Le 18/07/2011 18:16, David Glick a écrit :
> On 7/18/11 9:08 AM, Alexandre Garel wrote:
>> Hello,
>> We are building up an application where we use multiple zodb instances.
>> Indexation is done using solr.
>> zodb are served through zc.zodbwsgi. ZODB connections are set only
>> on-demand, upon traversal. Each zodb has its intid local utility. Each
>> object also has a uuid.
>> I have a zodb with global parameters objects on /params and distinct
>> zodb as /foo /bar /baz and so on.
>> Objects in a zodb may reference objects of the same zodb or of /params.
>> I have two possible strategies :
>> - either store uuid of referenced objects and retrieve objects from solr
>> (which will give me a zodb name + intid of object)
>> - either directly reference the objects of /params
>> Of course second option seems better and more natural.
>> I read
>> http://svn.zope.org/ZODB/trunk/src/ZODB/tests/multidb.txt?rev=99605&view=markup
>> and using pdb on databases = request.environ['zodb.connection'] I can
>> see the zodb.databases map
>> which is ok. I also know that _p_oid is unique and _p_jar handled for
>> each object so I feel confident on this side.
>> So before I dive into this, is this kind of cross-database reference
>> used on production applications. Is there any-risk or any trick to be
>> aware ?
> Using cross-database references can be treacherous, because the garbage
> collection that occurs when packing a ZODB the typical way is not aware
> of the cross-db references. So if there's an object in one db that is
> only referenced from a different db, it will get garbage-collected
> during packing. You can probably use
> http://pypi.python.org/pypi/zc.zodbdgc instead of standard packing to
> avoid that problem.

Thanks for the advice.

I normally won't fall in this case as my params objects are contained in 
parents and must exists even when all other zodb would not.

Thanks for your feedback.

Alex Garel

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to