Dario Lopez-Kästen wrote:
Andreas Jung wrote:
--On 1. Dezember 2005 13:46:55 -0200 Fernando Lujan
<[EMAIL PROTECTED]> wrote:
There's a way to use a Python class inside zope?
For instance, if I create the class:
"A simple example class"
i = 12345
return 'hello world'
Can I invoke the following code inside a Python Script?
x = MyClass()
PythonScripts are for *scripting* not for implementing complex
logic and for programming tasks that require classes. PythonScripts
don't provide full Python functionality that why were are talking of
*Restriced Python*. Consider writing your functionality as Python
all moral lessons aside, there are several use cases where access to
*objects*, passed to zope2 from external packages and modules, is
Most, if not all examples, out there assume that the external
packages/modules/classes can freely be converted to Zope-classes.
Now, assuming that I have not missed something fundamental, the
problem the way I see it, is that when my Product recieves an object
from the non-zope code, the object does not know anything about Zope,
it is just a happy Python-object.
But in order to even display it in a zpt I must transmogrify it into a
special zope-object, and *that* is not so easy as I have discovered.
In my case I am not so interested in importing the moduels or classes
into a Script(Python) - I have allready passed the objects in question
thtough my product, but still I get some "Zope Does Not Allow That"
So far I have not had any success with anything else than writing
special methods in my Classes that converts the objects to
dictionaries before passing them to the zpt or Script(Python) in
But that feels like a very awkward way of doing things, and it makeas
it *very* difficult for Zope to be a nice player with non-zope objects.
My 2 €-cents worth.
You need to call InitializeClass on your object, and that's it.
under "Zopifying our Python classes"
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -