[Zope3-dev] Calling persistent function

Jim Fulton jim at zope.com
Thu Jan 22 06:30:43 EST 2004


Jim Fulton wrote:
> Danny Smith wrote:
> 
>> I figured out how to add a persistent module to the
>> site manager but not how to call a function in it from
>> a page template.  The expression:
>>
>> <span tal:content="python:
>> container.getSiteManager()['default'].resolve('foo.bar')"
>> />
>>
>> will correctly resolve the bar function in the module
>> foo, but when I try to call it I get
>> ForbiddenAttribute __call__.
>>
>> I'm just playing around, is it possible to call a
>> persistent function from a page template?
> 
> 
> Not yet.  They aren't really meant for this sort of use.
> They exist mainly to:
> 
> - Be imported into other modules
> 
> - Registered as components.
> 
> For example, you should be able to register opersistent
> functions and classes as adapters.
> 
> This is all pretty raw and experimental at this point.

I should add that I'm open to suggestions as to how they should
be used.  Some other notes:

- It will eventually be possible to use them via the zpt module
   namespace:

   modules/foo.bar/myfunc

- It will be possible to access utilities in zpt, although
   we haven't figured out a syntax yet.  It will be possible to
   register persistent modules as utilities.

- I'm in favor of something like Evan Simpson's PythonLibraries:

     http://mail.zope.org/pipermail/zope-dev/2003-September/020429.html

   This would be like a persistent module that you could add to content
   space.

Jim





-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list