[ZODB-Dev] ZODB for context objects
Dieter Maurer
dieter at handshake.de
Tue Nov 1 05:41:59 EST 2005
Andre Meyer wrote at 2005-10-25 23:12 +0200:
>I am not sure whether ZODB is the right thing to use for my needs. So,
>what do I want?
>
>I have a number of threaded objects that have a context as a separate
>entity. The object and context need to be separated to allow for the
>threads to run asynchronously while their context aspects are shared in
>an environment model. The context aspect contains attributes that are
>perceivable from other objects, such as location, speed, colour etc.
>
>Now, my question is this: can I use ZODB to store my context objects and
>retrieve them by various attibutes. For example, can I look up easily
>all objects that have x and y coordinates within a given range? Or all
>objects of a given colour without knowing their names or paths?
>
>I hope that my question is clear, otherwise, please ask.
I fear, the ZODB is not optimal for your application:
Its normal usage mode expects that each thread opens its own
ZODB connection. Each connections maintains (lazyly) an
independent copy of the persistent objects. Synchronization
happens at transaction boundaries (only).
If you can formulate your application is these terms ("context" objects
come from different connections per thread), then the ZODB may be viable
(and easy to use). Otherwise, you probably should look for something else.
Note also, that the ZODB is a bit weak when the same persistent object
is written by concurrent threads. Such situations result in a
"ConflictError" for all but the first affected transaction.
The application should abort and retry the transaction in this case.
If such conflicts are expected to happen often, the ZODB is not optimal.
--
Dieter
More information about the ZODB-Dev
mailing list