ZODB, maintaining referential integrity

41 visualizzazioni
Passa al primo messaggio da leggere

Joe Steeve

da leggere,
21 apr 2016, 03:37:0721/04/16
a Pylons Discuss
How to maintain "referential integrity" in a ZODB. Simply put: When an
object-A is removed from a container, the references to object-A, in
other objects should go invalid.

I tried holding a persistent.WeakRef whenever a reference was required.
However, the WeakRef seems to go invalid only after a GC on the db
(correct me if I am wrong).

The other approach seems to be to use IObjectWillBeRemovedEvent at the
site of the referencing object, to act accordingly.

How do other people deal with this?

--
Joe Steeve
HiPro IT Solutions Private Limited
http://hipro.co.in/
signature.asc

Thierry Florac

da leggere,
21 apr 2016, 05:09:5121/04/16
a pylons-...@googlegroups.com
Hi,

Actually I handle this use case using IObjectRemovedEvent subscribers.
Can't see any other simple way...  :-/

Best regards,
Thierry


--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/1461224218.20052.19.camel%40hipro.co.in.
For more options, visit https://groups.google.com/d/optout.



--

Chris Rossi

da leggere,
21 apr 2016, 10:11:4421/04/16
a pylons-...@googlegroups.com
The other approach would be to only store objects in one canonical place, and use references that just store the path to the object or the oid.

Chris

Thierry Florac

da leggere,
21 apr 2016, 10:50:2821/04/16
a pylons-...@googlegroups.com
Hi !

I often use internal IDs (via an IIntIds utility) to store objects references.
The drawback of this method is that you have an indirection and you always have to check that the reference target is still available before using it!
So even in this use case I use an event listener to remove the reference when the target is removed...

Best regards,
Thierry


For more options, visit https://groups.google.com/d/optout.

Joe Steeve

da leggere,
2 mag 2016, 07:52:1602/05/16
a pylons-...@googlegroups.com
On Thu, 2016-04-21 at 11:09 +0200, Thierry Florac wrote:
> Actually I handle this use case using IObjectRemovedEvent subscribers.
> Can't see any other simple way... :-/

I am taking this approach. Specifically I am using repoze.folder's
IObjectWillBeRemoved. Thanks :)
signature.asc
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi