web/component.py
changeset 6580 798200432f50
parent 6553 2be8ff05fd20
child 6743 d2d7a5d9164d
equal deleted inserted replaced
6579:2b93aa515031 6580:798200432f50
   181             return False
   181             return False
   182         return True
   182         return True
   183 
   183 
   184 
   184 
   185 class CtxComponent(AppObject):
   185 class CtxComponent(AppObject):
   186     """base class for contextual compontents. The following contexts are
   186     """base class for contextual components. The following contexts are
   187     predefined:
   187     predefined:
   188 
   188 
   189     * boxes: 'left', 'incontext', 'right'
   189     * boxes: 'left', 'incontext', 'right'
   190     * section: 'navcontenttop', 'navcontentbottom', 'navtop', 'navbottom'
   190     * section: 'navcontenttop', 'navcontentbottom', 'navtop', 'navbottom'
   191     * other: 'ctxtoolbar'
   191     * other: 'ctxtoolbar'
   192 
   192 
   193     The 'incontext', 'navcontenttop', 'navcontentbottom' and 'ctxtoolbar'
   193     The 'incontext', 'navcontenttop', 'navcontentbottom' and 'ctxtoolbar'
   194     context are handled by the default primary view, others by the default main
   194     contexts are handled by the default primary view, others by the default main
   195     template.
   195     template.
   196 
   196 
   197     All subclasses may not support all those contexts (for instance if it can't
   197     All subclasses may not support all those contexts (for instance if it can't
   198     be displayed as box, or as a toolbar icon). You may restrict allowed context
   198     be displayed as box, or as a toolbar icon). You may restrict allowed context
   199     as followed:
   199     as follows:
   200 
   200 
   201     .. sourcecode:: python
   201     .. sourcecode:: python
   202 
   202 
   203       class MyComponent(CtxComponent):
   203       class MyComponent(CtxComponent):
   204           cw_property_defs = override_ctx(CtxComponent,
   204           cw_property_defs = override_ctx(CtxComponent,
   205                                           vocabulary=[list of contexts])
   205                                           vocabulary=[list of contexts])
   206           context = 'my default context'
   206           context = 'my default context'
   207 
   207 
   208     You can configure default component's context by simply giving appropriate
   208     You can configure a component's default context by simply giving an
   209     value to the `context` class attribute, as seen above.
   209     appropriate value to the `context` class attribute, as seen above.
   210     """
   210     """
   211     __registry__ = 'ctxcomponents'
   211     __registry__ = 'ctxcomponents'
   212     __select__ = ~no_cnx()
   212     __select__ = ~no_cnx()
   213 
   213 
   214     categories_in_order = ()
   214     categories_in_order = ()
   288             items = self.items
   288             items = self.items
   289         assert items
   289         assert items
   290         w(u'<ul class="%s">' % klass)
   290         w(u'<ul class="%s">' % klass)
   291         for item in items:
   291         for item in items:
   292             if hasattr(item, 'render'):
   292             if hasattr(item, 'render'):
   293                 item.render(w) # XXX display <li> by itself
   293                 item.render(w) # XXX displays <li> by itself
   294             else:
   294             else:
   295                 w(u'<li>')
   295                 w(u'<li>')
   296                 w(item)
   296                 w(item)
   297                 w(u'</li>')
   297                 w(u'</li>')
   298         w(u'</ul>')
   298         w(u'</ul>')