[Zope-dev] Referencing a python method from a product page template

Coletti Massimo m.coletti at finnat.it
Wed Oct 20 04:31:16 EDT 2004


Hi,

I am defining a Zope product to create a new portlet, the portlet will
display some contents retrieved from a python module.

Under the product dir I have a file queryBFE.py, with a method
returnQuery(); the method returns a dictionary.

In the __init__.py at product level, there is an:
allow_module('Products.CorpQuotes.queryBFE')

The portlet page template is stored under a skin directory, properly
registered in CFM.

In the portlet text, I tried two syntaxes to call the method:

a)

<span tal:define="modulo here/queryBFE;
                            quotazione modulo/returnQuery;">

b)

<span tal:define="quotazione
modules/Products/CorpQuotes/queryBFE/returnQuery">
 
The first one returns:

Exception Type
    AttributeError
Exception Value
    queryBFE

The second one returns:

Tipo di errore
    AttributeError
Valore dell'errore
    queryBFE

  Module Products.PageTemplates.TALES, line 220, in evaluate
   - URL: /Plone/FinnatHome_view
   - Line 13, Column 10
   - Expression: standard:'here/queryBFE'
   - Names:
      {'container': <PloneSite instance at 0170EF50>,
       'context': <Document at /Plone/index.html>,
       'default': <Products.PageTemplates.TALES.Default instance at
0x010BF5F8>,
       'here': <Document at /Plone/index.html>,
       'loop': <SafeMapping instance at 025E2C50>,
       'modules':
<Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at
0x010AED00>,
       'nothing': None,
       'options': {'args': ()},
       'repeat': <SafeMapping instance at 025E2C50>,
       'request': <HTTPRequest, URL=http://localhost:8082/index.html>,
       'root': <Application instance at 017C29E0>,
       'template': <ZopePageTemplate at /Plone/FinnatHome_view used for
/Plone/index.html>,
       'traverse_subpath': [],
       'user': coletti}
  Module Products.PageTemplates.Expressions, line 201, in __call__
  Module Products.PageTemplates.Expressions, line 189, in _eval
  Module Products.PageTemplates.Expressions, line 145, in _eval
   - __traceback_info__: here
  Module Products.PageTemplates.Expressions, line 354, in
restrictedTraverse
   - __traceback_info__: {'path': ['queryBFE'],
'TraversalRequestNameStack': []}
AttributeError: queryBFE

HELP!

massimo

This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.


More information about the Zope-Dev mailing list