[Zope3-checkins]
SVN: Zope3/branches/f12gsprint-widget/src/zope/widget/widget.
added basic __call__ and test for __call__
Dylan Reinhardt
zope at dylanreinhardt.com
Fri Sep 2 16:22:27 EDT 2005
Log message for revision 38251:
added basic __call__ and test for __call__
Changed:
U Zope3/branches/f12gsprint-widget/src/zope/widget/widget.py
U Zope3/branches/f12gsprint-widget/src/zope/widget/widget.txt
-=-
Modified: Zope3/branches/f12gsprint-widget/src/zope/widget/widget.py
===================================================================
--- Zope3/branches/f12gsprint-widget/src/zope/widget/widget.py 2005-09-02 20:14:44 UTC (rev 38250)
+++ Zope3/branches/f12gsprint-widget/src/zope/widget/widget.py 2005-09-02 20:22:26 UTC (rev 38251)
@@ -3,6 +3,7 @@
from zope import interface
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.schema.interfaces import ValidationError
+from xml.sax.saxutils import quoteattr
import zope.widget.interfaces
@@ -120,14 +121,19 @@
class TextLineWidget(BaseInputWidget):
- #template = namedtemplate.NamedTemplate('default')
+ #template = namedtemplate.NamedTemplate('default')
+
+ t = ("""<input type="text" value=%(value)s name=%(name)s """
+ """id=%(name)s size="20" />""")
+
def __call__(self):
if self._valueForced:
value = self.getValue()
else:
value = self._state
- return self.template(value=value)
+ return self.t % {'value':quoteattr(value or ''),
+ 'name':quoteattr(self.name)}
#("""<input type="text" value=%(value)s name=%(name)s """
# """id=%(name)s size="20" />""")
Modified: Zope3/branches/f12gsprint-widget/src/zope/widget/widget.txt
===================================================================
--- Zope3/branches/f12gsprint-widget/src/zope/widget/widget.txt 2005-09-02 20:14:44 UTC (rev 38250)
+++ Zope3/branches/f12gsprint-widget/src/zope/widget/widget.txt 2005-09-02 20:22:26 UTC (rev 38251)
@@ -41,6 +41,8 @@
>>> w.getState() # None
>>> w.hasState()
False
+ >>> w()
+ '<input type="text" value="" name="test_name" id="test_name" size="20" />'
Because we have set no value for the widget, nor was any available in the
request, a required field will raise a RequiredMissing is getValue is called.
More information about the Zope3-Checkins
mailing list