[Checkins] SVN: zope.principalannotation/ Initial import.
Dan Korostelev
nadako at gmail.com
Mon Mar 9 10:09:35 EDT 2009
Log message for revision 97692:
Initial import.
Changed:
A zope.principalannotation/
A zope.principalannotation/trunk/
U zope.principalannotation/trunk/CHANGES.txt
U zope.principalannotation/trunk/README.txt
U zope.principalannotation/trunk/buildout.cfg
U zope.principalannotation/trunk/setup.py
D zope.principalannotation/trunk/src/zope/app/
A zope.principalannotation/trunk/src/zope/principalannotation/
U zope.principalannotation/trunk/src/zope/principalannotation/__init__.py
D zope.principalannotation/trunk/src/zope/principalannotation/bootstrap.py
D zope.principalannotation/trunk/src/zope/principalannotation/bootstrap.zcml
D zope.principalannotation/trunk/src/zope/principalannotation/browser.zcml
U zope.principalannotation/trunk/src/zope/principalannotation/configure.zcml
U zope.principalannotation/trunk/src/zope/principalannotation/interfaces.py
U zope.principalannotation/trunk/src/zope/principalannotation/tests.py
-=-
Property changes on: zope.principalannotation/trunk
___________________________________________________________________
Added: svn:ignore
+ bin
build
dist
lib
develop-eggs
eggs
parts
.installed.cfg
coverage
Modified: zope.principalannotation/trunk/CHANGES.txt
===================================================================
--- zope.app.principalannotation/trunk/CHANGES.txt 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/CHANGES.txt 2009-03-09 14:09:35 UTC (rev 97692)
@@ -2,29 +2,8 @@
CHANGES
=======
-3.5.2 (unreleased)
+3.6.0 (unreleased)
------------------
-- ...
-
-3.5.1 (2009-03-06)
-------------------
-
-- Make boostrap subscriber called on IDatabaseOpenedWithRootEvent
- instead of IDatabaseOpenedEvent, because this can cause bug if
- subscriber will be called before root object is created.
-
-- Use zope.site instead of zope.app.component.
-
-3.5.0 (2009-02-01)
-------------------
-
-- Move boostrap subscriber to bootstrap.zcml file and browser
- menu item definition to browser.zcml file to ease overriding
- and excluding configuration.
-- Use zope.container instead of zope.app.container.
-
-3.4.0 (2007-10-26)
-------------------
-
-- Initial release independent of the main Zope tree.
+Initial release. This package was splitted off zope.app.principalannotation
+to remove its dependencies on "zope 3 application server" components.
Modified: zope.principalannotation/trunk/README.txt
===================================================================
--- zope.app.principalannotation/trunk/README.txt 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/README.txt 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,3 +1,3 @@
-This package implements annotations for Zope security principals. Common
+This package implements annotations for zope.security principals. Common
annotation techniques, like AttributeAnnotations cannot be applied to
principals, since they are created on the fly for every request.
Modified: zope.principalannotation/trunk/buildout.cfg
===================================================================
--- zope.app.principalannotation/trunk/buildout.cfg 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/buildout.cfg 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,8 +1,18 @@
[buildout]
develop = .
-parts = test
+parts = test coverage-test coverage-report
[test]
recipe = zc.recipe.testrunner
-eggs = zope.app.principalannotation [test]
+eggs = zope.principalannotation [test]
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = zope.principalannotation [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Modified: zope.principalannotation/trunk/setup.py
===================================================================
--- zope.app.principalannotation/trunk/setup.py 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/setup.py 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006 Zope Corporation and Contributors.
+# Copyright (c) 2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Setup for zope.app.principalannotation package
+"""Setup for zope.principalannotation package
$Id$
"""
@@ -21,17 +21,17 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-setup(name='zope.app.principalannotation',
- version = '3.5.2dev',
+setup(name='zope.principalannotation',
+ version = '3.6.0dev',
author='Zope Corporation and Contributors',
author_email='zope-dev at zope.org',
description='Annotations for Zope Principals',
long_description=(
- read('README.txt')
+ read('src', 'zope', 'principalannotation', 'README.txt')
+ '\n\n' +
read('CHANGES.txt')
),
- keywords = "zope3 annotation principal publisher",
+ keywords = "zope security principal annotation",
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
@@ -42,22 +42,21 @@
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
- url='http://pypi.python.org/pypi/zope.app.principalannotation',
+ url='http://pypi.python.org/pypi/zope.principalannotation',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir = {'': 'src'},
- namespace_packages=['zope', 'zope.app'],
- extras_require = dict(test=['zope.app.testing']),
+ namespace_packages=['zope'],
+ extras_require = dict(test=['zope.testing', 'zope.site[test]']),
install_requires=['setuptools',
+ 'ZODB3',
'zope.annotation',
- 'zope.app.appsetup',
'zope.component',
'zope.container',
'zope.interface',
'zope.location',
'zope.security',
'zope.site',
- 'ZODB3',
],
include_package_data = True,
zip_safe = False,
Modified: zope.principalannotation/trunk/src/zope/principalannotation/__init__.py
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/__init__.py 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/__init__.py 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,142 +1 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation 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'
-
-# TODO: register utility as adapter for IAnnotations on utility activation.
-
-from persistent import Persistent
-from persistent.dict import PersistentDict
-from BTrees.OOBTree import OOBTree
-import zope.security.interfaces
-from zope import interface, component
-from zope.annotation.interfaces import IAnnotations
-from zope.container.contained import Contained
-from zope.location import Location
-from zope.site.next import queryNextUtility
-
-from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
-
-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 __getitem__(self, key):
- try:
- return self.data[key]
- except KeyError:
- # We failed locally: delegate to a higher-level utility.
- utility = queryNextUtility(self, IPrincipalAnnotationUtility)
- if utility is not None:
- annotations = utility.getAnnotationsById(self.principalId)
- return annotations[key]
- raise
-
- 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]
-
- def get(self, key, default=None):
- return self.data.get(key, default)
-
-def annotations(principal, context=None):
- """adapt principal to annotations via principal annotation utility.
-
- To illustrate, we'll register the adapter and a dummy
- principal annotation utility.
-
- >>> component.provideAdapter(annotations)
- >>> class DummyPrincipal(object):
- ... interface.implements(zope.security.interfaces.IPrincipal)
- ... def __init__(self, id, title=None, description=None):
- ... self.id = id
- ... self.title = title
- ... self.description = description
- ...
- >>> dummy_annotation = {}
- >>> class DummyPAU(object):
- ... interface.implements(interfaces.IPrincipalAnnotationUtility)
- ... def getAnnotations(self, principal):
- ... if principal.id == 'sue':
- ... return dummy_annotation
- ... raise NotImplementedError
- ...
- >>> pau = DummyPAU()
- >>> component.provideUtility(pau)
- >>> sue = DummyPrincipal('sue')
- >>> annotation = IAnnotations(sue)
- >>> annotation is dummy_annotation
- True
- """ # TODO move this out to a doctest file when we have one...
- utility = component.getUtility(IPrincipalAnnotationUtility, context=context)
- return utility.getAnnotations(principal)
-component.adapter(zope.security.interfaces.IPrincipal)(annotations)
-interface.implementer(IAnnotations)(annotations)
+# i'm a package
\ No newline at end of file
Deleted: zope.principalannotation/trunk/src/zope/principalannotation/bootstrap.py
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/bootstrap.py 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/bootstrap.py 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,39 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002, 2004 Zope Corporation 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.
-#
-##############################################################################
-"""Bootstrap code for principal annotation utility.
-
-$Id$
-"""
-
-import transaction
-
-from zope.app.appsetup.bootstrap import ensureUtility, getInformationFromEvent
-
-from zope.app.principalannotation import PrincipalAnnotationUtility
-from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
-
-def bootStrapSubscriber(event):
- """Subscriber to the IDatabaseOpenedWithRootEvent
-
- Create utility at that time if not yet present
- """
-
- db, connection, root, root_folder = getInformationFromEvent(event)
-
- ensureUtility(root_folder, IPrincipalAnnotationUtility,
- 'PrincipalAnnotation', PrincipalAnnotationUtility,
- asObject=True)
-
- transaction.commit()
- connection.close()
Deleted: zope.principalannotation/trunk/src/zope/principalannotation/bootstrap.zcml
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/bootstrap.zcml 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/bootstrap.zcml 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,11 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- >
-
- <subscriber
- for="zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent"
- handler=".bootstrap.bootStrapSubscriber"
- />
-
-</configure>
Deleted: zope.principalannotation/trunk/src/zope/principalannotation/browser.zcml
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/browser.zcml 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/browser.zcml 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,13 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- >
-
- <browser:addMenuItem
- class=".PrincipalAnnotationUtility"
- permission="zope.ManageServices"
- title="Principal Annotation Utility"
- description="Stores Annotations for Principals"
- />
-
-</configure>
Modified: zope.principalannotation/trunk/src/zope/principalannotation/configure.zcml
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/configure.zcml 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/configure.zcml 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,12 +1,7 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- >
+<configure xmlns="http://namespaces.zope.org/zope">
- <class class=".PrincipalAnnotationUtility">
- <factory
- id="zope.app.PrincipalAnnotationUtility"
- />
+ <class class=".utility.PrincipalAnnotationUtility">
+ <factory id="zope.app.PrincipalAnnotationUtility" />
<implements
interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
@@ -16,14 +11,11 @@
/>
</class>
- <adapter factory=".annotations" />
+ <adapter factory=".utility.annotations" />
<adapter
for="zope.security.interfaces.IPrincipal *"
- factory=".annotations"
+ factory=".utility.annotations"
/>
- <include file="bootstrap.zcml" />
- <include file="browser.zcml" />
-
</configure>
Modified: zope.principalannotation/trunk/src/zope/principalannotation/interfaces.py
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/interfaces.py 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/interfaces.py 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
Modified: zope.principalannotation/trunk/src/zope/principalannotation/tests.py
===================================================================
--- zope.app.principalannotation/trunk/src/zope/app/principalannotation/tests.py 2009-03-09 11:06:06 UTC (rev 97689)
+++ zope.principalannotation/trunk/src/zope/principalannotation/tests.py 2009-03-09 14:09:35 UTC (rev 97692)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -15,18 +15,46 @@
$Id$
"""
+import unittest
+from zope.component import provideAdapter
from zope.testing import doctest
+from zope.interface import Interface
+from zope.security.interfaces import IPrincipal
+from zope.site.testing import siteSetUp, siteTearDown
+
+from zope.principalannotation.utility import annotations
+
+def setUp(test):
+ site = siteSetUp(site=True)
+ test.globs['root'] = site
+ provideAdapter(annotations)
+ provideAdapter(annotations, (IPrincipal, Interface))
+
+def tearDown(test):
+ siteTearDown()
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.ELLIPSIS)
+ ))
+
+
+'''
from unittest import TestCase, TestLoader, TextTestRunner
import zope.component
from zope.interface import implements
from zope.security.interfaces import IPrincipal
-from zope.app.principalannotation import PrincipalAnnotationUtility
from zope.app.component.testing import PlacefulSetup
from zope.app.testing import setup
-from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
+from zope.principalannotation.interfaces import IPrincipalAnnotationUtility
+from zope.principalannotation.utility import PrincipalAnnotationUtility
+
class Principal(object):
implements(IPrincipal)
@@ -83,11 +111,12 @@
def test_suite():
loader=TestLoader()
tests = loader.loadTestsFromTestCase(PrincipalAnnotationTests)
- import zope.app.principalannotation
- tests.addTest(doctest.DocTestSuite(zope.app.principalannotation,
+ import zope.principalannotation.utility
+ tests.addTest(doctest.DocTestSuite(zope.principalannotation.utility,
setUp=setup.placelessSetUp,
tearDown=setup.placelessTearDown))
return tests
if __name__=='__main__':
TextTestRunner().run(test_suite())
+'''
\ No newline at end of file
More information about the Checkins
mailing list