[Cubicweb] usage of baseviews

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Sep 20 15:22:51 CEST 2010


On 19 septembre 18:31, Alexandre Fayolle wrote:
> On Saturday 18 September 2010 10:18:26 Alexandre Fayolle wrote:
> > Hello,
> > 
> > I'm browsing the cubicweb.web.views.baseviews module and I'm wondering what
> > are the use cases / specifications for the following views:
> > 
> > * OneLineView
> > * TextView
> > * InContextTextView
> > * OutOfContextTextView
> > * InContextView
> > * OutOfContextView
> > * ListView
> > * SimpleListView
> > 
> > Also what is the semantic of the redirect_vid attribute : I found no
> > mention of this in cubicweb.view, and it is not clear to me what it is
> > used for.
> 
> http://docs.cubicweb.org/devweb/views/baseviews.html gives some answers.

* InContext/OutOfContext: some entities make sense in the context of 
  another entity. For instance, the Version of a Project in forge.
  So one may expect that 'incontext' will be called when display a version
  from within the context of a project, while 'outofcontext"' will be called 
  in other cases. In our example, the 'incontext' view of the version would
  be something like '0.1.2', while the 'outofcontext' view would include the
  project name, e.g. 'baz 0.1.2' (since only a version number without the 
  associated project doesn't make sense if you don't know yet that you're
  talking about the famous 'baz' project. CW tries to make guess and call
  'incontext'/'outofcontext' nicely. When it can't know, the 'oneline' view
  should be used.

* there is a variant of 'incontext' / 'outofcontext' view to be used when
  generating raw text, not html (for notifications for instance).

* the 'list' view will generate html like 

    <ul class="section">
      <li>"result of 'subvid' view for a row</li>
      ...
    </ul>

  the 'simplelist' view is not 'ul' based, and rely on div behaviour to
  separate items. html will look like

   <div class="section">"result of 'subvid' view for a row</div>
   ...

  It relies on base View class implementation of the 'call' method to insert
  those <div>.

  Also, you can give to both views a 'subvid' arguments, telling the view
  to use of each item in the list. When not specified, the value of the
  'redirect_vid' attribute of ListItemView (for 'listview') of of SimpleListView
  will be used. This default to 'outofcontext' for 'list' / 'incontext' for 
  'simplelist'
  

Hope things get cleared. Another snippet that should goes in the book...
-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org




More information about the Cubicweb mailing list