[Zope] storing python objects

Chris Withers chris at simplistix.co.uk
Fri Oct 26 08:17:24 EDT 2007

Jonathan wrote:
> ----- Original Message ----- From: "David Bear" <David.Bear at asu.edu>
>> I need to run an external method to use some python functions that are
>> restricted within zope. I'm thinking an easy way to get the data back
>> would be to just store basic python objects within zodb; tupples,
>> lists, dictionaries.

Why not just have the external method return the results and call the 
external method from a python script?

>> but I've never seen this documented anywhere. Is it possible to store
>> basic python objects directly in zodb? AND then use a zpt to read the
>> data?


in your external method:

self.somefolder.mydata = {'whatever':'somevalue'}

> I have done something similar:  have an external method store a a 
> list/dictionary value in a property field on a folder, then a future 
> call to the external method retrieves that property field and uses 
> 'eval' to convert it back to a list/dictionary (it is stored as a 
> string). 

Why on *earth* would you do that?!
Why not just store the actual value rather than fiddling around with 
strings and eval?

> The other approach I have used is to create a dead simple Zope product 
> that just defines an object class (which contains lists, dictionaries, 
> etc) and then have the external method store these objects directly in 
> the ZODB.

You can either store in the root of the zodb, hang off an existing 
object, or just use SimpleItem.



Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk

More information about the Zope mailing list