[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/groupscontainer/ Renamed GroupsFolder/groupsfolder to GroupFolder/groupfolder

Jim Fulton jim at zope.com
Tue Oct 19 18:25:49 EDT 2004


Log message for revision 28220:
  Renamed GroupsFolder/groupsfolder to GroupFolder/groupfolder
  

Changed:
  U   Zope3/trunk/src/zope/app/groupscontainer/configure.zcml
  U   Zope3/trunk/src/zope/app/groupscontainer/group.py
  A   Zope3/trunk/src/zope/app/groupscontainer/groupfolder.py
  A   Zope3/trunk/src/zope/app/groupscontainer/groupfolder.txt
  U   Zope3/trunk/src/zope/app/groupscontainer/groups_principals.txt
  D   Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.py
  D   Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.txt
  U   Zope3/trunk/src/zope/app/groupscontainer/interfaces.py
  U   Zope3/trunk/src/zope/app/groupscontainer/tests.py

-=-
Modified: Zope3/trunk/src/zope/app/groupscontainer/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/configure.zcml	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/configure.zcml	2004-10-19 22:25:48 UTC (rev 28220)
@@ -41,14 +41,14 @@
     />
   
 <browser:tool
-    interface=".interfaces.IGroupsFolder"
+    interface=".interfaces.IGroupFolder"
     title="Groups Folder"
     description="Groups Folder"
     />
 
-<localUtility class=".groupsfolder.GroupsFolder">
+<localUtility class=".groupfolder.GroupFolder">
   <implements
-      interface=".interfaces.IGroupsFolder" />
+      interface=".interfaces.IGroupFolder" />
   <implements
       interface="zope.app.annotation.IAttributeAnnotatable" />
   <require
@@ -59,12 +59,12 @@
 <browser:addMenuItem
     title="Groups Folder"
     description="A Groups folder"
-    class=".groupsfolder.GroupsFolder"
+    class=".groupfolder.GroupFolder"
     permission="zope.ManageServices"
     />
       
 <browser:containerViews
-     for=".interfaces.IGroupsFolder"
+     for=".interfaces.IGroupFolder"
      contents="zope.ManageContent"
      index="zope.View"
      add="zope.ManageContent"

Modified: Zope3/trunk/src/zope/app/groupscontainer/group.py
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/group.py	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/group.py	2004-10-19 22:25:48 UTC (rev 28220)
@@ -21,7 +21,7 @@
 from zope.app.pas.interfaces import IAuthenticatedPrincipalCreated
 from persistent import Persistent
 from zope.interface import implements, alsoProvides
-from zope.app.groupscontainer.interfaces import IGroupContained, IGroupsFolder
+from zope.app.groupscontainer.interfaces import IGroupContained, IGroupFolder
 from zope.security.interfaces import IGroupAwarePrincipal
 from types import StringTypes
 import zope.app.zapi
@@ -76,7 +76,7 @@
     principal = event.principal
     alsoProvides(principal, IGroupAwarePrincipal)
     principal.groups = []
-    groupfolders = zope.app.zapi.getUtilitiesFor(IGroupsFolder)
+    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/groupscontainer/groupfolder.py (from rev 28212, Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.py)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.py	2004-10-18 20:01:20 UTC (rev 28212)
+++ Zope3/trunk/src/zope/app/groupscontainer/groupfolder.py	2004-10-19 22:25:48 UTC (rev 28220)
@@ -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.groupscontainer.interfaces import IGroupSearchCriteria
+from zope.app.groupscontainer.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/groupscontainer/groupfolder.txt (from rev 28219, Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.txt)
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.txt	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/groupfolder.txt	2004-10-19 22:25:48 UTC (rev 28220)
@@ -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.groupscontainer.group import Group
+  >>> from zope.app.groupscontainer.interfaces import IGroupContained
+  >>> from zope.app.groupscontainer.interfaces import IGroupFolder
+  >>> from zope.app.groupscontainer.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()
+  []
+    

Modified: Zope3/trunk/src/zope/app/groupscontainer/groups_principals.txt
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groups_principals.txt	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/groups_principals.txt	2004-10-19 22:25:48 UTC (rev 28220)
@@ -5,15 +5,15 @@
 
   >>> from zope.app.groupscontainer.group import Group
   >>> from zope.security.interfaces import IGroupAwarePrincipal
-  >>> from zope.app.groupscontainer.groupsfolder import GroupsFolder
-  >>> from zope.app.groupscontainer.interfaces import IGroupsFolder
+  >>> from zope.app.groupscontainer.groupfolder import GroupFolder
+  >>> from zope.app.groupscontainer.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(IGroupsFolder))[0]
+  >>> 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', 

