[Checkins] SVN: grokcore.annotation/trunk/ Make the annotation aware of its context.

Sylvain Viollon sylvain at infrae.com
Thu Jul 2 08:54:21 EDT 2009


Log message for revision 101391:
  Make the annotation aware of its context.
  
  

Changed:
  U   grokcore.annotation/trunk/CHANGES.txt
  U   grokcore.annotation/trunk/src/grokcore/annotation/components.py
  U   grokcore.annotation/trunk/src/grokcore/annotation/meta.py

-=-
Modified: grokcore.annotation/trunk/CHANGES.txt
===================================================================
--- grokcore.annotation/trunk/CHANGES.txt	2009-07-02 12:28:13 UTC (rev 101390)
+++ grokcore.annotation/trunk/CHANGES.txt	2009-07-02 12:54:21 UTC (rev 101391)
@@ -4,7 +4,8 @@
 1.1 (unreleased)
 ----------------
 
-* ...
+* The annotation object become really a contained object to be aware
+  of its context [thefunny42 and trollfot].
 
 1.0.1 (2009-06-30)
 ------------------

Modified: grokcore.annotation/trunk/src/grokcore/annotation/components.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/components.py	2009-07-02 12:28:13 UTC (rev 101390)
+++ grokcore.annotation/trunk/src/grokcore/annotation/components.py	2009-07-02 12:54:21 UTC (rev 101391)
@@ -16,6 +16,7 @@
 """
 
 from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.app.container import contained
 import persistent
 import grokcore.component
 
@@ -26,6 +27,6 @@
     grokcore.component.implements(IAttributeAnnotatable)
 
 
-class Annotation(persistent.Persistent):
+class Annotation(persistent.Persistent, contained.Contained):
     """The base class for annotation classes in Grok applications.
     """

Modified: grokcore.annotation/trunk/src/grokcore/annotation/meta.py
===================================================================
--- grokcore.annotation/trunk/src/grokcore/annotation/meta.py	2009-07-02 12:28:13 UTC (rev 101390)
+++ grokcore.annotation/trunk/src/grokcore/annotation/meta.py	2009-07-02 12:54:21 UTC (rev 101391)
@@ -17,8 +17,6 @@
 
 from zope.annotation.interfaces import IAnnotations
 
-from zope.app.container.contained import contained
-
 import martian
 from martian import util
 
@@ -57,13 +55,12 @@
                 result = factory()
                 annotations[name] = result
 
-            # Containment has to be set up late to allow containment
-            # proxies to be applied, if needed. This does not trigger
-            # an event and is idempotent if containment is set up
-            # already.
-            contained_result = contained(result, context, name)
-            return contained_result
+            if result.__parent__ is None:
+                result.__parent__ = context
+                result.__name__ = name
 
+            return result
+
         config.action(
             discriminator=('adapter', adapter_context, provides, ''),
             callable=component.provideAdapter,



More information about the Checkins mailing list