view.py
changeset 2819 b864288fd316
parent 2818 326375561412
child 2822 f26578339214
equal deleted inserted replaced
2818:326375561412 2819:b864288fd316
    15 from logilab.mtconverter import xml_escape
    15 from logilab.mtconverter import xml_escape
    16 from rql import nodes
    16 from rql import nodes
    17 
    17 
    18 from cubicweb import NotAnEntity
    18 from cubicweb import NotAnEntity
    19 from cubicweb.selectors import yes, non_final_entity, nonempty_rset, none_rset
    19 from cubicweb.selectors import yes, non_final_entity, nonempty_rset, none_rset
    20 from cubicweb.selectors import require_group_compat, accepts_compat
       
    21 from cubicweb.appobject import AppObject
    20 from cubicweb.appobject import AppObject
    22 from cubicweb.utils import UStringIO, HTMLStream
    21 from cubicweb.utils import UStringIO, HTMLStream
    23 from cubicweb.schema import display_name
    22 from cubicweb.schema import display_name
    24 
    23 
    25 # robots control
    24 # robots control
    91     At instantiation time, the standard `req`, `rset`, and `cursor`
    90     At instantiation time, the standard `req`, `rset`, and `cursor`
    92     attributes are added and the `w` attribute will be set at rendering
    91     attributes are added and the `w` attribute will be set at rendering
    93     time to a write function to use.
    92     time to a write function to use.
    94     """
    93     """
    95     __registry__ = 'views'
    94     __registry__ = 'views'
    96     registered = require_group_compat(AppObject.registered)
       
    97 
    95 
    98     templatable = True
    96     templatable = True
    99     need_navigation = True
    97     need_navigation = True
   100     # content_type = 'application/xhtml+xml' # text/xhtml'
    98     # content_type = 'application/xhtml+xml' # text/xhtml'
   101     binary = False
    99     binary = False
   328 # concrete views base classes #################################################
   326 # concrete views base classes #################################################
   329 
   327 
   330 class EntityView(View):
   328 class EntityView(View):
   331     """base class for views applying on an entity (i.e. uniform result set)"""
   329     """base class for views applying on an entity (i.e. uniform result set)"""
   332     __select__ = non_final_entity()
   330     __select__ = non_final_entity()
   333     registered = accepts_compat(View.registered)
       
   334 
       
   335     category = 'entityview'
   331     category = 'entityview'
   336 
   332 
   337 
   333 
   338 class StartupView(View):
   334 class StartupView(View):
   339     """base class for views which doesn't need a particular result set to be
   335     """base class for views which doesn't need a particular result set to be
   340     displayed (so they can always be displayed !)
   336     displayed (so they can always be displayed !)
   341     """
   337     """
   342     __select__ = none_rset()
   338     __select__ = none_rset()
   343     registered = require_group_compat(View.registered)
       
   344 
   339 
   345     category = 'startupview'
   340     category = 'startupview'
   346 
   341 
   347     def html_headers(self):
   342     def html_headers(self):
   348         """return a list of html headers (eg something to be inserted between
   343         """return a list of html headers (eg something to be inserted between
   411 class MainTemplate(View):
   406 class MainTemplate(View):
   412     """main template are primary access point to render a full HTML page.
   407     """main template are primary access point to render a full HTML page.
   413     There is usually at least a regular main template and a simple fallback
   408     There is usually at least a regular main template and a simple fallback
   414     one to display error if the first one failed
   409     one to display error if the first one failed
   415     """
   410     """
   416     registered = require_group_compat(View.registered)
       
   417 
   411 
   418     @property
   412     @property
   419     def doctype(self):
   413     def doctype(self):
   420         if self.req.xhtml_browser():
   414         if self.req.xhtml_browser():
   421             return STRICT_DOCTYPE
   415             return STRICT_DOCTYPE