[ZPT] permissions getting to python modules?

Peter Bengtsson mail@peterbe.com
Mon, 20 Aug 2001 10:01:36 +0200


----- Original Message -----
From: "Chris Curvey" <ccurvey@bellatlantic.net>
To: <chris@chriscurvey.com>
Cc: <zpt@zope.org>
Sent: Saturday, August 18, 2001 4:46 PM
Subject: Re: [ZPT] permissions getting to python modules?


> Found it.  In order to access module besides string, math and random from
> ZPT, you need to tell Zope that it's OK to run it.
>
> in PageTemplates/__init__.py, add the following lines:
>
> from Products.PythonScripts.Utility import allow_module
> allow_module("time")  # or whatever module you want to allow folks to use
>
> (I put these lines before "def initialize", I don't know if the location
is
> important.)
>
> I'm uncomfortable changing the __init__.py script for someone else's
> product.  Is there a way around this?

http://www.zope.org/Members/Caseman/Dynamic_Hotfix
A better way not to poke in somebody else's code.

>
> Chris Curvey wrote:
>
> > I'm hoping someone will give me an "A-ha!" moment here.
> >
> > I'm trying to get a page to show the current date (e.g. "August 17").  I
> > was building up my page and came up with this:
> >
> > <html>
> >   <head>
> >     <title tal:content="template/title">The title</title>
> >   </head>
> >   <body>
> >     <span tal:replace="template/title" />
> >
> >     For the Week of <span tal:define="time modules/time"
> >     tal:replace="python:time.time()">Date</span>
> >   </body>
> > </html>
> >
> > But when I try to test it, Zope starts asking for username and password
> > again.  (Not only that, but I can't seem to get to anything anymore, no
> > matter how many times I put in the right username and password.)
> >
> > I think I'm missing something in security, but I can't figure out what.
> > My assumption is that you need special security to call the "time"
> > module because it's outside of Zope.
> >
> > -Chris
> >
> > P.S.  I know that the given code will give me a tuple of time values
> > instead of time, I'll give extra credit to anyone who can start me down
> > the path of converting the tuple to "August 17"
> >
> > --
> > Chris Curvey
> > Curvey Consulting
> > http://www.chriscurvey.com
> >
> > _______________________________________________
> > ZPT mailing list
> > ZPT@zope.org
> > http://lists.zope.org/mailman/listinfo/zpt
>
> --
> Chris Curvey
> Curvey Consulting
> http://www.chriscurvey.com
>
>
>
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://lists.zope.org/mailman/listinfo/zpt