[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/pau/ Changed the group search field definition to accept an empty string,

Jim Fulton jim at zope.com
Thu Dec 23 16:59:10 EST 2004


Log message for revision 28698:
  Changed the group search field definition to accept an empty string,
  which causes all groups to be returned.
  

Changed:
  U   Zope3/trunk/src/zope/app/pau/browser/ftests.py
  A   Zope3/trunk/src/zope/app/pau/browser/group_searching_with_empty_string.txt
  U   Zope3/trunk/src/zope/app/pau/groupfolder.py

-=-
Modified: Zope3/trunk/src/zope/app/pau/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/pau/browser/ftests.py	2004-12-23 21:44:30 UTC (rev 28697)
+++ Zope3/trunk/src/zope/app/pau/browser/ftests.py	2004-12-23 21:59:10 UTC (rev 28698)
@@ -22,6 +22,8 @@
     return unittest.TestSuite((
         functional.FunctionalDocFileSuite('principalfolder.txt'),
         functional.FunctionalDocFileSuite('groupfolder.txt'),
+        functional.FunctionalDocFileSuite(
+            'group_searching_with_empty_string.txt'),
         ))
 
 if __name__ == '__main__':

Added: Zope3/trunk/src/zope/app/pau/browser/group_searching_with_empty_string.txt
===================================================================
--- Zope3/trunk/src/zope/app/pau/browser/group_searching_with_empty_string.txt	2004-12-23 21:44:30 UTC (rev 28697)
+++ Zope3/trunk/src/zope/app/pau/browser/group_searching_with_empty_string.txt	2004-12-23 21:59:10 UTC (rev 28698)
@@ -0,0 +1,198 @@
+We can search group folder with an empty string.
+
+We'll add a  pluggable authentication utility:
+
+  >>> print http(r"""
+  ... POST /++etc++site/default/@@contents.html HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 60
+  ... Content-Type: application/x-www-form-urlencoded
+  ... Referer: http://localhost:8081/++etc++site/default/@@contents.html?type_name=BrowserAdd__zope.app.pau.pau.LocalPAU
+  ... 
+  ... type_name=BrowserAdd__zope.app.pau.pau.LocalPAU&new_value=PA""")
+  HTTP/1.1 303 See Other
+  ...
+
+And register it:
+
+  >>> print http(r"""
+  ... POST /++etc++site/default/PA/addRegistration.html HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 852
+  ... Content-Type: multipart/form-data; boundary=---------------------------8474411127918531132143183931
+  ... Referer: http://localhost:8081/++etc++site/default/PA/addRegistration.html
+  ... 
+  ... -----------------------------8474411127918531132143183931
+  ... Content-Disposition: form-data; name="field.name"
+  ... 
+  ... 
+  ... -----------------------------8474411127918531132143183931
+  ... Content-Disposition: form-data; name="field.interface"
+  ... 
+  ... zope.app.security.interfaces.IAuthenticationUtility
+  ... -----------------------------8474411127918531132143183931
+  ... Content-Disposition: form-data; name="field.interface-empty-marker"
+  ... 
+  ... 1
+  ... -----------------------------8474411127918531132143183931
+  ... Content-Disposition: form-data; name="field.permission"
+  ... 
+  ... 
+  ... -----------------------------8474411127918531132143183931
+  ... Content-Disposition: form-data; name="field.permission-empty-marker"
+  ... 
+  ... 1
+  ... -----------------------------8474411127918531132143183931
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ... 
+  ... Add
+  ... -----------------------------8474411127918531132143183931--
+  ... """)
+  HTTP/1.1 303 See Other
+  ...
+
+
+Next, we'll add the group folder:
+
+  >>> print http(r"""
+  ... POST /++etc++site/@@contents.html HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 118
+  ... Content-Type: application/x-www-form-urlencoded
+  ... Referer: http://localhost:8081/++etc++site/@@contents.html
+  ... 
+  ... container_add_button=Add&single_new_value=tools&single_type_name=BrowserAdd__zope.app.site.folder.SiteManagementFolder""")
+  HTTP/1.1 303 See Other
+  ...
+
+  >>> print http(r"""
+  ... POST /++etc++site/AddIPrincipalSearchPluginTool/AddGroupFolder.html%3D HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 420
+  ... Content-Type: multipart/form-data; boundary=---------------------------1160081710811409419323271465
+  ... Referer: http://localhost:8081/++etc++site/AddIPrincipalSearchPluginTool/AddGroupFolder.html=
+  ... 
+  ... -----------------------------1160081710811409419323271465
+  ... Content-Disposition: form-data; name="field.prefix"
+  ... 
+  ... test.
+  ... -----------------------------1160081710811409419323271465
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ... 
+  ... Add
+  ... -----------------------------1160081710811409419323271465
+  ... Content-Disposition: form-data; name="add_input_name"
+  ... 
+  ... 
+  ... -----------------------------1160081710811409419323271465--
+  ... """)
+  HTTP/1.1 303 See Other
+  ...
+
+And add some groups:
+
+  >>> print http(r"""
+  ... POST /++etc++site/tools/GroupFolder/+/AddGroupInformation.html%3D HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 545
+  ... Content-Type: multipart/form-data; boundary=---------------------------57051497716357005611441891504
+  ... Referer: http://localhost:8081/++etc++site/tools/GroupFolder/+/AddGroupInformation.html=
+  ... 
+  ... -----------------------------57051497716357005611441891504
+  ... Content-Disposition: form-data; name="field.title"
+  ... 
+  ... Test1
+  ... -----------------------------57051497716357005611441891504
+  ... Content-Disposition: form-data; name="field.description"
+  ... 
+  ... 
+  ... -----------------------------57051497716357005611441891504
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ... 
+  ... Add
+  ... -----------------------------57051497716357005611441891504
+  ... Content-Disposition: form-data; name="add_input_name"
+  ... 
+  ... 
+  ... -----------------------------57051497716357005611441891504--
+  ... """)
+  HTTP/1.1 303 See Other
+  ...
+
+
+  >>> print http(r"""
+  ... POST /++etc++site/tools/GroupFolder/+/AddGroupInformation.html%3D HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 540
+  ... Content-Type: multipart/form-data; boundary=---------------------------1162360160489428309570988744
+  ... Referer: http://localhost:8081/++etc++site/tools/GroupFolder/+/AddGroupInformation.html=
+  ... 
+  ... -----------------------------1162360160489428309570988744
+  ... Content-Disposition: form-data; name="field.title"
+  ... 
+  ... Test2
+  ... -----------------------------1162360160489428309570988744
+  ... Content-Disposition: form-data; name="field.description"
+  ... 
+  ... 
+  ... -----------------------------1162360160489428309570988744
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ... 
+  ... Add
+  ... -----------------------------1162360160489428309570988744
+  ... Content-Disposition: form-data; name="add_input_name"
+  ... 
+  ... 
+  ... -----------------------------1162360160489428309570988744--
+  ... """)
+  HTTP/1.1 303 See Other
+  ...
+
+Now we'll configure our pluggable-authentication utility to use the
+group folder:
+
+  >>> print http(r"""
+  ... POST /++etc++site/default/PA/@@edit.html HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 708
+  ... Content-Type: multipart/form-data; boundary=---------------------------13414337386198656711891559433
+  ... Referer: http://localhost:8081/++etc++site/default/PA/@@edit.html
+  ... 
+  ... -----------------------------13414337386198656711891559433
+  ... Content-Disposition: form-data; name="field.factories.to"
+  ... 
+  ... Default
+  ... -----------------------------13414337386198656711891559433
+  ... Content-Disposition: form-data; name="field.searchers.to"
+  ... 
+  ... GroupFolder
+  ... -----------------------------13414337386198656711891559433
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ... 
+  ... Change
+  ... -----------------------------13414337386198656711891559433
+  ... Content-Disposition: form-data; name="field.factories"
+  ... 
+  ... Default
+  ... -----------------------------13414337386198656711891559433
+  ... Content-Disposition: form-data; name="field.searchers"
+  ... 
+  ... GroupFolder
+  ... -----------------------------13414337386198656711891559433--
+  ... """)
+  HTTP/1.1 200 Ok
+  ...
+
+Now, if we search for a group, but don't supply a string:
+
+  >>> print http(r"""
+  ... POST /@@grant.html HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Length: 182
+  ... Content-Type: application/x-www-form-urlencoded
+  ... 
+  ... field.principal.displayed=y&field.principal.MC5Hcm91cEZvbGRlcg__.query.field.search=&field.principal.MC5Hcm91cEZvbGRlcg__.query.search=Search&field.principal.MQ__.query.searchstring=""")
+  HTTP/1.1 200 Ok
+  ...Test1...Test2...
+
+We get both of our groups in the result.

Modified: Zope3/trunk/src/zope/app/pau/groupfolder.py
===================================================================
--- Zope3/trunk/src/zope/app/pau/groupfolder.py	2004-12-23 21:44:30 UTC (rev 28697)
+++ Zope3/trunk/src/zope/app/pau/groupfolder.py	2004-12-23 21:59:10 UTC (rev 28698)
@@ -79,9 +79,14 @@
              
 
 class IGroupSearchCriteria(zope.interface.Interface):
-    search = zope.schema.TextLine(title=u"Group Search String")
 
+    search = zope.schema.TextLine(
+        title=u"Group Search String",
+        required=False,
+        missing_value=u'',
+        )
 
+
 class GroupFolder(BTreeContainer):
 
     zope.interface.implements(IGroupFolder)



More information about the Zope3-Checkins mailing list