[Grok-dev] Cataloging content in PersistenDict

Leonardo Rochael Almeida leorochael at gmail.com
Fri Feb 8 13:17:25 EST 2008


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