Hi Yuri,

Yuri wrote:
Tino Wildenhain wrote:
Yuri wrote:
Hi, all!

I would like to define a class inside a python script (so I can catalog it and use catalog to store info, as the tutorial about catalog everything suggests).

Its not possible in Python Scripts. You would need to write either
an external method or a small product.


You also cannot easily hand instances of your own classes over to DTML or scripts. The issue here is that your instances won't have Zope security information. You can define and use your own classes and instances to your heart's delight, just don't expect Zope to use them directly. Limit yourself to returning simple Python structures like strings, dictionaries and lists or Zope objects.

So developing a product, is the only option?

Well actually its not so hard as it seems. And products are more
easy to handle then external methods (initializing is more clear).

All you need to create a folder with a good name for your project
in the instance or common Products folder (depending on your
zope.conf ) then copy ZOPE_ROOT/lib/python/Products/PythonScripts/module_access_example.py to YourFanceProduct/__init__.py

then you edit this file to your likings based on both the documentation
(yes I know this is a bit sparse) and the hints given in that file.

Not you can define your own classes and functions in this file as
well. For better structure you are encouraged to create actual
module files in that directory instead of writing everything
into __init__.py once your create more then just a toolset.


Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to