How to implement Persistent List or Persistent Mapping in ZODB

One to many relations that do not work in ZODB, like a list, are mutable. They say the solution is Persistent Mapping or Persistent List or BTree. Someone please tell me how this is done.

+2


a source to share


1 answer


I'm not sure I understand your question.

A PersistentMapping behaves like a dictionary but is persistent. PersistentList is just a list that is persistent.

A BTree behaves like a dictionary, but is optimized for a huge number of objects. You shouldn't use PersistentMapping or PersistentList if you have to deal with many objects.



For ZODB relationships, you can use object references as you would normally in Python.

ZODB even supports weak links if you need them.

There are other specialized packages like z3c.relationfield for dealing with relationships in ZODB, for example if you need to search by relationships, but I've never needed to use them.

+5


a source







All Articles