RE: [Zope] Persistence - I know I'm not doing this right...
My question was a simplification of what I need to do. I need to store arrays of dictionaries, with 200 or more elements. And I need to access these from multiple points. In this context, can I still set variables in documents or other objects? Thanks. -----Original Message----- From: Sumiya Sakoda [mailto:sakoda@toyoake.or.jp] Sent: Tuesday, June 03, 2003 11:20 To: Samir Mishra Cc: Zope Mailing List Subject: Re: [Zope] Persistence - I know I'm not doing this right... At Tue, 3 Jun 2003 10:35:04 +0400, Samir Mishra wrote:
When I want to access 'x' & 'y', I call the above script.
Q: What's the right way to store persistent objects/data within Zope?
set the variables in object's property (for example DTML Document) may be light way (not right way) :-) - Sumiya Sakoda <sakoda@toyoake.or.jp>
Samir Mishra wrote:
My question was a simplification of what I need to do. I need to store arrays of dictionaries, with 200 or more elements. And I need to access these from multiple points. In this context, can I still set variables in documents or other objects?
You could use an external method and just set attributes on Document objects or some such, but this is a hack. Better would be to learn how to write Python Products and build your own Product... cheers, Chris
Samir Mishra wrote:
My question was a simplification of what I need to do. I need to store arrays of dictionaries, with 200 or more elements. And I need to access these from multiple points. In this context, can I still set variables in documents or other objects?
You set persistant data on an object by just setting it. object.foobar = 6 That's all you need to do. If you create object classes that should be used: object.foobar = MyObject() then it need to inherit from Persistence.Persistent. If you are using mutable types like lists and dictionaries, you need to use Persistent version of them, called PersistentList and PersistentMapping. In your case, with large amounts of dictionaries, you also might want to look into using BTrees to speed things up.
participants (3)
-
Chris Withers -
Lennart Regebro -
Samir Mishra