zopefoundation / zope.annotation

Mechanism for storing additional information about objects without modifying their classes
Other
1 stars 8 forks source link

Can AttributeAnnotations set `__parent__`? #11

Closed jamadden closed 7 years ago

jamadden commented 7 years ago

This would make it compatible with the IConnection adapter provided by zope.keyreference (assuming the object it annotates is persistent), which could simplify some use cases. AttributeAnnotations is itself not persistent, though the BTree it contains is.

For pickle compatibility this could be a property that reads self.obj.

Are there any downsides to making this generally the case?

(This comes out of a discussion in a private repository.)

jamadden commented 7 years ago

I'll note that zope.principalannotation does this by default.

icemac commented 7 years ago

I'll note that zope.principalannotation does this by default.

But the Annotations object used there is a subclass of Persistent and Location.

I am not sure what you want to change. Could you sketch it on a branch? I think it is much easier to think about existing code.

jamadden commented 7 years ago

Sure, #13. It's very simple, it isn't even a new field.

icemac commented 7 years ago

I did not think it was that easy, but a line of code tells more than a hundred words. :-)