how to instantiate an External Method
How can i instantiate a external method within my Container Product? I've tryed to do this as following: ... from Products.ExternalMethod import ExternalMethod class Container(Folder): meta_type ='Container' def __init__(self, id, title): self.id = id self.title = title .... index_html = DTMLFile("dtml/indexContainer", globals()) search = PythonScript(id='search') searchService=ExternalMethod('searchService','searchService','search','search') ..... The id and title are "searchService" . The module and function name are 'search' and they are located in Extensions directory in my Container Product. The following error is printed: File "/home/zope/Zope2.7.4/lib/python/OFS/Application.py", line 673, in import_product product=__import__(pname, global_dict, global_dict, silly) File "/home/zope/Zope2.7.4/lib/python/Products/Container/__init__.py", line 1, in ? import Container,ItemSimples File "/home/zope/Zope2.7.4/lib/python/Products/Container/Container.py", line 22, in ? class Container(Folder): File "/home/zope/Zope2.7.4/lib/python/Products/Container/Container.py", line 36, in Container searchService=ExternalMethod('searchService','searchService','search','search') TypeError: 'module' object is not callable How could i solve it?
Wladmir Araujo Chapetta wrote:
How can i instantiate a external method within my Container Product?
Tell us why you think you need to first... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Wladmir Araujo Chapetta wrote at 2005-4-6 17:58 -0300:
... line 36, in Container searchService=ExternalMethod('searchService','searchService','search','search') TypeError: 'module' object is not callable
A nice and precise error message: "ExternalMethod" is the module and not the class (as you expect). And the module is not callable. Try: from Products.ExternalMethod.ExternalMethod import ExternalMethod Note that after this change, your code above will only work when "search.py" is located in your global "Extensions" folder. For product specific ExternalMethods, they usually are better located in the product's "Extensions" folder. In this case, the module spec must take the form "product.module". -- Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Wladmir Araujo Chapetta