[Checkins] SVN: z3ext.ownership/tags/1.1.0/ release tag
Nikolay Kim
fafhrd at datacom.kz
Mon Jan 26 21:13:32 EST 2009
Log message for revision 95062:
release tag
Changed:
A z3ext.ownership/tags/1.1.0/
D z3ext.ownership/tags/1.1.0/CHANGES.txt
A z3ext.ownership/tags/1.1.0/CHANGES.txt
U z3ext.ownership/tags/1.1.0/setup.py
D z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt
A z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt
D z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml
A z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml
D z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py
A z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py
D z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py
A z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py
D z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py
A z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py
-=-
Deleted: z3ext.ownership/tags/1.1.0/CHANGES.txt
===================================================================
--- z3ext.ownership/trunk/CHANGES.txt 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/CHANGES.txt 2009-01-27 02:13:32 UTC (rev 95062)
@@ -1,26 +0,0 @@
-=======
-CHANGES
-=======
-
-1.0.1 (2008-05-19)
-------------------
-
-- Replace 'autoinclude' with 'includeDependendcies'
-
-
-1.0.0 (2008-03-21)
-------------------
-
-- Moved to svn.zope.org
-
-
-0.99 (2008-03-19)
------------------
-
-- Code cleanup
-
-
-0.9.0 (2008-02-01)
-------------------
-
-- Initial release
Copied: z3ext.ownership/tags/1.1.0/CHANGES.txt (from rev 95061, z3ext.ownership/trunk/CHANGES.txt)
===================================================================
--- z3ext.ownership/tags/1.1.0/CHANGES.txt (rev 0)
+++ z3ext.ownership/tags/1.1.0/CHANGES.txt 2009-01-27 02:13:32 UTC (rev 95062)
@@ -0,0 +1,32 @@
+=======
+CHANGES
+=======
+
+1.1.0 (2009-01-27)
+------------------
+
+- Added special IOwnership adapter for IInheritOwnership objects
+
+
+1.0.1 (2008-05-19)
+------------------
+
+- Replace 'autoinclude' with 'includeDependendcies'
+
+
+1.0.0 (2008-03-21)
+------------------
+
+- Moved to svn.zope.org
+
+
+0.99 (2008-03-19)
+-----------------
+
+- Code cleanup
+
+
+0.9.0 (2008-02-01)
+------------------
+
+- Initial release
Modified: z3ext.ownership/tags/1.1.0/setup.py
===================================================================
--- z3ext.ownership/trunk/setup.py 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/setup.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -21,7 +21,7 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-version='1.0.3dev'
+version='1.1.0'
setup(name = 'z3ext.ownership',
Deleted: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt
===================================================================
--- z3ext.ownership/trunk/src/z3ext/ownership/README.txt 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt 2009-01-27 02:13:32 UTC (rev 95062)
@@ -1,155 +0,0 @@
-=================
-Content ownership
-=================
-
-This package implement single ownership concept. Content owner has special
-role on content `content.Owner`.
-
-We need setup security interaction and principals
-
- >>> from zope import interface, component, event
- >>> import zope.security.management
- >>> from z3ext.ownership import tests
- >>> from z3ext.ownership.interfaces import IOwnership
- >>> from z3ext.ownership.interfaces import IOwnerAware, IOwnerGroupAware
-
- >>> from zope.app.security.interfaces import IAuthentication
-
- >>> principal1 = tests.Principal('bob')
- >>> principal2 = tests.Principal('meg')
-
- >>> class Auth(object):
- ... interface.implements(IAuthentication)
- ...
- ... def getPrincipal(self, id):
- ... if id == 'bob':
- ... return principal1
- ... if id == 'meg':
- ... return principal2
-
- >>> auth = Auth()
- >>> component.provideUtility(auth)
-
- >>> participation = tests.Participation()
- >>> participation.principal = principal1
- >>> zope.security.management.endInteraction()
- >>> zope.security.management.newInteraction(participation)
- >>> interaction = zope.security.management.getInteraction()
-
- >>> from zope.lifecycleevent import ObjectCreatedEvent
- >>> from zope.annotation.interfaces import IAttributeAnnotatable
-
- >>> class IMyObject(IOwnerAware):
- ... pass
-
- >>> class Content:
- ... __parent__ = None
- ... interface.implements(IAttributeAnnotatable, IMyObject)
-
- >>> content = Content()
- >>> event.notify(ObjectCreatedEvent(content))
-
- >>> owner = IOwnership(content)
-
- >>> owner.owner
- <Principal 'bob'>
-
- >>> owner.ownerId
- 'bob'
-
-Now let's check owner roles
-
- >>> from z3ext.security.interfaces import IExtendedGrantInfo
-
- >>> grantinfo = IExtendedGrantInfo(content)
- >>> grantinfo.getPrincipalsForRole('content.Owner')
- [('bob', PermissionSetting: Allow)]
-
- >>> grantinfo.getRolesForPrincipal('bob')
- [('content.Owner', PermissionSetting: Allow)]
-
- >>> grantinfo.getRolesForPrincipal('meg')
- [('content.Owner', PermissionSetting: Deny)]
-
-We can change owner
-
- >>> owner.owner = principal2
-
- >>> owner = IOwnership(content)
-
- >>> owner.owner
- <Principal 'meg'>
-
- >>> owner.ownerId
- 'meg'
-
-Change ownerId
-
- >>> owner.ownerId = 'bob'
-
- >>> owner = IOwnership(content)
- >>> owner.owner
- <Principal 'bob'>
-
- >>> owner.owner = principal2
-
- >>> grantinfo = IExtendedGrantInfo(content)
- >>> grantinfo.getRolesForPrincipal('meg')
- [('content.Owner', PermissionSetting: Allow)]
-
- >>> grantinfo.getRolesForPrincipal('bob')
- [('content.Owner', PermissionSetting: Deny)]
-
- >>> grantinfo.getPrincipalsForRole('unknown.Role')
- []
-
-content.Owner and content.GroupOwner are disabled for principal bob
-so ownership is not inherited from parents. But we can change this, we should
-explicitly set marker interface for content
-
- >>> from z3ext.ownership.interfaces import IInheritOwnership
- >>> interface.directlyProvides(content, IInheritOwnership)
-
- >>> grantinfo = IExtendedGrantInfo(content)
- >>> grantinfo.getRolesForPrincipal('bob')
- []
-
-
-We can assign only IPrincipal object
-
- >>> owner.owner = object()
- Traceback (most recent call last):
- ...
- ValueError: IPrincipal object is required.
-
-
-Group owner
-
- >>> from zope.security.interfaces import IGroup
- >>> interface.directlyProvides(principal1, IGroup)
-
- >>> owner = IOwnership(content)
- >>> owner.owner = principal1
-
- >>> owner = IOwnership(content)
- >>> owner.isGroup
- True
-
- >>> interface.directlyProvides(content, IOwnerGroupAware)
-
- >>> grantinfo = IExtendedGrantInfo(content)
- >>> grantinfo.getRolesForPrincipal('bob')
- [('content.GroupOwner', PermissionSetting: Allow)]
-
- >>> grantinfo.getPrincipalsForRole('content.GroupOwner')
- [('bob', PermissionSetting: Allow)]
-
- >>> grantinfo.getPrincipalsForRole('unknown.Role')
- []
-
- >>> grantinfo.getRolesForPrincipal('meg')
- [('content.GroupOwner', PermissionSetting: Deny)]
-
- >>> interface.alsoProvides(content, IInheritOwnership)
- >>> grantinfo.getRolesForPrincipal('meg')
- []
Copied: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt (from rev 95061, z3ext.ownership/trunk/src/z3ext/ownership/README.txt)
===================================================================
--- z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt (rev 0)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/README.txt 2009-01-27 02:13:32 UTC (rev 95062)
@@ -0,0 +1,253 @@
+=================
+Content ownership
+=================
+
+This package implement single ownership concept. Content owner has special
+role on content `content.Owner`.
+
+We need setup security interaction and principals
+
+ >>> from zope import interface, component, event
+ >>> import zope.security.management
+ >>> from z3ext.ownership import tests, interfaces
+ >>> from z3ext.ownership.interfaces import IOwnership
+ >>> from z3ext.ownership.interfaces import IOwnerAware, IOwnerGroupAware
+
+ >>> from zope.app.security.interfaces import IAuthentication
+
+ >>> principal1 = tests.Principal('bob')
+ >>> principal2 = tests.Principal('meg')
+
+ >>> class Auth(object):
+ ... interface.implements(IAuthentication)
+ ...
+ ... def getPrincipal(self, id):
+ ... if id == 'bob':
+ ... return principal1
+ ... if id == 'meg':
+ ... return principal2
+
+ >>> auth = Auth()
+ >>> component.provideUtility(auth)
+
+ >>> participation = tests.Participation()
+ >>> participation.principal = principal1
+ >>> zope.security.management.endInteraction()
+ >>> zope.security.management.newInteraction(participation)
+ >>> interaction = zope.security.management.getInteraction()
+
+ >>> from zope.location import Location
+ >>> from zope.lifecycleevent import ObjectCreatedEvent
+ >>> from zope.annotation.interfaces import IAttributeAnnotatable
+
+ >>> class IMyObject(IOwnerAware):
+ ... pass
+
+ >>> class Content(Location):
+ ... interface.implements(IAttributeAnnotatable, IMyObject)
+ ...
+ ... def __init__(self, parent=None):
+ ... self.__parent__ = parent
+
+ >>> content = Content()
+ >>> event.notify(ObjectCreatedEvent(content))
+
+ >>> owner = IOwnership(content)
+
+ >>> owner.owner
+ <Principal 'bob'>
+
+ >>> owner.ownerId
+ 'bob'
+
+Now let's check owner roles
+
+ >>> from z3ext.security.interfaces import IExtendedGrantInfo
+
+ >>> grantinfo = IExtendedGrantInfo(content)
+ >>> grantinfo.getPrincipalsForRole('content.Owner')
+ [('bob', PermissionSetting: Allow)]
+
+ >>> grantinfo.getRolesForPrincipal('bob')
+ [('content.Owner', PermissionSetting: Allow)]
+
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Deny)]
+
+We can change owner
+
+ >>> owner.owner = principal2
+
+ >>> owner = IOwnership(content)
+
+ >>> owner.owner
+ <Principal 'meg'>
+
+ >>> owner.ownerId
+ 'meg'
+
+Change ownerId
+
+ >>> owner.ownerId = 'bob'
+
+ >>> owner = IOwnership(content)
+ >>> owner.owner
+ <Principal 'bob'>
+
+ >>> owner.owner = principal2
+
+ >>> grantinfo = IExtendedGrantInfo(content)
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Allow)]
+
+ >>> grantinfo.getRolesForPrincipal('bob')
+ [('content.Owner', PermissionSetting: Deny)]
+
+ >>> grantinfo.getPrincipalsForRole('unknown.Role')
+ []
+
+content.Owner and content.GroupOwner are disabled for principal bob
+so ownership is not inherited from parents. But we can change this, we should
+explicitly set marker interface for content
+
+ >>> from z3ext.ownership.interfaces import IInheritOwnership
+ >>> interface.directlyProvides(content, IInheritOwnership)
+
+ >>> grantinfo = IExtendedGrantInfo(content)
+ >>> grantinfo.getRolesForPrincipal('bob')
+ []
+
+ >>> interface.noLongerProvides(content, IInheritOwnership)
+
+
+We can assign only IPrincipal object
+
+ >>> owner.owner = object()
+ Traceback (most recent call last):
+ ...
+ ValueError: IPrincipal object is required.
+
+
+Chain owner
+-----------
+
+let's create content chain, content -> content1 -> content2
+
+ >>> content1 = Content(content)
+ >>> content2 = Content(content1)
+
+ >>> grantinfo = IExtendedGrantInfo(content1)
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Deny)]
+ >>> grantinfo.getRolesForPrincipal('bob')
+ [('content.Owner', PermissionSetting: Deny)]
+
+now mark content1 as IInheritOwnership
+
+ >>> interface.directlyProvides(content1, IInheritOwnership)
+
+ >>> grantinfo = IExtendedGrantInfo(content1)
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Allow)]
+
+ >>> ownership = IOwnership(content1)
+ >>> ownership.ownerId
+ 'meg'
+
+ >>> interfaces.IUnchangeableOwnership.providedBy(ownership)
+ True
+
+ >>> ownership.ownerId = 'bob'
+ Traceback (most recent call last):
+ ...
+ AttributeError: can't set attribute
+
+content2
+
+ >>> grantinfo = IExtendedGrantInfo(content2)
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Deny)]
+
+ >>> interface.directlyProvides(content2, IInheritOwnership)
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Allow)]
+
+ >>> IOwnership(content2).ownerId
+ 'meg'
+ >>> IOwnership(content2).owner
+ <Principal 'meg'>
+
+ >>> IOwnership(content).ownerId = 'bob'
+ >>> IOwnership(content1).ownerId
+ 'bob'
+ >>> IOwnership(content2).ownerId
+ 'bob'
+
+ >>> IExtendedGrantInfo(content1).getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Deny)]
+ >>> IExtendedGrantInfo(content1).getRolesForPrincipal('bob')
+ [('content.Owner', PermissionSetting: Allow)]
+ >>> IExtendedGrantInfo(content2).getRolesForPrincipal('meg')
+ [('content.Owner', PermissionSetting: Deny)]
+ >>> IExtendedGrantInfo(content2).getRolesForPrincipal('bob')
+ [('content.Owner', PermissionSetting: Allow)]
+
+We need IOwnerAware parent for IInheritOwnership objects
+
+ >>> content4 = Content()
+ >>> interface.directlyProvides(content4, IInheritOwnership)
+ >>> IOwnership(content4)
+ Traceback (most recent call last):
+ ...
+ ComponentLookupError
+
+just tests
+
+ >>> from zope.securitypolicy.interfaces import IPrincipalRoleMap
+ >>> map = component.getAdapter(content, IPrincipalRoleMap, 'z3ext.ownership-owner')
+ >>> map.getRolesForPrincipal('bob')
+ (('content.Owner', PermissionSetting: Allow),)
+ >>> map.getSetting('content.Owner', 'bob')
+ PermissionSetting: Allow
+ >>> map.getSetting('content.Owner', 'meg')
+ PermissionSetting: Deny
+
+
+Group owner
+-----------
+
+ >>> from zope.security.interfaces import IGroup
+ >>> interface.directlyProvides(principal1, IGroup)
+
+ >>> owner = IOwnership(content)
+ >>> owner.owner = principal1
+
+ >>> owner = IOwnership(content)
+ >>> owner.isGroup
+ True
+
+ >>> interface.directlyProvides(content, IOwnerGroupAware)
+
+ >>> grantinfo = IExtendedGrantInfo(content)
+ >>> grantinfo.getRolesForPrincipal('bob')
+ [('content.GroupOwner', PermissionSetting: Allow)]
+
+ >>> grantinfo.getPrincipalsForRole('content.GroupOwner')
+ [('bob', PermissionSetting: Allow)]
+
+ >>> grantinfo.getPrincipalsForRole('unknown.Role')
+ []
+
+ >>> grantinfo.getRolesForPrincipal('meg')
+ [('content.GroupOwner', PermissionSetting: Deny)]
+
+
+just tests
+
+ >>> map = component.getAdapter(content, IPrincipalRoleMap, 'z3ext.ownership-groupowner')
+ >>> map.getRolesForPrincipal('bob')
+ (('content.GroupOwner', PermissionSetting: Allow),)
+ >>> map.getSetting('content.GroupOwner', 'bob')
+ PermissionSetting: Allow
+ >>> map.getSetting('content.GroupOwner', 'meg')
+ PermissionSetting: Deny
Deleted: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml
===================================================================
--- z3ext.ownership/trunk/src/z3ext/ownership/configure.zcml 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml 2009-01-27 02:13:32 UTC (rev 95062)
@@ -1,43 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="z3ext">
-
- <includeDependencies package="z3ext.ownership" />
-
- <role
- id="content.Owner"
- title="Content owner" />
-
- <role
- id="content.GroupOwner"
- title="Content group owner" />
-
- <permission
- id="z3ext.changeOwnership"
- title="Change ownership"
- description="Change object ownership." />
-
- <adapter factory=".owner.Ownership" />
-
- <class class=".owner.Ownership">
- <require
- permission="zope.View"
- interface=".interfaces.IOwnership" />
- <require
- permission="z3ext.changeOwnership"
- set_schema=".interfaces.IOwnership" />
- </class>
-
- <adapter factory=".principalgroups.principalGroups" />
-
- <adapter
- name="z3ext.ownership-owner"
- factory=".localroles.getLocalRoles" />
-
- <adapter
- name="z3ext.ownership-groupowner"
- factory=".localroles.getGroupLocalRoles" />
-
- <subscriber handler=".owner.initObjectOwnership" />
-
-</configure>
Copied: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml (from rev 95061, z3ext.ownership/trunk/src/z3ext/ownership/configure.zcml)
===================================================================
--- z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml (rev 0)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/configure.zcml 2009-01-27 02:13:32 UTC (rev 95062)
@@ -0,0 +1,47 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="z3ext.ownership">
+
+ <includeDependencies package="z3ext.ownership" />
+
+ <role
+ id="content.Owner"
+ title="Content owner" />
+
+ <role
+ id="content.GroupOwner"
+ title="Content group owner" />
+
+ <permission
+ id="z3ext.changeOwnership"
+ title="Change ownership"
+ description="Change object ownership." />
+
+ <adapter factory=".owner.Ownership" />
+
+ <adapter
+ provides=".interfaces.IOwnership"
+ factory=".owner.InheritedOwnership" />
+
+ <class class=".owner.Ownership">
+ <require
+ permission="zope.View"
+ interface=".interfaces.IOwnership" />
+ <require
+ permission="z3ext.changeOwnership"
+ set_schema=".interfaces.IOwnership" />
+ </class>
+
+ <adapter factory=".principalgroups.principalGroups" />
+
+ <adapter
+ name="z3ext.ownership-owner"
+ factory=".localroles.getLocalRoles" />
+
+ <adapter
+ name="z3ext.ownership-groupowner"
+ factory=".localroles.getGroupLocalRoles" />
+
+ <subscriber handler=".owner.initObjectOwnership" />
+
+</configure>
Deleted: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py
===================================================================
--- z3ext.ownership/trunk/src/z3ext/ownership/localroles.py 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -1,111 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from zope import interface, component
-from zope.app.security.settings import Allow, Unset, Deny
-from zope.securitypolicy.interfaces import IPrincipalRoleMap
-
-from interfaces import \
- IOwnership, IInheritOwnership, IOwnerAware, IOwnerGroupAware
-
-
- at component.adapter(IOwnerAware)
- at interface.implementer(IPrincipalRoleMap)
-def getLocalRoles(context):
- owner = IOwnership(context)
- if owner.isGroup and IOwnerGroupAware.providedBy(context):
- return
- return LocalRoles(context, owner)
-
-class LocalRoles(object):
- interface.implements(IPrincipalRoleMap)
-
- def __init__(self, context, owner):
- self.owner = owner
- self.ownerId = owner.ownerId
- self.inherit = IInheritOwnership.providedBy(context)
-
- def getPrincipalsForRole(self, role_id):
- if (role_id == 'content.Owner'):
- return ((self.ownerId, Allow),)
- else:
- return ()
-
- def getRolesForPrincipal(self, principal_id,
- deny = (('content.Owner', Deny),),
- allow = (('content.Owner', Allow),)):
- if principal_id == self.ownerId:
- return allow
- elif self.inherit:
- return ()
- else:
- return deny
-
- def getSetting(self, role_id, principal_id):
- if (principal_id == self.ownerId) and (role_id == 'content.Owner'):
- return Allow
- if self.inherit:
- return Unset
- else:
- return Deny
-
- def getPrincipalsAndRoles(self):
- return ()
-
-
- at component.adapter(IOwnerGroupAware)
- at interface.implementer(IPrincipalRoleMap)
-def getGroupLocalRoles(context):
- owner = IOwnership(context)
- if owner.isGroup:
- return GroupLocalRoles(context, owner)
-
-class GroupLocalRoles(object):
- interface.implements(IPrincipalRoleMap)
-
- def __init__(self, context, owner):
- self.owner = owner
- self.ownerId = owner.ownerId
- self.inherit = IInheritOwnership.providedBy(context)
-
- def getPrincipalsForRole(self, role_id):
- if role_id == 'content.GroupOwner':
- return ((self.ownerId, Allow),)
- else:
- return ()
-
- def getRolesForPrincipal(self, principal_id,
- deny = (('content.GroupOwner', Deny),),
- allow = (('content.GroupOwner', Allow),)):
- if principal_id == self.ownerId:
- return allow
- elif self.inherit:
- return ()
- else:
- return deny
-
- def getSetting(self, role_id, principal_id):
- if (principal_id == self.ownerId) and (role_id == 'content.GroupOwner'):
- return Allow
-
- if self.inherit:
- return Unset
- else:
- return Deny
-
- def getPrincipalsAndRoles(self):
- return ()
Copied: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py (from rev 95061, z3ext.ownership/trunk/src/z3ext/ownership/localroles.py)
===================================================================
--- z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py (rev 0)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/localroles.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -0,0 +1,108 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope import interface, component
+from zope.app.security.settings import Allow, Unset, Deny
+from zope.securitypolicy.interfaces import IPrincipalRoleMap
+
+from interfaces import \
+ IOwnership, IInheritOwnership, IOwnerAware, IOwnerGroupAware
+
+
+ at component.adapter(IOwnerAware)
+ at interface.implementer(IPrincipalRoleMap)
+def getLocalRoles(context):
+ if IInheritOwnership.providedBy(context):
+ return
+
+ owner = IOwnership(context)
+ if owner.isGroup and IOwnerGroupAware.providedBy(context):
+ return
+ return LocalRoles(context, owner)
+
+
+class LocalRoles(object):
+ interface.implements(IPrincipalRoleMap)
+
+ def __init__(self, context, owner):
+ self.owner = owner
+ self.ownerId = owner.ownerId
+
+ def getPrincipalsForRole(self, role_id):
+ if (role_id == 'content.Owner'):
+ return ((self.ownerId, Allow),)
+ else:
+ return ()
+
+ def getRolesForPrincipal(self, principal_id,
+ deny = (('content.Owner', Deny),),
+ allow = (('content.Owner', Allow),)):
+ if principal_id == self.ownerId:
+ return allow
+ else:
+ return deny
+
+ def getSetting(self, role_id, principal_id):
+ if (principal_id == self.ownerId) and (role_id == 'content.Owner'):
+ return Allow
+ else:
+ return Deny
+
+ def getPrincipalsAndRoles(self):
+ return ()
+
+
+ at component.adapter(IOwnerGroupAware)
+ at interface.implementer(IPrincipalRoleMap)
+def getGroupLocalRoles(context):
+ if IInheritOwnership.providedBy(context):
+ return
+
+ owner = IOwnership(context)
+ if owner.isGroup:
+ return GroupLocalRoles(context, owner)
+
+
+class GroupLocalRoles(object):
+ interface.implements(IPrincipalRoleMap)
+
+ def __init__(self, context, owner):
+ self.owner = owner
+ self.ownerId = owner.ownerId
+
+ def getPrincipalsForRole(self, role_id):
+ if role_id == 'content.GroupOwner':
+ return ((self.ownerId, Allow),)
+ else:
+ return ()
+
+ def getRolesForPrincipal(self, principal_id,
+ deny = (('content.GroupOwner', Deny),),
+ allow = (('content.GroupOwner', Allow),)):
+ if principal_id == self.ownerId:
+ return allow
+ else:
+ return deny
+
+ def getSetting(self, role_id, principal_id):
+ if (principal_id == self.ownerId) and (role_id == 'content.GroupOwner'):
+ return Allow
+ else:
+ return Deny
+
+ def getPrincipalsAndRoles(self):
+ return ()
Deleted: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py
===================================================================
--- z3ext.ownership/trunk/src/z3ext/ownership/owner.py 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -1,97 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-from rwproperty import getproperty, setproperty
-
-from zope import event, interface, component
-from zope.annotation.interfaces import IAnnotations
-from zope.lifecycleevent.interfaces import IObjectCreatedEvent
-
-from zope.security.proxy import removeSecurityProxy
-from zope.security.interfaces import IPrincipal, IGroup
-
-from z3ext.security.utils import getPrincipal
-
-from z3ext.ownership import interfaces
-from z3ext.ownership.interfaces import IInheritOwnership
-from z3ext.ownership.interfaces import IUnchangeableOwnership
-from z3ext.ownership.interfaces import OwnerChangedEvent
-
-ANNOTATION_KEY = 'z3ext.ownership.Owner'
-
-
-class Ownership(object):
- component.adapts(interfaces.IOwnerAware)
- interface.implements(interfaces.IOwnership)
-
- _ownerId = ''
- isGroup = False
-
- def __init__(self, context):
- annotations = IAnnotations(removeSecurityProxy(context))
-
- self.context = context
- self.annotations = annotations
-
- ownerinfo = annotations.get(ANNOTATION_KEY)
- if ownerinfo is None:
- ownerinfo = {'ownerId': None, 'isGroup': False}
- annotations[ANNOTATION_KEY] = ownerinfo
-
- self._ownerId = ownerinfo['ownerId']
- self.isGroup = ownerinfo['isGroup']
-
- @setproperty
- def owner(self, owner):
- if IPrincipal.providedBy(owner):
- oldOwner = self.owner
-
- self._ownerId = owner.id
- self.isGroup = IGroup.providedBy(owner)
-
- self.annotations[ANNOTATION_KEY] = {'ownerId': self._ownerId,
- 'isGroup': self.isGroup}
-
- event.notify(OwnerChangedEvent(self.context, owner, oldOwner))
- else:
- raise ValueError('IPrincipal object is required.')
-
- @getproperty
- def owner(self):
- if self._ownerId:
- return getPrincipal(self._ownerId)
- else:
- return None
-
- @getproperty
- def ownerId(self):
- return self._ownerId
-
- @setproperty
- def ownerId(self, pid):
- self.owner = getPrincipal(pid)
-
-
- at component.adapter(interfaces.IOwnerAware, IObjectCreatedEvent)
-def initObjectOwnership(object, event):
- if interfaces.IUnchangeableOwnership.providedBy(object) or \
- interfaces.IInheritOwnership.providedBy(object):
- return
-
- principal = getPrincipal()
- if principal is not None:
- interfaces.IOwnership(removeSecurityProxy(object)).owner = principal
Copied: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py (from rev 95061, z3ext.ownership/trunk/src/z3ext/ownership/owner.py)
===================================================================
--- z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py (rev 0)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/owner.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -0,0 +1,122 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from rwproperty import getproperty, setproperty
+
+from zope import event, interface, component
+from zope.annotation.interfaces import IAnnotations
+from zope.component.interfaces import ComponentLookupError
+from zope.lifecycleevent.interfaces import IObjectCreatedEvent
+
+from zope.security.proxy import removeSecurityProxy
+from zope.security.interfaces import IPrincipal, IGroup
+
+from z3ext.security.utils import getPrincipal
+
+from z3ext.ownership import interfaces
+from z3ext.ownership.interfaces import IOwnership
+from z3ext.ownership.interfaces import IInheritOwnership
+from z3ext.ownership.interfaces import IUnchangeableOwnership
+from z3ext.ownership.interfaces import OwnerChangedEvent
+
+ANNOTATION_KEY = 'z3ext.ownership.Owner'
+
+
+class Ownership(object):
+ component.adapts(interfaces.IOwnerAware)
+ interface.implements(IOwnership)
+
+ _ownerId = ''
+ isGroup = False
+
+ def __init__(self, context):
+ annotations = IAnnotations(removeSecurityProxy(context))
+
+ self.context = context
+ self.annotations = annotations
+
+ ownerinfo = annotations.get(ANNOTATION_KEY)
+ if ownerinfo is None:
+ ownerinfo = {'ownerId': None, 'isGroup': False}
+ annotations[ANNOTATION_KEY] = ownerinfo
+
+ self._ownerId = ownerinfo['ownerId']
+ self.isGroup = ownerinfo['isGroup']
+
+ @setproperty
+ def owner(self, owner):
+ if IPrincipal.providedBy(owner):
+ oldOwner = self.owner
+
+ self._ownerId = owner.id
+ self.isGroup = IGroup.providedBy(owner)
+
+ self.annotations[ANNOTATION_KEY] = {'ownerId': self._ownerId,
+ 'isGroup': self.isGroup}
+
+ event.notify(OwnerChangedEvent(self.context, owner, oldOwner))
+ else:
+ raise ValueError('IPrincipal object is required.')
+
+ @getproperty
+ def owner(self):
+ if self._ownerId:
+ return getPrincipal(self._ownerId)
+ else:
+ return None
+
+ @getproperty
+ def ownerId(self):
+ return self._ownerId
+
+ @setproperty
+ def ownerId(self, pid):
+ self.owner = getPrincipal(pid)
+
+
+class InheritedOwnership(object):
+ component.adapts(interfaces.IInheritOwnership)
+ interface.implements(IOwnership, IUnchangeableOwnership)
+
+ def __init__(self, context):
+ parent = context
+
+ while IInheritOwnership.providedBy(parent):
+ parent = getattr(parent, '__parent__', None)
+ if parent is None:
+ raise ComponentLookupError()
+
+ self._owner = IOwnership(parent)
+
+ @property
+ def owner(self):
+ return self._owner.owner
+
+ @property
+ def ownerId(self):
+ return self._owner.ownerId
+
+
+ at component.adapter(interfaces.IOwnerAware, IObjectCreatedEvent)
+def initObjectOwnership(object, event):
+ if interfaces.IUnchangeableOwnership.providedBy(object) or \
+ interfaces.IInheritOwnership.providedBy(object):
+ return
+
+ principal = getPrincipal()
+ if principal is not None:
+ interfaces.IOwnership(removeSecurityProxy(object)).owner = principal
Deleted: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py
===================================================================
--- z3ext.ownership/trunk/src/z3ext/ownership/tests.py 2009-01-27 01:05:48 UTC (rev 95060)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -1,66 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 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.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-import unittest, doctest
-from zope import interface, component
-from zope.app.testing import placelesssetup
-from zope.annotation.attribute import AttributeAnnotations
-
-import zope.security.management
-from zope.security.interfaces import IPrincipal
-from z3ext.security import tests as sectests
-from z3ext.security.securitypolicy import SecurityPolicy
-
-from z3ext.ownership.owner import Ownership, initObjectOwnership
-from z3ext.ownership.localroles import getLocalRoles, getGroupLocalRoles
-
-
-class Principal:
- interface.implements(IPrincipal)
-
- def __init__(self, id):
- self.id = id
- self.title = id
- self.groups = []
-
- def __repr__(self):
- return "<Principal '%s'>"%self.id
-
-class Participation:
- interaction = None
-
-
-def setUp(test):
- #placelesssetup.setUp(test)
- sectests.setUp(test)
- zope.security.management.setSecurityPolicy(SecurityPolicy)
-
- sm = component.getSiteManager()
- sm.registerAdapter(Ownership)
- sm.registerAdapter(getLocalRoles, name="z3ext.ownership-owner")
- sm.registerAdapter(getGroupLocalRoles, name="z3ext.ownership-group")
- sm.registerAdapter(AttributeAnnotations)
- sm.registerHandler(initObjectOwnership)
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite(
- 'README.txt',
- setUp=setUp, tearDown=placelesssetup.tearDown,
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
- ))
Copied: z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py (from rev 95061, z3ext.ownership/trunk/src/z3ext/ownership/tests.py)
===================================================================
--- z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py (rev 0)
+++ z3ext.ownership/tags/1.1.0/src/z3ext/ownership/tests.py 2009-01-27 02:13:32 UTC (rev 95062)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+import unittest, doctest
+from zope import interface, component
+from zope.app.testing import placelesssetup
+from zope.annotation.attribute import AttributeAnnotations
+
+import zope.security.management
+from zope.security.interfaces import IPrincipal
+from z3ext.security import tests as sectests
+from z3ext.security.securitypolicy import SecurityPolicy
+
+from z3ext.ownership.owner import initObjectOwnership
+from z3ext.ownership.owner import Ownership, InheritedOwnership
+from z3ext.ownership.localroles import getLocalRoles, getGroupLocalRoles
+from z3ext.ownership.interfaces import IOwnership, IInheritOwnership
+
+
+class Principal:
+ interface.implements(IPrincipal)
+
+ def __init__(self, id):
+ self.id = id
+ self.title = id
+ self.groups = []
+
+ def __repr__(self):
+ return "<Principal '%s'>"%self.id
+
+class Participation:
+ interaction = None
+
+
+def setUp(test):
+ sectests.setUp(test)
+ zope.security.management.setSecurityPolicy(SecurityPolicy)
+
+ sm = component.getSiteManager()
+ sm.registerAdapter(Ownership)
+ sm.registerAdapter(InheritedOwnership, (IInheritOwnership,), IOwnership)
+ sm.registerAdapter(getLocalRoles, name="z3ext.ownership-owner")
+ sm.registerAdapter(getGroupLocalRoles, name="z3ext.ownership-groupowner")
+ sm.registerAdapter(AttributeAnnotations)
+ sm.registerHandler(initObjectOwnership)
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp, tearDown=placelesssetup.tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+ ))
More information about the Checkins
mailing list