[Checkins] SVN: five.grok/trunk/ Integrate grokcore.annotations in five.grok.

Sylvain Viollon sylvain at infrae.com
Tue Jun 16 05:36:49 EDT 2009


Log message for revision 101070:
  Integrate grokcore.annotations in five.grok.
  
  

Changed:
  U   five.grok/trunk/README.txt
  U   five.grok/trunk/buildout.cfg
  _U  five.grok/trunk/devel/
  U   five.grok/trunk/setup.py
  U   five.grok/trunk/src/five/grok/__init__.py
  U   five.grok/trunk/src/five/grok/configure.zcml
  U   five.grok/trunk/src/five/grok/meta.zcml
  A   five.grok/trunk/src/five/grok/tests/annotation.py
  U   five.grok/trunk/src/five/grok/tests/test_all.py

-=-
Modified: five.grok/trunk/README.txt
===================================================================
--- five.grok/trunk/README.txt	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/README.txt	2009-06-16 09:36:48 UTC (rev 101070)
@@ -33,8 +33,10 @@
 
 - Formlib forms,
 
-- Local sites and utilities.
+- Local sites and local utilities,
 
+- Annotations.
+
 All those components are available with exactly the same syntax than
 in grok. You just have to do::
 

Modified: five.grok/trunk/buildout.cfg
===================================================================
--- five.grok/trunk/buildout.cfg	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/buildout.cfg	2009-06-16 09:36:48 UTC (rev 101070)
@@ -6,6 +6,7 @@
     test
 develop = .
     devel/grokcore.site
+    devel/grokcore.annotation
 versions = versions
 newest = false
 


Property changes on: five.grok/trunk/devel
___________________________________________________________________
Modified: svn:externals
   - grokcore.site svn://svn.zope.org/repos/main/grokcore.site/trunk

   + grokcore.site svn://svn.zope.org/repos/main/grokcore.site/trunk
grokcore.annotation svn://svn.zope.org/repos/main/grokcore.annotation/trunk


Modified: five.grok/trunk/setup.py
===================================================================
--- five.grok/trunk/setup.py	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/setup.py	2009-06-16 09:36:48 UTC (rev 101070)
@@ -36,5 +36,6 @@
         'grokcore.viewlet',
         'grokcore.security',
         'grokcore.site',
+        'grokcore.annotation',
         ],
       )

Modified: five.grok/trunk/src/five/grok/__init__.py
===================================================================
--- five.grok/trunk/src/five/grok/__init__.py	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/src/five/grok/__init__.py	2009-06-16 09:36:48 UTC (rev 101070)
@@ -13,6 +13,7 @@
 ##############################################################################
 
 from grokcore.component import *
+from grokcore.annotation import *
 from grokcore.security import *
 from grokcore.site import *
 from grokcore.view import *

Modified: five.grok/trunk/src/five/grok/configure.zcml
===================================================================
--- five.grok/trunk/src/five/grok/configure.zcml	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/src/five/grok/configure.zcml	2009-06-16 09:36:48 UTC (rev 101070)
@@ -8,6 +8,7 @@
   <include package="five.grok" file="meta.zcml" />
 
   <include package="five.localsitemanager" />
+  <include package="grokcore.annotation" />
   <include package="grokcore.view" />
   <include package="grokcore.viewlet" />
 

Modified: five.grok/trunk/src/five/grok/meta.zcml
===================================================================
--- five.grok/trunk/src/five/grok/meta.zcml	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/src/five/grok/meta.zcml	2009-06-16 09:36:48 UTC (rev 101070)
@@ -4,6 +4,7 @@
     xmlns:grok="http://namespaces.zope.org/grok">
 
   <include package="grokcore.component" file="meta.zcml" />
+  <include package="grokcore.annotation" file="meta.zcml" />
   <include package="grokcore.security" file="meta.zcml" />
   <include package="grokcore.site" file="meta.zcml" />
 

Added: five.grok/trunk/src/five/grok/tests/annotation.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/annotation.py	                        (rev 0)
+++ five.grok/trunk/src/five/grok/tests/annotation.py	2009-06-16 09:36:48 UTC (rev 101070)
@@ -0,0 +1,49 @@
+"""
+  >>> grok.testing.grok(__name__)
+  >>> from zope import component
+  >>> from zope.annotation.attribute import AttributeAnnotations
+  >>> component.provideAdapter(AttributeAnnotations)
+
+We can adapt a model to an annotation interface and obtain a
+persistent annotation storage:
+
+  >>> manfred = Mammoth()
+  >>> branding = IBranding(manfred)
+  >>> branding.addBrand('mine')
+  >>> branding.addBrand('yours')
+
+Regetting the adapter will yield the same annotation storage:
+
+  >>> brands = IBranding(manfred).getBrands()
+  >>> brands.sort()
+  >>> brands
+  ['mine', 'yours']
+
+"""
+
+from five import grok
+from zope import interface
+from BTrees.OOBTree import OOTreeSet
+
+class Mammoth(grok.Model):
+    pass
+
+class IBranding(interface.Interface):
+
+    def addBrand(brand):
+        """Brand an animal with ``brand``, a string."""
+
+    def getBrands():
+        """Return a list of brands."""
+
+class Branding(grok.Annotation):
+    grok.implements(IBranding)
+
+    def __init__(self):
+        self._brands = OOTreeSet()
+
+    def addBrand(self, brand):
+        self._brands.insert(brand)
+
+    def getBrands(self):
+        return list(self._brands)


Property changes on: five.grok/trunk/src/five/grok/tests/annotation.py
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision

Modified: five.grok/trunk/src/five/grok/tests/test_all.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/test_all.py	2009-06-16 09:33:47 UTC (rev 101069)
+++ five.grok/trunk/src/five/grok/tests/test_all.py	2009-06-16 09:36:48 UTC (rev 101070)
@@ -87,6 +87,10 @@
             setUp=setUp, tearDown=testing.tearDown),
 
         doctestunit.DocTestSuite(
+            module='five.grok.tests.annotation',
+            setUp=setUp, tearDown=testing.tearDown),
+
+        doctestunit.DocTestSuite(
             module='five.grok.tests.multiadapter',
             setUp=setUp, tearDown=testing.tearDown),
 



More information about the Checkins mailing list