[Checkins] SVN: zope.principalannotation/tags/ Tag 3.6.0
Dan Korostelev
nadako at gmail.com
Mon Mar 9 11:02:20 EDT 2009
Log message for revision 97698:
Tag 3.6.0
Changed:
A zope.principalannotation/tags/
A zope.principalannotation/tags/3.6.0/
D zope.principalannotation/tags/3.6.0/CHANGES.txt
A zope.principalannotation/tags/3.6.0/CHANGES.txt
U zope.principalannotation/tags/3.6.0/buildout.cfg
U zope.principalannotation/tags/3.6.0/setup.py
D zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py
A zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py
-=-
Deleted: zope.principalannotation/tags/3.6.0/CHANGES.txt
===================================================================
--- zope.principalannotation/trunk/CHANGES.txt 2009-03-09 14:33:38 UTC (rev 97694)
+++ zope.principalannotation/tags/3.6.0/CHANGES.txt 2009-03-09 15:02:19 UTC (rev 97698)
@@ -1,9 +0,0 @@
-=======
-CHANGES
-=======
-
-3.6.0 (unreleased)
-------------------
-
-Initial release. This package was splitted off zope.app.principalannotation
-to remove its dependencies on "zope 3 application server" components.
Copied: zope.principalannotation/tags/3.6.0/CHANGES.txt (from rev 97696, zope.principalannotation/trunk/CHANGES.txt)
===================================================================
--- zope.principalannotation/tags/3.6.0/CHANGES.txt (rev 0)
+++ zope.principalannotation/tags/3.6.0/CHANGES.txt 2009-03-09 15:02:19 UTC (rev 97698)
@@ -0,0 +1,19 @@
+=======
+CHANGES
+=======
+
+3.6.0 (2009-03-09)
+------------------
+
+Initial release. This package was splitted off zope.app.principalannotation
+to remove its dependencies on "zope 3 application server" components.
+
+In addition, the following changes were made after split off:
+
+ - The IAnnotations implementation was fixed to look in the higher-level
+ utility not only on ``__getitem__``, but also on ``get`` and ``__nonzero``.
+
+ - Tests was reworked into the README.txt doctest.
+
+ - Added a buildout part that generates Sphinx documentation from the
+ README.txt
Modified: zope.principalannotation/tags/3.6.0/buildout.cfg
===================================================================
--- zope.principalannotation/trunk/buildout.cfg 2009-03-09 14:33:38 UTC (rev 97694)
+++ zope.principalannotation/tags/3.6.0/buildout.cfg 2009-03-09 15:02:19 UTC (rev 97698)
@@ -1,5 +1,5 @@
[buildout]
-develop = . ../zope.site
+develop = .
parts = test coverage-test coverage-report docs
[test]
Modified: zope.principalannotation/tags/3.6.0/setup.py
===================================================================
--- zope.principalannotation/trunk/setup.py 2009-03-09 14:33:38 UTC (rev 97694)
+++ zope.principalannotation/tags/3.6.0/setup.py 2009-03-09 15:02:19 UTC (rev 97698)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.principalannotation',
- version = '3.6.0dev',
+ version = '3.6.0',
author='Zope Corporation and Contributors',
author_email='zope-dev at zope.org',
description='Annotations for Zope Principals',
Deleted: zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py
===================================================================
--- zope.principalannotation/trunk/src/zope/principalannotation/utility.py 2009-03-09 14:33:38 UTC (rev 97694)
+++ zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py 2009-03-09 15:02:19 UTC (rev 97698)
@@ -1,124 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2009 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Implementation of IPrincipalAnnotationUtility
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-from BTrees.OOBTree import OOBTree
-from persistent import Persistent
-from persistent.dict import PersistentDict
-from zope import interface, component
-from zope.annotation.interfaces import IAnnotations
-from zope.container.contained import Contained
-from zope.location import Location
-from zope.security.interfaces import IPrincipal
-from zope.site.next import queryNextUtility
-
-from zope.principalannotation.interfaces import IPrincipalAnnotationUtility
-
-# TODO: register utility as adapter for IAnnotations on utility activation.
-
-class PrincipalAnnotationUtility(Persistent, Contained):
- """Stores `IAnnotations` for `IPrinicipals`.
-
- The utility ID is 'PrincipalAnnotation'.
- """
-
- interface.implements(IPrincipalAnnotationUtility)
-
- def __init__(self):
- self.annotations = OOBTree()
-
- def getAnnotations(self, principal):
- """Return object implementing IAnnotations for the given principal.
-
- If there is no `IAnnotations` it will be created and then returned.
- """
- return self.getAnnotationsById(principal.id)
-
- def getAnnotationsById(self, principalId):
- """Return object implementing `IAnnotations` for the given principal.
-
- If there is no `IAnnotations` it will be created and then returned.
- """
- annotations = self.annotations.get(principalId)
- if annotations is None:
- annotations = Annotations(principalId, store=self.annotations)
- annotations.__parent__ = self
- annotations.__name__ = principalId
- return annotations
-
- def hasAnnotations(self, principal):
- """Return boolean indicating if given principal has `IAnnotations`."""
- return principal.id in self.annotations
-
-class Annotations(Persistent, Location):
- """Stores annotations."""
-
- interface.implements(IAnnotations)
-
- def __init__(self, principalId, store=None):
- self.principalId = principalId
- self.data = PersistentDict() # We don't really expect that many
-
- # _v_store is used to remember a mapping object that we should
- # be saved in if we ever change
- self._v_store = store
-
- def __nonzero__(self):
- nz = bool(self.data)
- if not nz:
- # maybe higher-level utility's annotations will be non-zero
- next = queryNextUtility(self, IPrincipalAnnotationUtility)
- if next is not None:
- annotations = next.getAnnotationsById(self.principalId)
- return bool(next)
- return nz
-
- def __getitem__(self, key):
- try:
- return self.data[key]
- except KeyError:
- # We failed locally: delegate to a higher-level utility.
- next = queryNextUtility(self, IPrincipalAnnotationUtility)
- if next is not None:
- annotations = next.getAnnotationsById(self.principalId)
- return annotations[key]
- raise
-
- def get(self, key, default=None):
- try:
- return self[key]
- except KeyError:
- return default
-
- def __setitem__(self, key, value):
- if getattr(self, '_v_store', None) is not None:
- # _v_store is used to remember a mapping object that we should
- # be saved in if we ever change
- self._v_store[self.principalId] = self
- del self._v_store
-
- self.data[key] = value
-
- def __delitem__(self, key):
- del self.data[key]
-
-
- at component.adapter(IPrincipal)
- at interface.implementer(IAnnotations)
-def annotations(principal, context=None):
- utility = component.getUtility(IPrincipalAnnotationUtility, context=context)
- return utility.getAnnotations(principal)
Copied: zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py (from rev 97697, zope.principalannotation/trunk/src/zope/principalannotation/utility.py)
===================================================================
--- zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py (rev 0)
+++ zope.principalannotation/tags/3.6.0/src/zope/principalannotation/utility.py 2009-03-09 15:02:19 UTC (rev 97698)
@@ -0,0 +1,125 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Implementation of IPrincipalAnnotationUtility
+
+$Id$
+"""
+__docformat__ = 'restructuredtext'
+from BTrees.OOBTree import OOBTree
+from persistent import Persistent
+from persistent.dict import PersistentDict
+from zope import interface, component
+from zope.annotation.interfaces import IAnnotations
+from zope.container.contained import Contained
+from zope.location import Location
+from zope.security.interfaces import IPrincipal
+from zope.site.next import queryNextUtility
+
+from zope.principalannotation.interfaces import IPrincipalAnnotationUtility
+
+# TODO: register utility as adapter for IAnnotations on utility activation.
+
+class PrincipalAnnotationUtility(Persistent, Contained):
+ """Stores `IAnnotations` for `IPrinicipals`.
+
+ The utility ID is 'PrincipalAnnotation'.
+ """
+
+ interface.implements(IPrincipalAnnotationUtility)
+
+ def __init__(self):
+ self.annotations = OOBTree()
+
+ def getAnnotations(self, principal):
+ """Return object implementing IAnnotations for the given principal.
+
+ If there is no `IAnnotations` it will be created and then returned.
+ """
+ return self.getAnnotationsById(principal.id)
+
+ def getAnnotationsById(self, principalId):
+ """Return object implementing `IAnnotations` for the given principal.
+
+ If there is no `IAnnotations` it will be created and then returned.
+ """
+ annotations = self.annotations.get(principalId)
+ if annotations is None:
+ annotations = Annotations(principalId, store=self.annotations)
+ annotations.__parent__ = self
+ annotations.__name__ = principalId
+ return annotations
+
+ def hasAnnotations(self, principal):
+ """Return boolean indicating if given principal has `IAnnotations`."""
+ return principal.id in self.annotations
+
+
+class Annotations(Persistent, Location):
+ """Stores annotations."""
+
+ interface.implements(IAnnotations)
+
+ def __init__(self, principalId, store=None):
+ self.principalId = principalId
+ self.data = PersistentDict() # We don't really expect that many
+
+ # _v_store is used to remember a mapping object that we should
+ # be saved in if we ever change
+ self._v_store = store
+
+ def __nonzero__(self):
+ nz = bool(self.data)
+ if not nz:
+ # maybe higher-level utility's annotations will be non-zero
+ next = queryNextUtility(self, IPrincipalAnnotationUtility)
+ if next is not None:
+ annotations = next.getAnnotationsById(self.principalId)
+ return bool(next)
+ return nz
+
+ def __getitem__(self, key):
+ try:
+ return self.data[key]
+ except KeyError:
+ # We failed locally: delegate to a higher-level utility.
+ next = queryNextUtility(self, IPrincipalAnnotationUtility)
+ if next is not None:
+ annotations = next.getAnnotationsById(self.principalId)
+ return annotations[key]
+ raise
+
+ def get(self, key, default=None):
+ try:
+ return self[key]
+ except KeyError:
+ return default
+
+ def __setitem__(self, key, value):
+ if getattr(self, '_v_store', None) is not None:
+ # _v_store is used to remember a mapping object that we should
+ # be saved in if we ever change
+ self._v_store[self.principalId] = self
+ del self._v_store
+
+ self.data[key] = value
+
+ def __delitem__(self, key):
+ del self.data[key]
+
+
+ at component.adapter(IPrincipal)
+ at interface.implementer(IAnnotations)
+def annotations(principal, context=None):
+ utility = component.getUtility(IPrincipalAnnotationUtility, context=context)
+ return utility.getAnnotations(principal)
More information about the Checkins
mailing list