[Zope3-checkins] CVS: Zope3/src/zope/app/form - widget.py:1.9
Gary Poster
gary at zope.com
Fri Sep 26 15:54:05 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/form
In directory cvs.zope.org:/tmp/cvs-serv11773/form
Modified Files:
widget.py
Log Message:
make title and description properties that translate themselves if possible. Add description attribute to IWidget.
=== Zope3/src/zope/app/form/widget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/form/widget.py:1.8 Wed Aug 13 17:28:34 2003
+++ Zope3/src/zope/app/form/widget.py Fri Sep 26 15:53:34 2003
@@ -19,6 +19,8 @@
from zope.app.interfaces.form import IWidget
from zope.component.interfaces import IViewFactory
from zope.interface import implements
+from zope.app.services.servicenames import Translation
+from zope.component import getService
__metaclass__ = type
@@ -54,8 +56,8 @@
if traceback.extract_stack()[-2][2] != 'setRenderedValue':
warn("setData is deprecated - use setRenderedValue",
DeprecationWarning, 2)
-
- # XXX - move this implementation to setRenderedValue when
+
+ # XXX - move this implementation to setRenderedValue when
# deprecation is removed
self._data = value
@@ -68,7 +70,7 @@
def hasValidInput(self):
raise TypeError("hasValidInput has not been implemented")
-
+
def getInputValue(self):
raise TypeError("getInputValue has not been implemented")
@@ -78,8 +80,22 @@
def applyChanges(self, content):
raise TypeError("applyChanges has not been implemented")
- title = property(lambda self: self.context.title)
- description = property(lambda self: self.context.description)
+ def title(self):
+ ts = getService(self.context, Translation)
+ # Note that the domain is not that important here, since the title
+ # is most likely a message id carrying the domain anyways.
+ context_title = self.context.title
+ return (ts.translate(context_title, "zope", context=self.request)
+ or context_title)
+ title = property(title)
+
+ def description(self):
+ ts = getService(self.context, Translation)
+ # hopefully the description is a message id with domain (?).
+ context_desc = self.context.description
+ return (ts.translate(context_desc, "zope", context=self.request)
+ or context_desc)
+ description = property(description)
required = property(lambda self: self.context.required)
More information about the Zope3-Checkins
mailing list