Changeset 7702 for main/waeup.sirp/trunk/src/waeup/sirp/widgets
- Timestamp:
- 25 Feb 2012, 10:21:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/widgets/restwidget.py
r7385 r7702 18 18 """A widget that renders restructured text. 19 19 """ 20 from zope.component import getUtility 20 21 from zope.formlib.widget import renderElement, DisplayWidget 21 22 from waeup.sirp.utils.helpers import ReST2HTML 23 from waeup.sirp.interfaces import ISIRPUtils 22 24 23 25 … … 27 29 28 30 def __call__(self): 31 """The ReSTDisplayWidget transforms a ReST text string into 32 a dictionary. 33 34 Different languages must be separated by `<<xy>>` whereas 35 xy is the language code. Text parts without correct leading 36 language separator - usually the first part has no language 37 descriptor - are interpreted as texts in the portal's language. 38 The latter can be configured in waeup.srp.utils.utils.SIRPUtils. 39 """ 29 40 if self._renderedValueSet(): 30 41 value = self._data … … 33 44 if value == self.context.missing_value: 34 45 return "" 35 return renderElement(u'div id="rest"', 36 contents=ReST2HTML(value)) 46 parts = value.split('>>') 47 elements = {} 48 lang = getUtility(ISIRPUtils).PORTAL_LANGUAGE 49 for part in parts: 50 if part[2:4] == u'<<': 51 lang = part[0:2].lower() 52 text = part[4:] 53 elements[lang] = renderElement(u'div id="rest"', 54 contents=ReST2HTML(text)) 55 else: 56 text = part 57 elements[lang] = renderElement(u'div id="rest"', 58 contents=ReST2HTML(text)) 59 return elements
Note: See TracChangeset for help on using the changeset viewer.