diff -r 30faf6021278 -r 3f3d576b87d9 web/component.py --- a/web/component.py Tue Jan 11 12:05:12 2011 +0100 +++ b/web/component.py Tue Jan 11 12:19:36 2011 +0100 @@ -24,7 +24,7 @@ from warnings import warn -from logilab.common.deprecation import class_deprecated, class_renamed +from logilab.common.deprecation import class_deprecated, class_renamed, deprecated from logilab.mtconverter import xml_escape from cubicweb import Unauthorized, role, target, tags @@ -36,7 +36,7 @@ non_final_entity, partial_relation_possible, partial_has_related_entities) from cubicweb.appobject import AppObject -from cubicweb.web import INTERNAL_FIELD_VALUE, htmlwidgets, stdmsgs +from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs # abstract base class for navigation components ################################ @@ -163,6 +163,57 @@ rendered """ + +class Link(object): + """a link to a view or action in the ui. + + Use this rather than `cw.web.htmlwidgets.BoxLink`. + + Note this class could probably be avoided with a proper DOM on the server + side. + """ + newstyle = True + + def __init__(self, href, label, **attrs): + self.href = href + self.label = label + self.attrs = attrs + + def __unicode__(self): + return tags.a(self.label, href=self.href, **self.attrs) + + def render(self, w): + w(tags.a(self.label, href=self.href, **self.attrs)) + + +class Separator(object): + """a menu separator. + + Use this rather than `cw.web.htmlwidgets.BoxSeparator`. + """ + newstyle = True + + def render(self, w): + w(u'
') + + +def _bwcompatible_render_item(w, item): + if hasattr(item, 'render'): + if getattr(item, 'newstyle', False): + if isinstance(item, Separator): + w(u'') + item.render(w) + w(u'