[Zope] Persistence - I know I'm not doing this right...

Lennart Regebro lennart@regebro.nu
Tue, 03 Jun 2003 11:28:34 +0200

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.