[Zope] Making a self written module available to Zope

Hong Yaun hongyuan at homemaster.cn
Sun Jan 23 11:20:15 EST 2005


Paul Winkler wrote:

>a trivial example:
>
># this is Products/MyFunctions/__init__.py
>
>from AccessControl import ModuleSecurityInfo
>
>def trivialFunc():
>   return True 
>
>def anotherFunc():
>   return False
>
>ModuleSecurityInfo('Products.MyFunctions').declarePublic(
>    'trivialFunc', 'anotherFunc'
>    ) 
>
># EOF
>
>  
>
Thanks for the sample and now I can access trivialFunc() from within a 
template file using:

<p tal:content="python:modules['Products.MyFunctions'].trivialFunc()"></p>

It works fine, just somewhat cumbersome. One way to simplify its usage 
is to use tal:define, like:

<p tal:define="func python:modules['Products.MyFunctions'].trivialFunc"
     tal:content="func()"></p>

But this would require using tal:define in every template file that 
could access the function.

Is there any other way to simplify the access to the function?

Best Regards
Hong Yuan



More information about the Zope mailing list