[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/src/zope/publisher- browser.py:1.7

Tres Seaver tseaver@zope.com
13 Feb 2003 11:43:25 -0500


On Thu, 2003-02-13 at 11:14, Shane Hathaway wrote:
> Jim Fulton wrote:
> > Marius Gedminas wrote:
> >> I think zope.app.datetimeutils should be moved to zope.datetimeutils.

Apologies for introducing this dependency.  The 'datetimeutils' module
is a bit of a mess.

> > I think that's reasonable. Another option would be to make the publisher
> > marshaling facility pluggable, so that zope.app could plug in a specialized
> > date-time parser.
> 
> We'll need pluggable date time parsing anyway for I18N.  In Brazil, for 
> example, "13.02.03" and "13 Fevereiro 2003" are valid dates.
> 
> Just to make it more complicated, :-) the choice of date time parsing 
> routines probably ought not to be global, and should instead be 
> request-specific.  Some (many?) sites are multilingual.

Right.  This is why my checkin to zope.publisher.browser says:

+    # *Don't* force a timezone if not passed explicitly;  leave it as
+    # "naive" datetime.
+    year, month, day, hour, minute, second, tzname = \
        parseDateTime(v, local=0)
+
+    # TODO:  look up a real tzinfo object using 'tzname'
+    #
+    # Option 1:  Use 'timezones' module as global registry::
+    #
+    #   from zope.app.timezones import getTimezoneInfo
+    #   tzinfo = getTimezoneInfo(tzname)
+    #
+    # Option 2:  Use a utility.
+    #
+    #   tz_lookup = getUtility(None, ITimezoneLookup)
+    #   tzinfo = tz_lookup(tzname)
+    #
+    return datetime(year, month, day, hour, minute, second,
+                  # tzinfo=tzinfo
+                   )

Although it would need to be a "resource" (or "view"?) rather than a
"utility" if it needs to be conformed to the request.  Perhaps the
interface is something like::

  class IQueryStringMarshaller:
      def __call__(value, marshal_type):
          """Convert 'value' per the semantics of 'marshall_type'.
          """

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com