[Zope3-checkins] SVN: Zope3/trunk/ Renamed groupscontainer ro
groupfolder.
Jim Fulton
jim at zope.com
Tue Oct 19 18:52:08 EDT 2004
Log message for revision 28221:
Renamed groupscontainer ro groupfolder.
Changed:
U Zope3/trunk/package-includes/groupscontainer-configure.zcml
A Zope3/trunk/src/zope/app/groupfolder/
D Zope3/trunk/src/zope/app/groupfolder/configure.zcml
A Zope3/trunk/src/zope/app/groupfolder/configure.zcml
A Zope3/trunk/src/zope/app/groupfolder/group.py
A Zope3/trunk/src/zope/app/groupfolder/groupfolder.py
A Zope3/trunk/src/zope/app/groupfolder/groupfolder.txt
A Zope3/trunk/src/zope/app/groupfolder/groups_principals.txt
D Zope3/trunk/src/zope/app/groupfolder/interfaces.py
A Zope3/trunk/src/zope/app/groupfolder/interfaces.py
D Zope3/trunk/src/zope/app/groupfolder/tests.py
A Zope3/trunk/src/zope/app/groupfolder/tests.py
D Zope3/trunk/src/zope/app/groupscontainer/
-=-
Modified: Zope3/trunk/package-includes/groupscontainer-configure.zcml
===================================================================
--- Zope3/trunk/package-includes/groupscontainer-configure.zcml 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/package-includes/groupscontainer-configure.zcml 2004-10-19 22:52:08 UTC (rev 28221)
@@ -1 +1 @@
-<include package="zope.app.groupscontainer"/>
+<include package="zope.app.groupfolder"/>
Copied: Zope3/trunk/src/zope/app/groupfolder (from rev 28212, Zope3/trunk/src/zope/app/groupscontainer)
Deleted: Zope3/trunk/src/zope/app/groupfolder/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/configure.zcml 2004-10-18 20:01:20 UTC (rev 28212)
+++ Zope3/trunk/src/zope/app/groupfolder/configure.zcml 2004-10-19 22:52:08 UTC (rev 28221)
@@ -1,48 +0,0 @@
-<configure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:browser='http://namespaces.zope.org/browser'
- i18n_domain="groupscontainer"
- xmlns:i18n="http://namespaces.zope.org/i18n"
- >
-
- <browser:tool
- interface=".interfaces.IGroupsFolder"
- title="Groups Folder"
- description="Groups Folder"
- />
-
- <localUtility class=".groupsfolder.GroupsFolder">
- <implements
- interface=".interfaces.IGroupsFolder" />
- <implements
- interface="zope.app.annotation.IAttributeAnnotatable" />
- <require
- permission="zope.ManageServices"
- interface="zope.app.container.interfaces.IContainer" />
- </localUtility>
-
- <browser:addMenuItem
- title="Groups Folder"
- description="A Groups folder"
- class=".groupsfolder.GroupsFolder"
- permission="zope.ManageServices"
- />
-
-<browser:containerViews
- for=".interfaces.IGroupsFolder"
- contents="zope.ManageContent"
- index="zope.View"
- add="zope.ManageContent"
- />
-
-</configure>
-
-
-
-
-
-
-
-
-
-
Copied: Zope3/trunk/src/zope/app/groupfolder/configure.zcml (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/configure.zcml)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/configure.zcml 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/src/zope/app/groupfolder/configure.zcml 2004-10-19 22:52:08 UTC (rev 28221)
@@ -0,0 +1,83 @@
+<configure
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:browser='http://namespaces.zope.org/browser'
+ i18n_domain="zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ >
+
+<content class=".group.Group">
+ <require
+ permission="zope.ManageContent"
+ interface=".interfaces.IGroup"
+ set_schema=".interfaces.IGroup"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.groupfolder.interfaces.IGroupContained"
+ />
+ <implements
+ interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ />
+</content>
+
+<browser:addMenuItem
+ title="Group"
+ description="A principals group"
+ class=".group.Group"
+ permission="zope.ManageServices"
+ />
+
+<browser:editform
+ schema=".interfaces.IGroup"
+ label="Change group information"
+ name="edit.html"
+ menu="zmi_views" title="Edit"
+ permission="zope.ManageContent"
+ />
+
+<subscriber
+ factory="zope.app.groupfolder.group.setGroupsForPrincipal"
+ for="zope.app.pas.interfaces.IAuthenticatedPrincipalCreated"
+ />
+
+<browser:tool
+ interface=".interfaces.IGroupFolder"
+ title="Groups Folder"
+ description="Groups Folder"
+ />
+
+<localUtility class=".groupfolder.GroupFolder">
+ <implements
+ interface=".interfaces.IGroupFolder" />
+ <implements
+ interface="zope.app.annotation.IAttributeAnnotatable" />
+ <require
+ permission="zope.ManageServices"
+ interface="zope.app.container.interfaces.IContainer" />
+</localUtility>
+
+<browser:addMenuItem
+ title="Groups Folder"
+ description="A Groups folder"
+ class=".groupfolder.GroupFolder"
+ permission="zope.ManageServices"
+ />
+
+<browser:containerViews
+ for=".interfaces.IGroupFolder"
+ contents="zope.ManageContent"
+ index="zope.View"
+ add="zope.ManageContent"
+ />
+
+</configure>
+
+
+
+
+
+
+
+
+
+
Copied: Zope3/trunk/src/zope/app/groupfolder/group.py (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/group.py)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/group.py 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/src/zope/app/groupfolder/group.py 2004-10-19 22:52:08 UTC (rev 28221)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Zope Group implementation
+
+$Id: group.py 27237 2004-10-12 09:33:00 mriya3 $
+
+"""
+
+from zope.security.interfaces import IGroup
+from zope.app.pas.interfaces import IAuthenticatedPrincipalCreated
+from persistent import Persistent
+from zope.interface import implements, alsoProvides
+from zope.app.groupfolder.interfaces import IGroupContained, IGroupFolder
+from zope.security.interfaces import IGroupAwarePrincipal
+from types import StringTypes
+import zope.app.zapi
+from zope.event import notify
+
+
+class Group(Persistent):
+
+ implements(IGroup, IGroupContained)
+
+ __parent__ = __name__ = None
+
+ def __init__(self, id='', title='', description='', principalsids=[]):
+ self.id = id
+ self.title = title
+ self.description = description
+ self.__principals = principalsids
+
+ def addPrincipals(self, *principalIds):
+ tmpNewList = self.__principals
+ for principalId in principalIds:
+ if not principalId in self.__principals:
+ tmpNewList.append(principalId)
+ self.setPrincipals(tmpNewList)
+ if self.__parent__ is not None:
+ self.__parent__.updateMappingForPrincipals(*principalIds)
+
+ def removePrincipals(self, *principalIds):
+ tmpNewList = self.__principals
+ for principalId in principalIds:
+ if principalId in tmpNewList:
+ tmpNewList.remove(principalId)
+ self.setPrincipals(tmpNewList)
+ if self.__parent__ is not None:
+ self.__parent__.updateMappingForPrincipals(*principalIds)
+
+ def containsPrincipal(self, principalId):
+ return principalId in self.__principals
+
+ def getPrincipals(self):
+ return self.__principals
+
+ def setPrincipals(self, prinlist):
+ origprincipals = self.__principals
+ self.__principals = prinlist
+
+ principals = property(getPrincipals, setPrincipals)
+
+
+def setGroupsForPrincipal(event):
+ """Set group information when a principal is created"""
+ principal = event.principal
+ alsoProvides(principal, IGroupAwarePrincipal)
+ principal.groups = []
+ groupfolders = zope.app.zapi.getUtilitiesFor(IGroupFolder)
+ for name, groupfolder in groupfolders:
+ groups = groupfolder.getGroupsForPrincipal(principal.id)
+ principal.groups.extend(groups)
Copied: Zope3/trunk/src/zope/app/groupfolder/groupfolder.py (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/groupfolder.py)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groupfolder.py 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/src/zope/app/groupfolder/groupfolder.py 2004-10-19 22:52:08 UTC (rev 28221)
@@ -0,0 +1,125 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Zope Groups Folder implementation
+
+$Id: groupfolder.py 27237 2004-10-12 09:33:00 mriya3 $
+
+"""
+
+from zope.app.groupfolder.interfaces import IGroupSearchCriteria
+from zope.app.groupfolder.interfaces import IGroupFolder
+from zope.app.pas.interfaces import IQuerySchemaSearch
+from zope.app.container.btree import BTreeContainer
+from zope.interface import implements
+from BTrees.OOBTree import OOBTree
+import zope.schema
+
+
+
+class GroupFolder(BTreeContainer):
+
+ implements(IGroupFolder, IQuerySchemaSearch)
+ schema = (IGroupSearchCriteria)
+
+ def __init__(self):
+ super(BTreeContainer,self).__init__()
+ # __inversemapping is used to map principals to groups
+ self.__inverseMapping = OOBTree()
+
+ def __delitem__(self, name):
+ """Removes a group and updates the inverse mapping"""
+ for principal in self.__inverseMapping.keys():
+ groupListForPrincipal = self.__inverseMapping[principal]
+ if name in groupListForPrincipal:
+ groupListForPrincipal.remove(name)
+ # Clean up
+ for principal in self.__inverseMapping.keys():
+ groupListForPrincipal = self.__inverseMapping[principal]
+ if len(groupListForPrincipal) == 0:
+ del self.__inverseMapping[principal]
+ super(BTreeContainer,self).__delitem__(name)
+
+ def __setitem__(self, name, object):
+ """Adds a new group and updates the inverse mapping"""
+ super(BTreeContainer,self).__setitem__(name, object)
+ principalsInGroup = object.principals
+ for principal in principalsInGroup:
+ if self.__inverseMapping.has_key(principal):
+ self.__inverseMapping[principal].append(name)
+ else:
+ self.__inverseMapping[principal] = [name]
+
+ def getGroupsForPrincipal(self, principalid):
+ """Get groups the given principal belongs to"""
+ if self.__inverseMapping.has_key(principalid):
+ return self.__inverseMapping[principalid]
+ else:
+ return []
+
+
+ def getPrincipalsForGroup(self, groupid):
+ """Get principals which belong to the group"""
+ if groupid in self.keys():
+ return self.__getitem__(groupid).principals
+ else:
+ return []
+
+ def removePrincipalFromAllGroups(self, principalId):
+ """Removes a principal from all the groups"""
+ groupsItIsIn = self.getGroupsForPrincipal(principalId)
+ for groupid in groupsItIsIn:
+ self.__getitem__(groupid).removePrincipals(principalId)
+
+ def getAllMappedPrincipals(self):
+ """Returns all mapped principals"""
+ return list(self.__inverseMapping.keys())
+
+ def updateMappingForPrincipals(self, *principalsIds):
+ for principalId in principalsIds:
+ self.updateMappingForPrincipal(principalId)
+
+ def updateMappingForPrincipal(self, principalId):
+ """Updates inverse mapping for principalId -> group"""
+ tmpNewGroupList = []
+ # Search in all groups and add to inverse mapping if the principalId is in
+ for groupid in self.keys():
+ if self.__getitem__(groupid).containsPrincipal(principalId):
+ tmpNewGroupList.append(groupid)
+ # If the principal disappears from all groups just remove it
+ if len(tmpNewGroupList) == 0:
+ del self.__inverseMapping[principalId]
+ else:
+ self.__inverseMapping[principalId] = tmpNewGroupList
+
+ def search(self, query, start=None, batch_size=None):
+ """ Search for groups"""
+ search = query.get('search')
+ if search is not None:
+ i = 0
+ n = 0
+ for value in self.keys():
+ if search in value:
+ if not ((start is not None and i < start)
+ or
+ (batch_size is not None and n > batch_size)):
+ n += 1
+ yield value
+ i += 1
+
+ def principalInfo(self, id):
+ if id in self:
+ return {'title': self[id].title, 'description': self[id].description}
+
+
+
Copied: Zope3/trunk/src/zope/app/groupfolder/groupfolder.txt (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/groupfolder.txt)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groupfolder.txt 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/src/zope/app/groupfolder/groupfolder.txt 2004-10-19 22:52:08 UTC (rev 28221)
@@ -0,0 +1,152 @@
+Groups Folder Implementation
+============================
+
+The GroupFolder class offers a groups container that mantains maps
+between groups and principals as well as maps from principals to
+groups.
+
+We test that we can add a Group to a GroupFolder; we also check that
+it is possible to retrieve principals from a given group id and,
+vice-versa, get a list of groups a principal belongs to by providing
+its id.
+
+ >>> import zope.interface
+ >>> from zope.security.interfaces import IGroupAwarePrincipal, IGroup
+ >>> from zope.app.groupfolder.group import Group
+ >>> from zope.app.groupfolder.interfaces import IGroupContained
+ >>> from zope.app.groupfolder.interfaces import IGroupFolder
+ >>> from zope.app.groupfolder.groupfolder import GroupFolder
+ >>> from zope.interface import implements
+ >>> class GoldrakePrincipal:
+ ... implements(IGroupAwarePrincipal)
+ ... id = '0'
+ ... title = 'Goldrake'
+ ... description = 'Ufo robot'
+ ... groups = ['superheroes', 'robots']
+ >>> class MazingaPrincipal:
+ ... implements(IGroupAwarePrincipal)
+ ... id = '1'
+ ... title = 'Mazinga'
+ ... description = 'Mazinga Z'
+ ... groups = ['superheroes', 'robots']
+ >>> class CaptainAmericaPrincipal:
+ ... implements(IGroupAwarePrincipal)
+ ... id = '2'
+ ... title = 'CaptainAmerica'
+ ... description = 'Captain America'
+ ... groups = ['superheroes']
+
+Then we create instances of our fake principal classes:
+
+ >>> goldrake = GoldrakePrincipal()
+ >>> mazinga = MazingaPrincipal()
+ >>> captainamerica = CaptainAmericaPrincipal()
+ >>> superheroesgroup = Group(id='superheroes', title='Superheroes group',
+ ... description='The best superheroes',
+ ... principalsids=['0', '1', '2'])
+ >>> robotsgroup = Group(id='robots', title='Robots group',
+ ... description='The best robots',
+ ... principalsids=['0', '1'])
+
+A groups folder contains groups:
+
+ >>> notordinarypeople = GroupFolder()
+ >>> notordinarypeople[superheroesgroup.id] = superheroesgroup
+ >>> notordinarypeople[robotsgroup.id] = robotsgroup
+
+We test that 'getGroupsForPrincipal' returns the groups the provided
+principal id belongs to:
+
+ >>> notordinarypeople.getGroupsForPrincipal('1')
+ ['superheroes', 'robots']
+ >>> notordinarypeople.getGroupsForPrincipal('2')
+ ['superheroes']
+ >>> notordinarypeople.getGroupsForPrincipal('99')
+ []
+
+The 'getPrincipalsForGroup' returns the principals id contained in a group:
+
+ >>> notordinarypeople.getPrincipalsForGroup('superheroes')
+ ['0', '1', '2']
+ >>> notordinarypeople.getPrincipalsForGroup('users')
+ []
+
+We also test removing a group:
+
+ >>> del notordinarypeople['superheroes']
+ >>> print list(notordinarypeople.keys())
+ [u'robots']
+ >>> notordinarypeople.getGroupsForPrincipal('1')
+ ['robots']
+ >>> mazinga.groups
+ ['superheroes', 'robots']
+ >>> notordinarypeople.getGroupsForPrincipal('2')
+ []
+ >>> captainamerica.groups
+ ['superheroes']
+
+Now we test the search capabilities, as in IQuerySchemaSearch example:
+
+We're trying to search groups in the notordinarypeople class, so first
+we get a view:
+
+ >>> import zope.schema
+ >>> from zope.app.pas.browser.schemasearch import QuerySchemaSearchView
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+ >>> view = QuerySchemaSearchView(notordinarypeople, request)
+
+This allows us to render a search form.
+
+ >>> print view.render('test') # doctest: +NORMALIZE_WHITESPACE
+ <div class="row">
+ <div class="label">
+ <label for="test.field.search" title="">
+ Group Search String
+ </label>
+ </div>
+ <div class="field">
+ <input class="textType" id="test.field.search"
+ name="test.field.search"
+ size="20" type="text" value=""
+ />
+ </div>
+ </div>
+ <br /><input type="submit" name="test.search" value="Search" />
+
+If we ask for results:
+
+ >>> view.results('test')
+
+We don't get any, since we did not provide any. But if we give input:
+
+ >>> request.form['test.field.search'] = 'bo'
+
+we still don't get any:
+
+ >>> view.results('test')
+
+because we did not press the button. So let's press the button:
+
+ >>> request.form['test.search'] = 'Search'
+
+so that we now get results (!):
+
+ >>> list(view.results('test'))
+ [u'robots']
+ >>> request.form['test.field.search'] = 'eek'
+
+We can also remove a principal from all the groups:
+
+ >>> notordinarypeople.removePrincipalFromAllGroups('1')
+ >>> notordinarypeople.getGroupsForPrincipal('1')
+ []
+ >>> notordinarypeople.getAllMappedPrincipals()
+ ['0']
+
+If we remove the last group there will be no principal mapped anymore:
+
+ >>> del notordinarypeople['robots']
+ >>> notordinarypeople.getAllMappedPrincipals()
+ []
+
Copied: Zope3/trunk/src/zope/app/groupfolder/groups_principals.txt (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/groups_principals.txt)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groups_principals.txt 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/src/zope/app/groupfolder/groups_principals.txt 2004-10-19 22:52:08 UTC (rev 28221)
@@ -0,0 +1,54 @@
+Groups & Principals
+===================
+
+We import the needed modules
+
+ >>> from zope.app.groupfolder.group import Group
+ >>> from zope.security.interfaces import IGroupAwarePrincipal
+ >>> from zope.app.groupfolder.groupfolder import GroupFolder
+ >>> from zope.app.groupfolder.interfaces import IGroupFolder
+ >>> from zope.app.pas.principalplugins import PrincipalFactory
+ >>> from zope.publisher.tests.httprequest import TestRequest
+ >>> import zope.app.zapi
+
+We first create a group folder and add some groups:
+
+ >>> name, groups = list(zope.app.zapi.getUtilitiesFor(IGroupFolder))[0]
+ >>> geeks = Group(id='geeks', principalsids=['srichter','jim'])
+ >>> newbies = Group(id='newbies', principalsids=['amos','claudia'])
+ >>> sprinters = Group(id='sprinters',
+ ... principalsids=['srichter', 'jim', 'amos','claudia'])
+ >>> for g in [geeks, sprinters, newbies]: groups[g.id] = g
+
+Now we create some principals and check if they operate correctly:
+
+1) Instantiate a Principal Factory
+
+ >>> pf = PrincipalFactory()
+
+2) Get some principals
+
+ >>> srichter = pf.createAuthenticatedPrincipal('srichter', {} ,
+ ... TestRequest())
+ >>> IGroupAwarePrincipal.providedBy(srichter)
+ True
+ >>> groups.getGroupsForPrincipal(srichter.id)
+ ['geeks', 'sprinters']
+ >>> thomas = pf.createAuthenticatedPrincipal('thomas', {} , TestRequest())
+ >>> groups.getGroupsForPrincipal(thomas.id)
+ []
+ >>> amos = pf.createAuthenticatedPrincipal('amos', {} , TestRequest())
+ >>> groups.getGroupsForPrincipal(amos.id)
+ ['sprinters', 'newbies']
+
+3) Now we add a group and check that getGroupsForPrincipal gets updated but
+ principal group info gets NOT updated:
+
+ >>> thinkers = Group(id='thinkers',
+ ... principalsids=['srichter', 'jim', 'thomas','robert'])
+ >>> groups[thinkers.id] = thinkers
+ >>> groups.getGroupsForPrincipal(srichter.id)
+ ['geeks', 'sprinters', 'thinkers']
+ >>> srichter.groups
+ ['geeks', 'sprinters']
+
Deleted: Zope3/trunk/src/zope/app/groupfolder/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/interfaces.py 2004-10-18 20:01:20 UTC (rev 28212)
+++ Zope3/trunk/src/zope/app/groupfolder/interfaces.py 2004-10-19 22:52:08 UTC (rev 28221)
@@ -1,45 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Zope Groups Folder Interface"""
-
-# $Id: interfaces.py 27237 2004-10-12 09:33:00 mriya3 $
-
-from zope.app.container.interfaces import IContained, IContainer
-from zope.app.container.constraints import ContainerTypesConstraint
-from zope.app.container.constraints import ItemTypePrecondition
-from zope.security.interfaces import IGroup
-from zope.schema import Field, TextLine
-from zope.interface import Interface
-
-class IGroupsFolder(IContainer):
-
- def getGroupsForPrincipal(principalid):
- """Get groups the given principal belongs to"""
-
- def getPrincipalsForGroup(groupid):
- """Get principals which belong to the group"""
-
- def __setitem__(name, object):
- """Adds a Group to the GroupFolder"""
-
- __setitem__.precondition = ItemTypePrecondition(IGroup)
-
-class IGroupContained(IContained):
- __parent__ = Field(
- constraint = ContainerTypesConstraint(IGroupsFolder))
-
-
-class IGroupSearchCriteria(Interface):
- search = TextLine(title=u"Group Search String")
-
Copied: Zope3/trunk/src/zope/app/groupfolder/interfaces.py (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/interfaces.py)
Deleted: Zope3/trunk/src/zope/app/groupfolder/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/tests.py 2004-10-18 20:01:20 UTC (rev 28212)
+++ Zope3/trunk/src/zope/app/groupfolder/tests.py 2004-10-19 22:52:08 UTC (rev 28221)
@@ -1,60 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Groups folder tests.
-
-$Id: tests.py 27237 2004-10-12 10:49:00 mriya3 $
-"""
-
-__docformat__ = "reStructuredText"
-import unittest
-from zope.testing import doctest
-from zope.schema.interfaces import ITextLine
-from zope.app.tests import placelesssetup
-from zope.app.tests import ztapi
-from zope.app.form.browser import TextWidget
-from zope.app.form.interfaces import IInputWidget
-
-def setUp(test):
- placelesssetup.setUp()
- ztapi.browserView(ITextLine, '', TextWidget, providing=IInputWidget)
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite('groupsfolder.txt',
- setUp=setUp, tearDown=placelesssetup.tearDown),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
-
-
-
-
-
-
-
-
-
-"""
-
-import unittest
-from zope.testing.doctest import DocFileSuite
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(DocFileSuite('groupsfolder.txt'))
- return suite
-
-
-"""
Copied: Zope3/trunk/src/zope/app/groupfolder/tests.py (from rev 28220, Zope3/trunk/src/zope/app/groupscontainer/tests.py)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/tests.py 2004-10-19 22:25:48 UTC (rev 28220)
+++ Zope3/trunk/src/zope/app/groupfolder/tests.py 2004-10-19 22:52:08 UTC (rev 28221)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+"""Groups folder tests.
+
+$Id: tests.py 27237 2004-10-12 10:49:00 mriya3 $
+"""
+
+__docformat__ = "reStructuredText"
+import unittest
+from zope.testing import doctest
+from zope.schema.interfaces import ITextLine
+from zope.app.tests import placelesssetup
+from zope.app.tests import ztapi
+from zope.app.form.browser import TextWidget
+from zope.app.form.interfaces import IInputWidget
+
+import zope.app.groupfolder.group
+import zope.app.groupfolder.groupfolder
+import zope.app.groupfolder.interfaces
+import zope.app.pas.interfaces
+
+
+
+def setUp(test):
+ placelesssetup.setUp()
+ ztapi.browserView(ITextLine, '', TextWidget, providing=IInputWidget)
+
+def setUpGP(test):
+ placelesssetup.setUp(test)
+ ztapi.subscribe([zope.app.pas.interfaces.IAuthenticatedPrincipalCreated],
+ None,
+ zope.app.groupfolder.group.setGroupsForPrincipal)
+ groups = zope.app.groupfolder.groupfolder.GroupFolder()
+ ztapi.provideUtility(zope.app.groupfolder.interfaces.IGroupFolder,
+ groups)
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite('groupfolder.txt',
+ setUp=setUp, tearDown=placelesssetup.tearDown),
+ doctest.DocFileSuite('groups_principals.txt',
+ setUp=setUpGP, tearDown=placelesssetup.tearDown),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+
More information about the Zope3-Checkins
mailing list