# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1234973572 -3600 # Node ID 9cd49a910fce2494c8e3acef7351e728fd08c047 # Parent 69c623aa39edf572fc42be7e38db3a1d308d2fea kill Template class and 'templates' registry diff -r 69c623aa39ed -r 9cd49a910fce cwvreg.py --- a/cwvreg.py Wed Feb 18 16:55:01 2009 +0100 +++ b/cwvreg.py Wed Feb 18 17:12:52 2009 +0100 @@ -198,7 +198,7 @@ and returning the output as a string instead of requiring the [w]rite method as argument """ - res = self.render('templates', oid, req, **context) + res = self.render('views', oid, req, **context) if isinstance(res, unicode): return res.encode(req.encoding) assert isinstance(res, str) diff -r 69c623aa39ed -r 9cd49a910fce view.py --- a/view.py Wed Feb 18 16:55:01 2009 +0100 +++ b/view.py Wed Feb 18 17:12:52 2009 +0100 @@ -9,6 +9,7 @@ from cStringIO import StringIO +from logilab.common.deprecation import obsolete from logilab.mtconverter import html_escape from cubicweb import NotAnEntity, NoSelectableObject @@ -91,8 +92,9 @@ attributes are added and the `w` attribute will be set at rendering time to a write function to use. """ + __registry__ = 'views' __registerer__ = priority_registerer - __registry__ = 'views' + registered = require_group_compat(AppRsetObject.registered) templatable = True need_navigation = True @@ -205,8 +207,8 @@ self.req.set_content_type(self.content_type) # view utilities ########################################################## - - def view(self, __vid, rset, __fallback_vid=None, **kwargs): + + def view(self, __vid, rset=None, __fallback_vid=None, **kwargs): """shortcut to self.vreg.render method avoiding to pass self.req""" try: view = self.vreg.select_view(__vid, self.req, rset, **kwargs) @@ -215,7 +217,10 @@ raise view = self.vreg.select_view(__fallback_vid, self.req, rset, **kwargs) return view.dispatch(**kwargs) - + + # XXX Template bw compat + template = obsolete('.template is deprecated, use .view')(view) + def wview(self, __vid, rset, __fallback_vid=None, **kwargs): """shortcut to self.view method automatically passing self.w as argument """ @@ -414,27 +419,13 @@ # concrete template base classes ############################################## -class Template(View): - """a template is almost like a view, except that by default a template - is only used globally (i.e. no result set adaptation) - """ - __registry__ = 'templates' - __select__ = yes() - - registered = require_group_compat(View.registered) - - def template(self, oid, **kwargs): - """shortcut to self.registry.render method on the templates registry""" - w = kwargs.pop('w', self.w) - self.vreg.render('templates', oid, self.req, w=w, **kwargs) - - -class MainTemplate(Template): +class MainTemplate(View): """main template are primary access point to render a full HTML page. There is usually at least a regular main template and a simple fallback one to display error if the first one failed """ base_doctype = STRICT_DOCTYPE + registered = require_group_compat(View.registered) @property def doctype(self): diff -r 69c623aa39ed -r 9cd49a910fce web/box.py --- a/web/box.py Wed Feb 18 16:55:01 2009 +0100 +++ b/web/box.py Wed Feb 18 17:12:52 2009 +0100 @@ -12,8 +12,9 @@ from cubicweb import Unauthorized, role as get_role from cubicweb.selectors import (one_line_rset, primary_view, match_context_prop, abstract_has_related_entities, - accepts_compat, has_relation_compat, condition_compat) -from cubicweb.view import Template, ReloadableMixIn + accepts_compat, has_relation_compat, + condition_compat, require_group_compat) +from cubicweb.view import View, ReloadableMixIn from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, RawBoxItem, BoxSeparator) @@ -22,7 +23,7 @@ _ = unicode -class BoxTemplate(Template): +class BoxTemplate(View): """base template for boxes, usually a (contextual) list of possible actions. Various classes attributes may be used to control the box @@ -38,6 +39,7 @@ """ __registry__ = 'boxes' __select__ = match_context_prop() + registered = require_group_compat(View.registered) categories_in_order = () property_defs = { diff -r 69c623aa39ed -r 9cd49a910fce web/views/basetemplates.py --- a/web/views/basetemplates.py Wed Feb 18 16:55:01 2009 +0100 +++ b/web/views/basetemplates.py Wed Feb 18 17:12:52 2009 +0100 @@ -11,7 +11,7 @@ from logilab.mtconverter import html_escape from cubicweb import NoSelectableObject, ObjectNotFound -from cubicweb.view import Template, MainTemplate, NOINDEX, NOFOLLOW +from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW from cubicweb.utils import make_uid, UStringIO from cubicweb.web.views.baseviews import vid_from_rset @@ -38,7 +38,7 @@ w(NOINDEX) w(NOFOLLOW) w(u'\n'.join(additional_headers) + u'\n') - self.template('htmlheader', rset=self.rset) + self.view('htmlheader', rset=self.rset) w(u'
\n') @@ -185,7 +185,7 @@ self.w(u' | \n') self.nav_column(view, 'right') self.w(u'