Re: [Zope-dev] Granularity of Persistent Objects
Ian Beatty wrote: However, I don't know how to do this. Is it as simple as using a PersistentMapping where I'd normally use a standard Python dictionary? Well, yes. Or shall I wrap each one in a custom class that subclasses Persistent? That is usually an even better idea. And for big dictionaries, you may want to use the BTree objects for storage. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Granularity of Persistent Objects
Or shall I wrap each one in a custom class that subclasses Persistent? That is usually an even better idea. And for big dictionaries, you may want to use the BTree objects for storage. So in my containing class, I just have class MyContainer( Persistent ): subObject = None def __init__( self ): self.subObject = BTree() and etc.? That's all there is to it?? Thanks, ..Ian ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Granularity of Persistent Objects
In article [EMAIL PROTECTED] you write: Or shall I wrap each one in a custom class that subclasses Persistent? That is usually an even better idea. And for big dictionaries, you may want to use the BTree objects for storage. So in my containing class, I just have class MyContainer( Persistent ): subObject = None def __init__( self ): self.subObject = BTree() and etc.? That's all there is to it?? Yes, that's it. You can even store BTree's in BTree's if you fancy :) Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:[EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Granularity of Persistent Objects
On Thu, Jul 15, 2004 at 02:54:54PM -0400, Ian Beatty wrote: Greetings. I'm developing a Zope (2.7) product, and I've got a particular persistent object that's going to be a real bottleneck, in that there will be many threads trying to change the state of the object more or less simultaneously. I'd like to spread out the problem by taking member fields of the object (lists, dictionaries, etc.) and making them persistent sub-objects in their own right. That way, changes made to one of them can be saved to the ZODB without causing thread conflicts with changes being made to others, removing at least some of the thred conflicts. sounds reasonable... However, I don't know how to do this. Is it as simple as using a PersistentMapping where I'd normally use a standard Python dictionary? Instead of PersistentMapping, see the various flavors of BTree, e.g. OOBTree, IOBTree. These do their own conflict resolution and in your scenario that could be a big help. -- Paul Winkler http://www.slinkp.com ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )