[Zope3-dev] Re: widgets and ZCML (was widget question: propertyNames/getValue)

Gary Poster gary at modernsongs.com
Thu Feb 19 15:33:24 EST 2004



Garrett Smith wrote:
> Gary Poster wrote:
> 
>>I'd like to be able to explicitly override labels in zcml too.
>>
>><addform ...>
>>   <widget class=".widgets.DualListWidget">
>>     <label id="available_items" value="Available Vehicles" />
>>     <label id="selected_items" value="Selected Vehicles" />
>>   </widget>
>></addform>
>
...
>   <widget class=".widgets.DualListWidget">
>     <field name="availableItemsLabel">Available Vehicles</field>
>     <field name="selectedItemsLabel">Selected Vehicles</field>
>   </widget>
> 
> (This is a hypothetical format for specifying field values in ZCML -
> lots of hand waiving at this point.)
> 
> I might be totally missing your point :-) but this is the sort of thing
> I'm thinking about for widgets and ZCML. (Note also that specifying
> schema in ZCML opens up world of other possibilities wrt content types
> and whatever else uses schema.)

I think we are on the same page as far as goals, so cool.  :-)  So, 
since I think we agree, I'm dealing with details.

My proposed zcml was an attempt to leverage the current zcml machinery 
particularly in regards to i18n message ids.  What it comes down to is 
that we need to distinguish between non-message-id fields, which merely 
need to be cast in order to do what we want, and message-id fields, 
which nominally need casting but more importantly need to be findable by 
the i18n message-id extraction machinery.  We do that by specifying that 
an attribute is a message id in the zcml definition schema.

So, two takes that would handle this:

one...

<widget field="start_date"
   class=".widgets.DatePicker" format="%Y-%m-%d">
   <label id="format_description" value="Use Year-month-date" />
</widget>

two...

<widget field="start_date" class=".widgets.DatePicker"
   <property name="format" value="%Y-%m-%d" />
   <label id="format_description" value="Use Year-month-date" />
</widget>

Or similar variants (obviously I'm attribute-friendly and you're 
contents-friendly...I think zcml is ok with the contents approach but I 
forget how to do it...)

:-)

Gary



More information about the Zope3-dev mailing list