[Zope] Class property in object creation form
Thierry Florac
thierry.florac@onf.fr
05 Dec 2002 17:19:42 +0100
Hi,
I'm currently building several Zope products working quite well but with
which I have a problem : how can I define class properties (most often
defined as lists actually) and use them in my creation forms written in
DTML.
For example, I've tried to use:
in file MyProduct.py :
class MyProduct(...):
MyProductProperty = [ 'item1', 'item2', 'item3' ]
def getMyProductProperty(self):
return MyProduct.MyProductProperty
in file __init__.py :
import MyProduct
...
def initialize(context):
context.registerClass (MyProduct.MyProduct,...)
...
methods={'myproduct_property':MyProduct.MyProduct.getMyProductProperty}
and finally in my DTML file :
<dtml-in myproduct_property>
...
</dtml-in>
But when I call my creation script from the ZMI, I get an error:
Traceback (innermost last):
* Module ZPublisher.Publish, line 150, in publish_module
* Module ZPublisher.Publish, line 114, in publish
* Module Zope, line 171, in zpublisher_exception_hook
* Module ZPublisher.Publish, line 98, in publish
* Module ZPublisher.mapply, line 88, in mapply
* Module ZPublisher.Publish, line 39, in call_object
* Module Shared.DC.Scripts.Bindings, line 252, in __call__
* Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
* Module App.special_dtml, line 174, in _exec
* Module DocumentTemplate.DT_In, line 628, in renderwob
* Module DocumentTemplate.DT_Util, line 201, in eval
__traceback_info__: myproduct_property
* Module <string>, line 0, in ?
* Module None, line 58, in getMyProductProperty
ImportError: No module named MyProduct
I forgot to tell you that I use Zope-2.6.0 with Python-2.1.3, and that I
didn't found any good example or documentation about this point
anywhere...
Thanks for any help,
Thierry
--
Linux every day, keeps Dr Watson away...
http://gpc.sourceforge.net -- http://www.ulthar.net