# HG changeset patch # User Sylvain Thénault # Date 1316781824 -7200 # Node ID dd3f0871d8b7cca9dddfee6e0c5c010a26e8cd63 # Parent 2172978be23752fdd79b0634f1767be0d33eba08 [primary view] add 'verbatim' attribute view (closes #1947475) diff -r 2172978be237 -r dd3f0871d8b7 web/views/cwsources.py --- a/web/views/cwsources.py Fri Sep 23 14:18:13 2011 +0200 +++ b/web/views/cwsources.py Fri Sep 23 14:43:44 2011 +0200 @@ -56,9 +56,9 @@ _pvdc.tag_attribute(('CWSource', 'type'), {'vid': 'attribute'})# disable reledit _rc = uicfg.reledit_ctrl -_rc.tag_attribute(('CWSource', 'config'), {'rvid': 'verbatim'}) -_rc.tag_attribute(('CWSourceHostConfig', 'config'), {'rvid': 'verbatim'}) -_rc.tag_attribute(('CWSourceSchemaConfig', 'options'), {'rvid': 'verbatim'}) +_rc.tag_attribute(('CWSource', 'config'), {'rvid': 'verbatimattr'}) +_rc.tag_attribute(('CWSourceHostConfig', 'config'), {'rvid': 'verbatimattr'}) +_rc.tag_attribute(('CWSourceSchemaConfig', 'options'), {'rvid': 'verbatimattr'}) class CWSourcePrimaryView(tabs.TabbedPrimaryView): diff -r 2172978be237 -r dd3f0871d8b7 web/views/primary.py --- a/web/views/primary.py Fri Sep 23 14:18:13 2011 +0200 +++ b/web/views/primary.py Fri Sep 23 14:43:44 2011 +0200 @@ -34,6 +34,7 @@ .. autoclass:: AttributeView .. autoclass:: URLAttributeView +.. autoclass:: VerbatimAttributeView """ __docformat__ = "restructuredtext en" @@ -421,20 +422,6 @@ self.w(u'') -class URLAttributeView(EntityView): - """:__regid__: *urlattr* - - This view will wrap an attribute value (hence expect a string) into an '' - HTML tag to display a clickable link. - """ - __regid__ = 'urlattr' - __select__ = EntityView.__select__ & match_kwargs('rtype') - - def entity_call(self, entity, rtype, **kwargs): - url = entity.printable_value(rtype) - if url: - self.w(u'%s' % (url, url)) - class AttributeView(EntityView): """:__regid__: *attribute* @@ -455,6 +442,39 @@ self.wview('autolimited', rset, initargs={'dispctrl': dispctrl}) +class URLAttributeView(EntityView): + """:__regid__: *urlattr* + + This view will wrap an attribute value (hence expect a string) into an '' + HTML tag to display a clickable link. + """ + __regid__ = 'urlattr' + __select__ = EntityView.__select__ & match_kwargs('rtype') + + def entity_call(self, entity, rtype, **kwargs): + url = entity.printable_value(rtype) + if url: + self.w(u'%s' % (url, url)) + + +class VerbatimAttributeView(EntityView): + """:__regid__: *verbatimattr* + + This view will wrap an attribute value into an '
' HTML tag to display
+    arbitrary text where EOL will be respected. It usually make sense for
+    attributes whose value is a multi-lines string where new lines matters.
+    """
+    __regid__ = 'verbatimattr'
+    __select__ = EntityView.__select__ & match_kwargs('rtype')
+
+    def entity_call(self, entity, rtype, **kwargs):
+        value = entity.printable_value(rtype)
+        if value:
+            self.w(u'
%s
' % value) + + + + class ToolbarLayout(component.Layout): # XXX include me in the doc