[Zope3-dev] storing per instance data in principalannotation
Christian Heimes
heimes@faho.rwth-aachen.de
Thu, 10 Apr 2003 17:18:54 +0200
Hello!
I just start working with principalannotations and I'm trying to add
some features for me. One feature is the ability that each instance can
store data for each principal. This is like a kind of combination of
attributeannotations and principalannotations.
I thought of this way:
* instance is querying for the annontation object of a principal:
a = getService(self.context,
'MyPrincipalAnnotation').getAnnotation(self.request.user)
* instance is using a special method to store it's data:
a.perInstanceData[self] = data
The perInstanceData method of the principalannotation class works like this:
* the key 'self' is converted to a RUID via object hub
* if there the key is already in the per instance data OOBTree the new
data is writen to the OOBTree
* if not the principal annotation service is told that there might be a
new instance that has to be monitored, then the data is saved.
QUESTION: How can I access the right principal annotation service? Can I
use getService and safely assume that I got the right service or should
I pass the service to the principal annotation as an option?
The principal annotation service keeps a list of all instance RUIDs that
had saved data in a principal annotation. The service monitors all this
instances for IObjectMovedEvent, IObjectCopiedEvent and
IObjectRemovedEvent via event hub. If it catches one of these events, it
iterates over all principal data and changes/deletes the corresponding data.
QUESTION: Is this way ok or does anybody know a better one? Would this
be a nice feature for the Zope3 principal annotation? If you have any
comments or suggestions you can reach me in #zope3-dev, too. My nick
name is Tiran.
Christian