[Zope-dev] RE: [Zope] Time module in python scripts

sean.upton@uniontrib.com sean.upton@uniontrib.com
Thu, 06 Feb 2003 14:30:16 -0800


I hope you all don't mind, but I've moved this to Zope-dev.  I would like to
propose that it be possible without modification (default behavior) in a
future version of Zope to import the time module and its methods safely into
TTW Python Scripts.

I haven't used this yet in TTW code (I've had to work around it), but it
seems like it might be good to un-restrict it, especially for CMF
installations that heavily utilize date metadata.
time.localtime(time.time()) is, AFAICT, the only way to determine if you are
in standard or DST at any point in time during the year.  You can't have a
page-template appropriately display correct times for content from multiple
time-zones without this (I'm sure many CMF installations will need this),
and it seems silly to write an external method for this; allowing import of
the time module is a good workaround, but I would suggest it be enabled by
default in Zope.

My particular use-case is AP newswire stories which are in EST/EDT.  The
timezone offset changes for this twice a year, and having a fixed
calculation based upon some assumption of a fixed timezone offset in my own
timezone (PST/PDT) won't work.  I need to be able to know my own timezone
offset to do the math, and for this I need to use
time.localtime(time.time())[8] to get it.  I'm sure "community" sites and
things like blogs, or anything else that works across the geographic
boundaries of differing time zones could use this too.

Thoughts?

Sean

-----Original Message-----
From: Chris McDonough [mailto:chrism@zope.com]
Sent: Thursday, February 06, 2003 2:01 PM
To: Chris Muldrow
Cc: 'zope@zope.org'
Subject: Re: [Zope] Time module in python scripts


Apparently.  See /lib/python/Products/PythonScripts/README.txt or the
Zope Developer's Guide Security chapter for info on how to enable it...

- C


On Thu, 2003-02-06 at 16:49, Chris Muldrow wrote:
> I'm trying to do
> Import time
> Time=time.time()
> 
> in a Python Script, but I'm getting login prompts and "Error Value: You
are
> not allowed to access time in this context" messages. Is the time module
one
> that's restricted in Python Script?
> Chris
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )



_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )