[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/security/browser/ Sprinting with Jim:

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Oct 13 03:42:19 EDT 2004


Log message for revision 28040:
  Sprinting with Jim:
  
  Provide a regular Authentication Service search view.
  

Changed:
  U   Zope3/trunk/src/zope/app/security/browser/auth.py
  U   Zope3/trunk/src/zope/app/security/browser/tests.py

-=-
Modified: Zope3/trunk/src/zope/app/security/browser/auth.py
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/auth.py	2004-10-13 07:33:15 UTC (rev 28039)
+++ Zope3/trunk/src/zope/app/security/browser/auth.py	2004-10-13 07:42:18 UTC (rev 28040)
@@ -16,11 +16,49 @@
 $Id$
 """
 from zope.interface import implements
+from zope.i18n import translate
 from zope.app.publisher.interfaces.http import ILogin, ILogout
+from zope.app.security.interfaces import IAuthenticationService
 from zope.app.security.principalregistry import UnauthenticatedPrincipal
 from zope.app.pagetemplate import ViewPageTemplateFile
 from zope.proxy import removeAllProxies
+from zope.app.i18n import ZopeMessageIDFactory as _
 
+
+search_label = _('search-button', 'Search')
+
+class AuthServiceSearchView(object):
+    __used_for__ = IAuthenticationService
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def render(self, name):
+        html = []
+        html.append('<div class="row">')
+        html.append('<div class="label">')
+        html.append('Search String')
+        html.append('</div>')
+        html.append('<div class="field">')
+        html.append('<input type="text" name="%s" />' %(name+'.searchstring'))
+        html.append('</div>')
+        html.append('</div>')
+
+        html.append('<br /><input type="submit" name="%s" value="%s" />'
+                    % (name+'.search',
+                       translate(search_label, context=self.request)))
+
+        return '\n'.join(html)
+
+    def results(self, name):
+        if not (name+'.search' in self.request):
+            return None
+        searchstring = self.request[name+'.searchstring']
+        return [principal.id
+                for principal in self.context.getPrincipals(searchstring)]
+
+
 class HTTPAuthenticationLogin(object):
     implements(ILogin)
 

Modified: Zope3/trunk/src/zope/app/security/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/tests.py	2004-10-13 07:33:15 UTC (rev 28039)
+++ Zope3/trunk/src/zope/app/security/browser/tests.py	2004-10-13 07:42:18 UTC (rev 28040)
@@ -22,6 +22,9 @@
 
 def test_suite():
     return unittest.TestSuite((
+        doctest.DocFileSuite('authservicesearchview.txt',
+                             setUp=placelesssetup.setUp,
+                             tearDown=placelesssetup.tearDown),
         doctest.DocFileSuite('principalterms.txt',
                              setUp=placelesssetup.setUp,
                              tearDown=placelesssetup.tearDown),



More information about the Zope3-Checkins mailing list