32 primaryview_display_ctrl.tag_attribute(('Foo', 'bar'), {'vid': 'attribute'}) |
32 primaryview_display_ctrl.tag_attribute(('Foo', 'bar'), {'vid': 'attribute'}) |
33 |
33 |
34 |
34 |
35 .. autoclass:: AttributeView |
35 .. autoclass:: AttributeView |
36 .. autoclass:: URLAttributeView |
36 .. autoclass:: URLAttributeView |
|
37 .. autoclass:: VerbatimAttributeView |
37 """ |
38 """ |
38 |
39 |
39 __docformat__ = "restructuredtext en" |
40 __docformat__ = "restructuredtext en" |
40 _ = unicode |
41 _ = unicode |
41 |
42 |
419 xml_escape(self._cw.build_url(rql=rql, vid=subvid)), |
420 xml_escape(self._cw.build_url(rql=rql, vid=subvid)), |
420 self._cw._('see them all'))) |
421 self._cw._('see them all'))) |
421 self.w(u'</div>') |
422 self.w(u'</div>') |
422 |
423 |
423 |
424 |
424 class URLAttributeView(EntityView): |
|
425 """:__regid__: *urlattr* |
|
426 |
|
427 This view will wrap an attribute value (hence expect a string) into an '<a>' |
|
428 HTML tag to display a clickable link. |
|
429 """ |
|
430 __regid__ = 'urlattr' |
|
431 __select__ = EntityView.__select__ & match_kwargs('rtype') |
|
432 |
|
433 def entity_call(self, entity, rtype, **kwargs): |
|
434 url = entity.printable_value(rtype) |
|
435 if url: |
|
436 self.w(u'<a href="%s">%s</a>' % (url, url)) |
|
437 |
|
438 class AttributeView(EntityView): |
425 class AttributeView(EntityView): |
439 """:__regid__: *attribute* |
426 """:__regid__: *attribute* |
440 |
427 |
441 This view is generally used to disable the *reledit* feature. It works on |
428 This view is generally used to disable the *reledit* feature. It works on |
442 both relations and attributes. |
429 both relations and attributes. |
453 rset = entity.related(rtype, role) |
440 rset = entity.related(rtype, role) |
454 if rset: |
441 if rset: |
455 self.wview('autolimited', rset, initargs={'dispctrl': dispctrl}) |
442 self.wview('autolimited', rset, initargs={'dispctrl': dispctrl}) |
456 |
443 |
457 |
444 |
|
445 class URLAttributeView(EntityView): |
|
446 """:__regid__: *urlattr* |
|
447 |
|
448 This view will wrap an attribute value (hence expect a string) into an '<a>' |
|
449 HTML tag to display a clickable link. |
|
450 """ |
|
451 __regid__ = 'urlattr' |
|
452 __select__ = EntityView.__select__ & match_kwargs('rtype') |
|
453 |
|
454 def entity_call(self, entity, rtype, **kwargs): |
|
455 url = entity.printable_value(rtype) |
|
456 if url: |
|
457 self.w(u'<a href="%s">%s</a>' % (url, url)) |
|
458 |
|
459 |
|
460 class VerbatimAttributeView(EntityView): |
|
461 """:__regid__: *verbatimattr* |
|
462 |
|
463 This view will wrap an attribute value into an '<pre>' HTML tag to display |
|
464 arbitrary text where EOL will be respected. It usually make sense for |
|
465 attributes whose value is a multi-lines string where new lines matters. |
|
466 """ |
|
467 __regid__ = 'verbatimattr' |
|
468 __select__ = EntityView.__select__ & match_kwargs('rtype') |
|
469 |
|
470 def entity_call(self, entity, rtype, **kwargs): |
|
471 value = entity.printable_value(rtype) |
|
472 if value: |
|
473 self.w(u'<pre>%s</pre>' % value) |
|
474 |
|
475 |
|
476 |
|
477 |
458 |
478 |
459 class ToolbarLayout(component.Layout): |
479 class ToolbarLayout(component.Layout): |
460 # XXX include me in the doc |
480 # XXX include me in the doc |
461 __select__ = match_context('ctxtoolbar') |
481 __select__ = match_context('ctxtoolbar') |
462 |
482 |