Deleted: Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.py
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.py	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.py	2004-10-19 22:25:48 UTC (rev 28220)
@@ -1,124 +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 implementation
-
-$Id: groupsfolder.py 27237 2004-10-12 09:33:00 mriya3 $
-
-"""
-
-from zope.app.groupscontainer.interfaces import IGroupsFolder, IGroupSearchCriteria
-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 GroupsFolder(BTreeContainer):
-
-    implements(IGroupsFolder, 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}
-        
-        
-            

Deleted: Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.txt
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.txt	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/groupsfolder.txt	2004-10-19 22:25:48 UTC (rev 28220)
@@ -1,152 +0,0 @@
-Groups Folder Implementation
-============================
-
-The GroupsFolder 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 GroupsFolder; 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.groupscontainer.group import Group
-  >>> from zope.app.groupscontainer.interfaces import IGroupContained
-  >>> from zope.app.groupscontainer.interfaces import IGroupsFolder
-  >>> from zope.app.groupscontainer.groupsfolder import GroupsFolder
-  >>> 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 = GroupsFolder()
-  >>> 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()
-  []
-    

Modified: Zope3/trunk/src/zope/app/groupscontainer/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/interfaces.py	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/interfaces.py	2004-10-19 22:25:48 UTC (rev 28220)
@@ -22,7 +22,7 @@
 from zope.schema import Field, TextLine
 from zope.interface import Interface
 
-class IGroupsFolder(IContainer):
+class IGroupFolder(IContainer):
        
     def getGroupsForPrincipal(principalid):
         """Get groups the given principal belongs to"""
@@ -37,7 +37,7 @@
 
 class IGroupContained(IContained):
     __parent__ = Field(
-             constraint = ContainerTypesConstraint(IGroupsFolder))
+             constraint = ContainerTypesConstraint(IGroupFolder))
              
 
 class IGroupSearchCriteria(Interface):

Modified: Zope3/trunk/src/zope/app/groupscontainer/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/groupscontainer/tests.py	2004-10-19 22:06:15 UTC (rev 28219)
+++ Zope3/trunk/src/zope/app/groupscontainer/tests.py	2004-10-19 22:25:48 UTC (rev 28220)
@@ -26,7 +26,7 @@
 from zope.app.form.interfaces import IInputWidget
 
 import zope.app.groupscontainer.group
-import zope.app.groupscontainer.groupsfolder
+import zope.app.groupscontainer.groupfolder
 import zope.app.groupscontainer.interfaces
 import zope.app.pas.interfaces
 
@@ -41,13 +41,13 @@
     ztapi.subscribe([zope.app.pas.interfaces.IAuthenticatedPrincipalCreated],
                     None,
                     zope.app.groupscontainer.group.setGroupsForPrincipal)
-    groups = zope.app.groupscontainer.groupsfolder.GroupsFolder()
-    ztapi.provideUtility(zope.app.groupscontainer.interfaces.IGroupsFolder,
+    groups = zope.app.groupscontainer.groupfolder.GroupFolder()
+    ztapi.provideUtility(zope.app.groupscontainer.interfaces.IGroupFolder,
                          groups)
 
 def test_suite():
     return unittest.TestSuite((
-        doctest.DocFileSuite('groupsfolder.txt',
+        doctest.DocFileSuite('groupfolder.txt',
                              setUp=setUp, tearDown=placelesssetup.tearDown),
         doctest.DocFileSuite('groups_principals.txt',
                              setUp=setUpGP, tearDown=placelesssetup.tearDown),



More information about the Zope3-Checkins mailing list