Changeset 8024 for main/waeup.kofa/trunk/src/waeup/kofa/widgets
- Timestamp:
- 3 Apr 2012, 07:37:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/widgets/sequencewidget.py
r7819 r8024 22 22 """ 23 23 import grok 24 from zope.i18n import translate 24 25 from zope.browserpage import ViewPageTemplateFile 25 26 from zope.formlib.interfaces import IInputWidget, IDisplayWidget … … 47 48 itemTag = 'div' 48 49 50 def __call__(self): 51 """This is is a patch for the orginal __call__ method which doesn't call 52 the translate function properly. 53 """ 54 55 # get the data to display: 56 if self._renderedValueSet(): 57 data = self._data 58 else: 59 data = self.context.get(self.context.context) 60 61 # deal with special cases: 62 if data == self.context.missing_value: 63 return translate(self._missingValueMessage, context=self.request) 64 data = list(data) 65 if not data: 66 return translate(self._emptySequenceMessage, context=self.request) 67 68 parts = [] 69 for i, item in enumerate(data): 70 widget = self._getWidget(i) 71 widget.setRenderedValue(item) 72 s = widget() 73 if self.itemTag: 74 s = "<%s>%s</%s>" % (self.itemTag, s, self.itemTag) 75 parts.append(s) 76 contents = "\n".join(parts) 77 if self.tag: 78 contents = "\n%s\n" % contents 79 contents = renderElement(self.tag, 80 cssClass=self.cssClass, 81 extra=self.extra, 82 contents=contents) 83 return contents 84 49 85 # Register our sequence widgets as default for lists. 50 86 @grok.adapter(IList, IField, IBrowserRequest)
Note: See TracChangeset for help on using the changeset viewer.