[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/form/browser/source.txt
Fixed formatting (EOL WS).
Benji York
benji at zope.com
Fri Feb 4 12:11:27 EST 2005
Log message for revision 29036:
Fixed formatting (EOL WS).
Changed:
U Zope3/trunk/src/zope/app/form/browser/source.txt
-=-
Modified: Zope3/trunk/src/zope/app/form/browser/source.txt
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/source.txt 2005-02-04 17:10:49 UTC (rev 29035)
+++ Zope3/trunk/src/zope/app/form/browser/source.txt 2005-02-04 17:11:27 UTC (rev 29036)
@@ -40,7 +40,7 @@
>>> import zope.schema
>>> class SourceList(list):
... zope.interface.implements(zope.schema.interfaces.ISource)
-
+
We provide an `ITerms` view for the source:
>>> class Term:
@@ -52,24 +52,24 @@
...
... def __init__(self, source, request):
... pass # We don't actually need the source or the request :)
- ...
+ ...
... def getTerm(self, value):
... title = unicode(value)
... token = title.encode('base64').strip()
... return Term(title=title, token=token)
- ...
+ ...
... def getValue(self, token):
... return token.decode('base64')
>>> from zope.app.tests import ztapi
>>> from zope.publisher.interfaces.browser import IBrowserRequest
>>> import zope.app.form.browser.interfaces
- >>> ztapi.provideAdapter((SourceList, IBrowserRequest),
+ >>> ztapi.provideAdapter((SourceList, IBrowserRequest),
... zope.app.form.browser.interfaces.ITerms,
... ListTerms)
-
+
This view just uses the unicode representations of values as titles
-and the base-64 encoding of the titles as tokens. This is a very
+and the base-64 encoding of the titles as tokens. This is a very
simple strategy that's only approriate when the values have short and
unique unicode representations.
@@ -78,18 +78,18 @@
query view for the source:
>>> class ListQueryView:
- ...
+ ...
... def __init__(self, source, request):
... self.source = source
... self.request = request
- ...
+ ...
... def render(self, name):
... return (
... '<input name="%s.string">\n'
... '<input type="submit" name="%s" value="Search">'
... % (name, name)
... )
- ...
+ ...
... def results(self, name):
... if name in self.request:
... search_string = self.request.get(name+'.string')
@@ -100,7 +100,7 @@
... ]
... return None
- >>> ztapi.provideAdapter((SourceList, IBrowserRequest),
+ >>> ztapi.provideAdapter((SourceList, IBrowserRequest),
... zope.app.form.browser.interfaces.ISourceQueryView,
... ListQueryView)
@@ -121,7 +121,7 @@
>>> request = TestRequest()
>>> widget = zope.app.form.browser.source.SourceInputWidget(
... dog, dog.source, request)
-
+
Now if we render the widget, we'll see the input value (initially
nothing) and a form elements for seaching for values:
@@ -171,7 +171,7 @@
If we actually provide some input:
- >>> request.form['field.dog'] = 'foo'
+ >>> request.form['field.dog'] = 'foo'
then we have input:
@@ -275,7 +275,7 @@
We can reuse our terms view:
- >>> ztapi.provideAdapter((MultiSource, IBrowserRequest),
+ >>> ztapi.provideAdapter((MultiSource, IBrowserRequest),
... zope.app.form.browser.interfaces.ITerms,
... ListTerms)
More information about the Zope3-Checkins
mailing list