[Grok-dev] Cataloging content in PersistenDict

Sebastian Ware sebastian at urbantalk.se
Tue Feb 12 09:09:37 EST 2008


For the record... When I moved the content from a PersistentDict to a  
grok.Container (removing the event notifications) it started working.  
I have no idea what I was doing wrong.

mvh Sebastian

8 feb 2008 kl. 19.17 skrev Leonardo Rochael Almeida:

> I don't see anything wrong with your code, though I'd strongly sugest
> you use one of the BTree flavors, instead of PersistentDict.
>
> The only benefit a PersistentDict gives you over a std dict is the
> implicit persistence. Other than that, accessing a PersistentDict
> loads it all to memory from the disk, even if all you want to do is a
> single insertion.
>
> I'd only use PD instead of a BTree if I know the number of stored
> elements will be small.
>
> On Feb 8, 2008 3:37 PM, Sebastian Ware <sebastian at urbantalk.se> wrote:
>> Can I catalog content in a PersistenDict, or are there other
>> requirements?
>>
>> Basically I have this:
>>
>> class Movement(grok.Model):
>>   interface.implements(interfaces.IMovement)
>>   title = 'My object'
>>
>> class Transaction(grok.Model):
>>   def __init__(self):
>>     self.movements = PersistentDict()
>>
>>   def create_stuff(self):
>>     mov_id = ...
>>     mov = Movement()
>>     self.movements[mov_id] = mov
>>     event.notify(lifecycleevent.ObjectCreatedEvent(mov))
>>     event.notify(lifecycleevent.ObjectModifiedEvent(mov,
>> interfaces.IMovement))
>>
>> class MovementIndex(grok.Indexes):
>>     grok.site(MySite)
>>     grok.context(interfaces.IMovement)
>>     grok.name('catalog')
>>     title = grok.index.Field()
>>
>> Should this work?
>>
>> Mvh Sebastian
>>
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> http://mail.zope.org/mailman/listinfo/grok-dev
>>



More information about the Grok-dev mailing list