view.py
branchtls-sprint
changeset 1144 654047cd0c30
parent 1143 8d097defbf2c
child 1181 620ec8e6ae19
equal deleted inserted replaced
1143:8d097defbf2c 1144:654047cd0c30
   204     def set_request_content_type(self):
   204     def set_request_content_type(self):
   205         """set the content type returned by this view"""
   205         """set the content type returned by this view"""
   206         self.req.set_content_type(self.content_type)
   206         self.req.set_content_type(self.content_type)
   207 
   207 
   208     # view utilities ##########################################################
   208     # view utilities ##########################################################
   209         
       
   210     def view(self, __vid, rset=None, __fallback_vid=None, **kwargs):
       
   211         """shortcut to self.vreg.render method avoiding to pass self.req"""
       
   212         try:
       
   213             view = self.vreg.select_view(__vid, self.req, rset, **kwargs)
       
   214         except NoSelectableObject:
       
   215             if __fallback_vid is None:
       
   216                 raise
       
   217             view = self.vreg.select_view(__fallback_vid, self.req, rset, **kwargs)
       
   218         return view.dispatch(**kwargs)
       
   219     
   209     
   220     def wview(self, __vid, rset, __fallback_vid=None, **kwargs):
   210     def wview(self, __vid, rset, __fallback_vid=None, **kwargs):
   221         """shortcut to self.view method automatically passing self.w as argument
   211         """shortcut to self.view method automatically passing self.w as argument
   222         """
   212         """
   223         self.view(__vid, rset, __fallback_vid, w=self.w, **kwargs)
   213         self.view(__vid, rset, __fallback_vid, w=self.w, **kwargs)
   315                 label = display_name(self.req, label)
   305                 label = display_name(self.req, label)
   316             w(u'<span class="label">%s</span>' % label)
   306             w(u'<span class="label">%s</span>' % label)
   317         w(u'<div class="field">%s</div>' % value)
   307         w(u'<div class="field">%s</div>' % value)
   318         if row:
   308         if row:
   319             w(u'</div>')
   309             w(u'</div>')
       
   310             
       
   311     def initialize_varmaker(self):
       
   312         varmaker = self.req.get_page_data('rql_varmaker')
       
   313         if varmaker is None:
       
   314             varmaker = self.req.varmaker
       
   315             self.req.set_page_data('rql_varmaker', varmaker)
       
   316         self.varmaker = varmaker
       
   317         
   320 
   318 
   321 
   319 
   322 # concrete views base classes #################################################
   320 # concrete views base classes #################################################
   323 
   321 
   324 class EntityView(View):
   322 class EntityView(View):