[Zope] Re: First python script in zope - import problem (permissions)
Joshua Lanza
jlanza@vorsite.com
Fri, 21 Dec 2001 23:01:18 -0800
I added a script object and directly pinched the code that Jason sent:=20
import DateTime
return DateTime.DateTime().millis()
and it seems to be working.=20
It is strange that it does though. I see in the help
(Control_Panel/Products/PythonScripts/Help/ModuleAccess.stx) that
"string, math, and random" are availible for import, but "The only way
to make other Python modules available for import is to add security
declarations to them in the filesystem". Not sure if they intended this
to mean the whole list or just a subset.=20
Josh
-----Original Message-----
From: Dan Shafer [mailto:dan@gui.com]=20
Sent: Friday, December 21, 2001 10:40 PM
To: zope@zope.org
Subject: [Zope] Re: First python script in zope - import problem
(permissions)
Joshua Lanza wrote:
>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?=3D20
I don't think you can do time-based stuff in a Python script in Zope.=20
On p. 153 of the Zope Book, it outlines the fairly tight restrictions=20
on what you can import into Python from inside Zope and the time=20
stuff is not listed.
You _can_ do this with an External Method, assuming you have proper=20
access rights to the outside-Zope portion of your server.
--=20
Dan Shafer, Author-Consultant
http://www.danshafer.com
http://www.shafermedia.com
_______________________________________________
Zope maillist - Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -=20
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )