[Zope3-checkins] SVN: Zope3/trunk/src/zope/formlib/form.py if formlib can't find an IRequest -> ITZInfo adapter, use UTC instead

Benji York benji at zope.com
Wed Oct 5 16:00:24 EDT 2005


Log message for revision 38777:
  if formlib can't find an IRequest -> ITZInfo adapter, use UTC instead
  

Changed:
  U   Zope3/trunk/src/zope/formlib/form.py

-=-
Modified: Zope3/trunk/src/zope/formlib/form.py
===================================================================
--- Zope3/trunk/src/zope/formlib/form.py	2005-10-05 19:54:40 UTC (rev 38776)
+++ Zope3/trunk/src/zope/formlib/form.py	2005-10-05 20:00:24 UTC (rev 38777)
@@ -18,6 +18,7 @@
 import datetime
 import re
 import sys
+import pytz
 
 import zope.event
 import zope.i18n
@@ -776,12 +777,16 @@
                 zope.app.event.objectevent.ObjectModifiedEvent(self.context))
             formatter = self.request.locale.dates.getFormatter(
                 'dateTime', 'medium')
+
+            try:
+                time_zone = idatetime.ITZInfo(self.request)
+            except TypeError:
+                time_zone = type(pytz.UTC)
+
             status = _("Updated on ${date_time}",
                        mapping={'date_time':
                                 formatter.format(
-                                   datetime.datetime.now(
-                                       idatetime.ITZInfo(self.request)
-                                       )
+                                   datetime.datetime.now(time_zone)
                                    )
                         }
                        )



More information about the Zope3-Checkins mailing list