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

StackOverflow https://stackoverflow.com/questions/4832664

سؤال

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?

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

I've used a product called RedirectionTool for this.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top