[Zope] Re: request.locale - do we have this in 2.9.4?

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Thu Sep 7 04:55:22 EDT 2006


> Sure. As I said earlier, we are happy to accept patches :)

I've written simple path that, at last, causes DateDisplayWidget
doesn't raise exceptions and has minimalistic locale aware date
formatting (according to docs about time module and strftime
function with %x and %X).
I've added overrides.zcml that redefines DateDisplayWidget
and DatetimeDisplayWidget.

File textwidgets.py should be placed in Five/form/
and overrides.zcml in Five/ (possibly there should be
rather include of Five/form/overrides.zcml)

I'm not sure if it is suitable to Five philosophy (especially overrides)
so comments are welcome.


Another idea of being locale aware with DateDisplay widgets
is similiar to one used in CalZope from Nuxeo.Use translation
to get proper (locale aware) date formats. But I'm not sure
where such translations should be defined and what are
'short', 'medium', 'long' and 'full' formats used
by getFormatter in Zope3. I mean something like:

msgid = _('YYYY-MM-DD')
res = translate(msgid, context=self.request, default=msgid)
return renderElement("span", contents=escape(res),
                         cssClass=self.cssClass)

-- 
Maciej Wisniowski
-------------- next part --------------
<configure xmlns="http://namespaces.zope.org/zope"
           xmlns:browser="http://namespaces.zope.org/browser">

    <view
      type="zope.publisher.interfaces.browser.IBrowserRequest"
      for="zope.schema.interfaces.IDate"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".form.textwidgets.DateDisplayWidget"
      permission="zope.Public"
      />
      
    <view
      type="zope.publisher.interfaces.browser.IBrowserRequest"
      for="zope.schema.interfaces.IDatetime"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".form.textwidgets.DatetimeDisplayWidget"
      permission="zope.Public"
      />

</configure>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: textwidgets.py
Type: text/x-python
Size: 2357 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20060907/5c47e2e7/textwidgets.py


More information about the Zope mailing list