Re: How to edit dexterity types without needing to know about their behaviors
ajung <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.devel |
|---|---|
| Message-ID | <[email protected]> |
ajung wrote
>
> johannes raggam wrote
>>
>> i'll fix that, probably at the wine and beer sprint. but then you'll
>> still always get UTC datetime values instead of localized ones, if you
>> get the start/end attributes directly from the context.
>>
>>> Consistency-is-king
>>> Andreas
>>
>> pragmatism is okay.
>> johannes
Here are the facts why plone.app.event currently freaks me out.
The source 'start' object is
v = DateTime('2008/09/09 09:00:00 GMT+2')
which translates to 07:00 UTC.
The migration code tries to concert the DateTime instance to a Python
datetime instance with UTC timezone and setting the 'timezone' of the event
object to 'Etc/GMT+2' using
v = v.asdatetime()
tz = str(v.tzinfo)
if tz.startswith('GMT'):
tz = 'Etc/%s' % tz
new_obj.timezone = tz
acc = IEventAccessor(new_obj)
v = v.replace(tzinfo=pytz.timezone('UTC'))
setattr(acc, k, v)
After the migration the event show up in Plone with
09.09.2008 um 07:00 bis 10.09.2008 um 15:00 (Etc/GMT+2 / UTC-200)
^^^^^^^^^^^^^^^^^^^^
Taking the debugger:
>>> ev = app.restrictedTraverse('eteaching/news/tagungen/ilias_2008/')
>>> ev.start
datetime.datetime(2008, 9, 9, 9, 0,
tzinfo=<plone.app.event.dx.behaviors.FakeZone object at 0xa7c1250>)
>>> ev = app.restrictedTraverse('eteaching/news/tagungen/ilias_2008/')
>>> ev.timezone
'Etc/GMT+2'
>>> ev.start
datetime.datetime(2008, 9, 9, 9, 0,
tzinfo=<plone.app.event.dx.behaviors.FakeZone object at 0xa7c1250>)
>>> ev.start.tzinfo
<plone.app.event.dx.behaviors.FakeZone object at 0xa7c1250>
>>> ev.start.tzinfo.tzname(ev.start)
'FAKEZONE'
That the hell is a FAKEZONE?
Obviously my code is wrong because it does not change the 'hour' from 9 to 7
(because of the two hours offset).
So I changed the code to
v = v.astimezone(pytz.utc)
In this case the output changed to
09.09.2008 um 05:00 ...
^^^^^^^^^^^^^^^^^^^^
...which is even more weird.
-aj
--
View this message in context: http://plone.293351.n2.nabble.com/How-to-edit-dexterity-types-without-needing-to-know-about-their-behaviors-tp7570571p7570628.html
Sent from the Core Developers mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech