[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/pas/ Added searching support.

Jim Fulton jim at zope.com
Wed Oct 13 11:33:17 EDT 2004


Log message for revision 28100:
  Added searching support.
  

Changed:
  U   Zope3/trunk/src/zope/app/pas/README.txt
  U   Zope3/trunk/src/zope/app/pas/pas.py

-=-
Modified: Zope3/trunk/src/zope/app/pas/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/pas/README.txt	2004-10-13 15:17:12 UTC (rev 28099)
+++ Zope3/trunk/src/zope/app/pas/README.txt	2004-10-13 15:33:16 UTC (rev 28100)
@@ -519,4 +519,28 @@
 Searching
 =========
 
-  XXX Still workin this out
+As their name suggests, search plugins provide searching support.
+We've already seen them used to get principals given principal
+ids. They're also used to find principals given search criteria.
+
+Different search plugins are likely to use very different search
+criteria.  There are two approaches a plugin can use to support
+searching: 
+
+- A plugin can provide IQuerySchemaSearch, in addition to
+  `IPrincipalSearchPlugin`.  In this case, the plugin provises a search
+  method and a schema that describes the input to be provided to the
+  search method.
+
+- For browser-based applications, the plugin can provide a browser
+  view that provides
+  `zope.app.form.browser.interfaces.ISourceQueryView`.
+
+PAS uses search plugins in a very simple way.  It mearly implements
+`zope.schema.interfaces.ISourceQueriables`:
+
+  >>> [id for (id, queriable) in service.getQueriables()]
+  ['s42', 'sint']
+  >>> [queriable.__class__.__name__ 
+  ...  for (id, queriable) in service.getQueriables()]
+  ['Search42', 'IntSearch']

Modified: Zope3/trunk/src/zope/app/pas/pas.py
===================================================================
--- Zope3/trunk/src/zope/app/pas/pas.py	2004-10-13 15:17:12 UTC (rev 28099)
+++ Zope3/trunk/src/zope/app/pas/pas.py	2004-10-13 15:33:16 UTC (rev 28100)
@@ -21,6 +21,8 @@
 import zope.schema
 from persistent import Persistent
 
+from zope.schema.interfaces import ISourceQueriables
+
 from zope.app import zapi
 
 from zope.app.security.interfaces import IAuthenticationService
@@ -74,7 +76,7 @@
 
 class PAS:
 
-    zope.interface.implements(IPAS, IAuthenticationService)
+    zope.interface.implements(IPAS, IAuthenticationService, ISourceQueriables)
 
     authenticators = extractors = challengers = factories = search = ()
 
@@ -134,6 +136,12 @@
 
         return self._delegate('getPrincipal', self.prefix+id)
 
+    def getQueriables(self):
+        for searcher_id in self.searchers:
+            searcher = zapi.queryUtility(IPrincipalSearchPlugin, searcher_id)
+            yield searcher_id, searcher
+        
+
     def unauthenticatedPrincipal(self):
         return None
 



More information about the Zope3-Checkins mailing list