[Zope] creating and using a python object

Joh Johannsen jojo@farm9.com
Wed, 21 Feb 2001 05:21:23 -0800


--------------196F8623CF0502D1DE9F15CC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

At the moment, I guess it is impossible to use Python instances within
Zope.  (I'm surprised, something does not sound right about this...)

Here is what the Zope Book says:

> Problems can occurr if you hand instances of your own classes to Zope and expect them to work like Zope objects. For example, you cannot define a class in an
> External Method script file and assign it as an attribute of a Zope object. This causes problems with Zope's persistence machinary. 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 handing Zope simple Python structures like
> dictionaries and lists or Zope objects
>

I'm not so sure about this "causes problems with Zope's persistence
machinery"... what does that mean?



Joh Johannsen wrote:

> I've got the following python class:
>
> class TestClass:
>   def __init__(self):
>     pass
>
>   def getValue(self):
>     return 'test'
>
> How can I create an instance of it, and use it from within a DTML page?
>
> Thanks,
>
> JJ

--------------196F8623CF0502D1DE9F15CC
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
At the moment, I guess it is impossible to use Python instances within
Zope.&nbsp; (I'm surprised, something does not sound right about this...)
<p>Here is what the Zope Book says:
<blockquote TYPE=CITE>
<pre>Problems can occurr if you hand instances of your own classes to Zope and expect them to work like Zope objects. For example, you cannot define a class in an
External Method script file and assign it as an attribute of a Zope object. This causes problems with Zope's persistence machinary. 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 handing Zope simple Python structures like
dictionaries and lists or Zope objects</pre>
</blockquote>

<p><br>I'm not so sure about this "causes problems with Zope's persistence
machinery"... what does that mean?
<br>&nbsp;
<br>&nbsp;
<p>Joh Johannsen wrote:
<blockquote TYPE=CITE>I've got the following python class:
<p>class TestClass:
<br>&nbsp; def __init__(self):
<br>&nbsp;&nbsp;&nbsp; pass
<p>&nbsp; def getValue(self):
<br>&nbsp;&nbsp;&nbsp; return 'test'
<p>How can I create an instance of it, and use it from within a DTML page?
<p>Thanks,
<p>JJ</blockquote>
</html>

--------------196F8623CF0502D1DE9F15CC--