Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like a "symbolic link" (in *nixes terms) but for objects in ZODB in Plone?

Suppose I have an object in /school1/document-rules.

Suppose in another context, /school2, I need to have the same document-rules that is available in /school1/document-rules.

In ZODB, having /school1/document-rules and /school2/document-rules means I have two different objects.

I would like to know if it's possible to make /school2/document-rules reference /school1/document-rules. So, /school2/document-rules would be something like a "ReferenceDocument", "ReferenceLink" or something like a symbolic link that would just point to /school1/document-rules.

Why? The document is the same, but sometimes it makes more sense (in semantic terms) to have the same document in different contexts. I have portlets that are rendered depending in their context, and I don't want to duplicate document-rules.

Does something like what I'm looking for exist? Bultin or using a module?

like image 525
Somebody still uses you MS-DOS Avatar asked Jan 20 '23 15:01

Somebody still uses you MS-DOS


2 Answers

SimpleAlias does what you want. I've used it and it works well. You could also look at collective.alias

like image 197
djay Avatar answered Jan 31 '23 07:01

djay


ZODB handles references transparently as you would expect in plain Python. You have a nice explanation here.

You should watch out for multiple references for the same object when you want to delete the object. For that you might want to use weak references for your 'symlinks' using the weakref module from ZODB which is equivalent to weakref of the Python standard library.

like image 37
Danny Navarro Avatar answered Jan 31 '23 06:01

Danny Navarro