doc/book/en/devweb/views/primary.rst
changeset 8190 2a3c1b787688
parent 8032 bcb87336c7d2
child 8665 e65af61bde7d
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
   174 override the method ``cell_call()`` of the view ``primary`` in
   174 override the method ``cell_call()`` of the view ``primary`` in
   175 ``BlogDemo/views.py``.
   175 ``BlogDemo/views.py``.
   176 
   176 
   177 .. sourcecode:: python
   177 .. sourcecode:: python
   178 
   178 
   179    from cubicweb.selectors import is_instance
   179    from cubicweb.predicates import is_instance
   180    from cubicweb.web.views.primary import Primaryview
   180    from cubicweb.web.views.primary import Primaryview
   181 
   181 
   182    class BlogEntryPrimaryView(PrimaryView):
   182    class BlogEntryPrimaryView(PrimaryView):
   183        __select__ = PrimaryView.__select__ & is_instance('BlogEntry')
   183        __select__ = PrimaryView.__select__ & is_instance('BlogEntry')
   184 
   184 
   204 Let us now improve the primary view of a blog
   204 Let us now improve the primary view of a blog
   205 
   205 
   206 .. sourcecode:: python
   206 .. sourcecode:: python
   207 
   207 
   208  from logilab.mtconverter import xml_escape
   208  from logilab.mtconverter import xml_escape
   209  from cubicweb.selectors import is_instance, one_line_rset
   209  from cubicweb.predicates import is_instance, one_line_rset
   210  from cubicweb.web.views.primary import Primaryview
   210  from cubicweb.web.views.primary import Primaryview
   211 
   211 
   212  class BlogPrimaryView(PrimaryView):
   212  class BlogPrimaryView(PrimaryView):
   213      __regid__ = 'primary'
   213      __regid__ = 'primary'
   214      __select__ = PrimaryView.__select__ & is_instance('Blog')
   214      __select__ = PrimaryView.__select__ & is_instance('Blog')