[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Changed the
PrincipalSource getQueriables method,
now we return each utility only once.
Roger Ineichen
roger at projekt01.ch
Wed Feb 9 18:14:53 EST 2005
Log message for revision 29096:
Changed the PrincipalSource getQueriables method, now we return each utility only once.
Changed the render method in QuerySchemaSearchView for rendering zope3.css like html output.
Changed the source widget for rendering zope3 CSS conform html output.
Changed the getQueriables in authentication.py, ensure that we access the right searchers
if we call the getQueriables method from a PrincipalSource vocabulary.
Changed test setup for zope.app.authentication.README.txt to placefull, for supporting getUtility context.
TODO:
Perhaps we shold change the source widget that the search forms QuerySchemaSearchView just show up if we
havn't selected a source item. If we selected a source item we can show just a link for selecting another item.
This whould simplyfie the search result, which in the authentication grant.html form is a bigger table.
Changed:
U Zope3/trunk/src/zope/app/authentication/authentication.py
U Zope3/trunk/src/zope/app/authentication/browser/schemasearch.py
U Zope3/trunk/src/zope/app/authentication/browser/schemasearch.txt
U Zope3/trunk/src/zope/app/authentication/tests.py
U Zope3/trunk/src/zope/app/form/browser/source.py
U Zope3/trunk/src/zope/app/form/browser/source.txt
UU Zope3/trunk/src/zope/app/security/vocabulary.py
U Zope3/trunk/src/zope/app/securitypolicy/browser/granting.pt
-=-
Modified: Zope3/trunk/src/zope/app/authentication/authentication.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/authentication.py 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/authentication/authentication.py 2005-02-09 23:14:53 UTC (rev 29096)
@@ -103,7 +103,10 @@
def getQueriables(self):
for searcher_id in self.searchers:
- searcher = queryUtility(IPrincipalSearchPlugin, searcher_id)
+ # ensure with context=self that we call it in the context if
+ # we call it form a PrincipalSource vocabulary
+ searcher = queryUtility(IPrincipalSearchPlugin, searcher_id,
+ context=self)
yield searcher_id, searcher
Modified: Zope3/trunk/src/zope/app/authentication/browser/schemasearch.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/schemasearch.py 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/authentication/browser/schemasearch.py 2005-02-09 23:14:53 UTC (rev 29096)
@@ -44,7 +44,25 @@
html = []
# add sub title for source search field
- html.append('<h4 i18n:translate="">%s %s</h4>' % (sourcename, sourcepath))
+ html.append('<h4>%s</h4>' % sourcename)
+
+ # start row for path display field
+ html.append('<div class="row">')
+
+ # for each source add path of source
+ html.append(' <div class="label">')
+ label = _(u"Source path")
+ title = _(u"Path to the source utility")
+ html.append(' <label for="%s" title="%s">' % (sourcename, title))
+ html.append(' %s' % label)
+ html.append(' </label>')
+ html.append(' </div>')
+ html.append(' <div class="field">')
+ html.append(' %s' % sourcepath)
+ html.append(' </field>')
+ html.append(' </div>')
+ html.append('</div>')
+
# start row for search fields
html.append('<div class="row">')
@@ -52,35 +70,34 @@
widget = getattr(self, field_name+'_widget')
# for each field add lable...
- html.append('<div class="label">')
- html.append('<label for="%s" title="%s">'
+ html.append(' <div class="label">')
+ html.append(' <label for="%s" title="%s">'
% (widget.name, widget.hint))
- html.append(widget.label)
- html.append('</label>')
- html.append('</div>')
+ html.append(' %s' % widget.label)
+ html.append(' </label>')
+ html.append(' </div>')
# ...and field widget
- html.append('<div class="field">')
- html.append(widget())
+ html.append(' <div class="field">')
+ html.append(' %s' % widget())
if widget.error():
- html.append('<div class="error">')
- html.append(widget.error())
- html.append('</div>')
- html.append('</div>')
+ html.append(' <div class="error">')
+ html.append(' %s' % widget.error())
+ html.append(' </div>')
+ html.append(' </div>')
# end row
html.append('</div>')
# add search button for search fields
html.append('<div class="row">')
- html.append('<div class="field">')
- html.append('<input type="submit" name="%s" value="%s" />'
+ html.append(' <div class="field">')
+ html.append(' <input type="submit" name="%s" value="%s" />'
% (name+'.search',
translate(search_label, context=self.request)))
+ html.append(' </div>')
html.append('</div>')
- html.append('</div>')
-
return '\n'.join(html)
def results(self, name):
Modified: Zope3/trunk/src/zope/app/authentication/browser/schemasearch.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/schemasearch.txt 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/authentication/browser/schemasearch.txt 2005-02-09 23:14:53 UTC (rev 29096)
@@ -52,23 +52,34 @@
This allows us to render a search form.
>>> print view.render('test') # doctest: +NORMALIZE_WHITESPACE
- <h4 i18n:translate="">searchplugin /searchplugin</h4>
+ <h4>searchplugin</h4>
<div class="row">
- <div class="label">
- <label for="test.field.search" title="">
- Search String
- </label>
+ <div class="label">
+ <label for="searchplugin" title="Path to the source utility">
+ Source path
+ </label>
+ </div>
+ <div class="field">
+ /searchplugin
+ </field>
+ </div>
</div>
- <div class="field">
- <input class="textType" id="test.field.search" name="test.field.search"
+ <div class="row">
+ <div class="label">
+ <label for="test.field.search" title="">
+ 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>
- </div>
<div class="row">
- <div class="field">
- <input type="submit" name="test.search" value="Search" />
+ <div class="field">
+ <input type="submit" name="test.search" value="Search" />
+ </div>
</div>
- </div>
If we ask for results:
Modified: Zope3/trunk/src/zope/app/authentication/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/tests.py 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/authentication/tests.py 2005-02-09 23:14:53 UTC (rev 29096)
@@ -59,7 +59,13 @@
def groupSetUp(test):
placelesssetup.setUp()
+def searcheableSetUp(self):
+ placefulSetUp(site=True)
+def searcheableTearDown(self):
+ placefulTearDown()
+
+
def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite('zope.app.authentication.generic'),
@@ -71,8 +77,8 @@
setUp=formAuthSetUp,
tearDown=formAuthTearDown),
doctest.DocFileSuite('README.txt',
- setUp=placelesssetup.setUp,
- tearDown=placelesssetup.tearDown,
+ setUp=searcheableSetUp,
+ tearDown=searcheableTearDown,
globs={'provideUtility': ztapi.provideUtility,
'getEvents': getEvents,
}),
Modified: Zope3/trunk/src/zope/app/form/browser/source.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/source.py 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/form/browser/source.py 2005-02-09 23:14:53 UTC (rev 29096)
@@ -149,6 +149,12 @@
term = None
if value == field.missing_value:
result.append(' <div class="row">')
+ result.append(' <div class="label">')
+ result.append(u' ' +
+ self._translate(_("SourceDisplayWidget-label",
+ default="Selected"))
+ )
+ result.append(' </div>')
result.append(' <div class="field">')
result.append(u' ' +
self._translate(_("SourceDisplayWidget-missing",
@@ -166,6 +172,12 @@
)
else:
result.append(' <div class="row">')
+ result.append(' <div class="label">')
+ result.append(u' ' +
+ self._translate(_("SourceDisplayWidget-label",
+ default="Selected"))
+ )
+ result.append(' </div>')
result.append(' <div class="field">')
result.append(u' ' + cgi.escape(term.title))
result.append(' </div>')
Modified: Zope3/trunk/src/zope/app/form/browser/source.txt
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/source.txt 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/form/browser/source.txt 2005-02-09 23:14:53 UTC (rev 29096)
@@ -128,6 +128,9 @@
>>> print widget()
<div class="value">
<div class="row">
+ <div class="label">
+ Selected
+ </div>
<div class="field">
Nothing
</div>
@@ -185,6 +188,9 @@
>>> print widget()
<div class="value">
<div class="row">
+ <div class="label">
+ Selected
+ </div>
<div class="field">
Nothing
</div>
@@ -220,6 +226,9 @@
>>> print widget()
<div class="value">
<div class="row">
+ <div class="label">
+ Selected
+ </div>
<div class="field">
spot
</div>
@@ -301,6 +310,9 @@
>>> print widget()
<div class="value">
<div class="row">
+ <div class="label">
+ Selected
+ </div>
<div class="field">
Nothing
</div>
@@ -333,6 +345,9 @@
>>> print widget() # doctest:
<div class="value">
<div class="row">
+ <div class="label">
+ Selected
+ </div>
<div class="field">
Nothing
</div>
@@ -376,6 +391,9 @@
>>> print widget()
<div class="value">
<div class="row">
+ <div class="label">
+ Selected
+ </div>
<div class="field">
tabby
</div>
Modified: Zope3/trunk/src/zope/app/security/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/security/vocabulary.py 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/security/vocabulary.py 2005-02-09 23:14:53 UTC (rev 29096)
@@ -15,7 +15,7 @@
This vocabulary provides permission IDs.
-$Id: $
+$Id$
"""
from zope.security.checker import CheckerPublic
from zope.app import zapi
@@ -207,13 +207,18 @@
"""
i = 0
auth = zapi.getUtility(IAuthentication)
+ yielded = []
while True:
queriables = ISourceQueriables(auth, None)
if queriables is None:
yield unicode(i), auth
else:
for qid, queriable in queriables.getQueriables():
- yield unicode(i)+'.'+unicode(qid), queriable
+ # ensure that we dont return same yielded utility more
+ # then once
+ if queriable not in yielded:
+ yield unicode(i)+'.'+unicode(qid), queriable
+ yielded.append(queriable)
auth = queryNextUtility(auth, IAuthentication)
if auth is None:
break
Property changes on: Zope3/trunk/src/zope/app/security/vocabulary.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.pt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.pt 2005-02-09 22:08:55 UTC (rev 29095)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.pt 2005-02-09 23:14:53 UTC (rev 29096)
@@ -4,11 +4,12 @@
<h2 i18n:translate="">Granting Roles and Permissions to Principals</h2>
<p tal:define="status view/status"
tal:condition="status"
- tal:content="status" />
+ tal:content="status" />
<form action="" method="POST">
- <h4 i18n:translate="">Selected principal:</h4>
+
<div tal:content="structure view/principal_widget">...</div>
+
<div tal:condition="view/principal">
<h2 i18n:translate="">Grants for the selected principal</h2>
More information about the Zope3-Checkins
mailing list