----- Original Message -----
From: "Chris Withers" <[EMAIL PROTECTED]>
To: "Jonathan" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "zope" <[email protected]>
Sent: Friday, October 26, 2007 8:17 AM
Subject: Re: [Zope] storing python objects
Jonathan wrote:
----- Original Message ----- From: "David Bear" <[EMAIL PROTECTED]>
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?
Yes.
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?
If you want to be able to inspect the list/dictionary via the ZMI then
storing the list/dict as a property on an object (eg. folder) allows you to
do that - but if you do not need access via the ZMI, then storing the
list/dict directly on the object will be more efficient.
Jonathan
_______________________________________________
Zope maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )