[Zope] First python script in zope - import problem (permissions)

Jason Earl jason.earl@simplot.com
21 Dec 2001 09:34:43 -0700


The time module is probably off limit in Python Scripts (I am just
guessing, but that's what it looks like).  Try the Zope DateTime
module instead.  Something like this should be more or less what you
are looking for.

import DateTime

return DateTime.DateTime().millis()

Jason

"Joshua Lanza" <jlanza@vorsite.com> writes:

> Hi,
> 
> I have created a new script object called get_timestamp. I put the
> following code in there:
> 
> import time
> return int(time.time())
> 
> When I try to test it, I get user and password prompt and Unauthorized.
> Something else I need to do? 
> 
> 
> Here's the trace:
> 
> <!--
> 
> Traceback (innermost last):
>   File C:\PROGRA~1\zope2\lib\python\ZPublisher\Publish.py, line 223, in
> publish_module
>   File C:\PROGRA~1\zope2\lib\python\ZPublisher\Publish.py, line 187, in
> publish
>   File C:\PROGRA~1\zope2\lib\python\ZPublisher\Publish.py, line 171, in
> publish
>   File C:\PROGRA~1\zope2\lib\python\ZPublisher\mapply.py, line 160, in
> mapply
>     (Object: get_timestamp)
>   File C:\PROGRA~1\zope2\lib\python\ZPublisher\Publish.py, line 112, in
> call_object
>     (Object: get_timestamp)
>   File C:\PROGRA~1\zope2\lib\python\Shared\DC\Scripts\Bindings.py, line
> 324, in __call__
>     (Object: get_timestamp)
>   File C:\PROGRA~1\zope2\lib\python\Shared\DC\Scripts\Bindings.py, line
> 354, in _bindAndExec
>     (Object: get_timestamp)
>   File
> C:\PROGRA~1\zope2\lib\python\Products\PythonScripts\PythonScript.py,
> line 363, in _exec
>     (Object: get_timestamp)
>     (Info: ({'script': &lt;PythonScript instance at 01088950&gt;,
> 'context': &lt;Application instance at 00FA8580&gt;, 'container':
> &lt;Application instance at 00FA8580&gt;, 'traverse_subpath': []}, (),
> {}, None))
>   File Script (Python), line 2, in get_timestamp
>     (Object: guarded_getattr)
>   File C:\PROGRA~1\zope2\lib\python\AccessControl\ZopeGuards.py, line
> 122, in guarded_getattr
>     (Object: time)
>   File C:\PROGRA~1\zope2\lib\python\AccessControl\SecurityManager.py,
> line 149, in validate
>   File C:\PROGRA~1\zope2\lib\python\AccessControl\ZopeSecurityPolicy.py,
> line 172, in validate
> Unauthorized: time
> 
> -->
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )