# HG changeset patch # User Sylvain Thénault # Date 1295858454 -3600 # Node ID 7c59d513883e2323804ade7596591906b3b5aeac # Parent 0e8fc441b38b5a2489e430bf52034d22f31de2fe update code sample to 3.10 api diff -r 0e8fc441b38b -r 7c59d513883e doc/book/en/tutorials/advanced/part04_ui-base.rst --- a/doc/book/en/tutorials/advanced/part04_ui-base.rst Mon Jan 24 09:17:11 2011 +0100 +++ b/doc/book/en/tutorials/advanced/part04_ui-base.rst Mon Jan 24 09:40:54 2011 +0100 @@ -112,8 +112,8 @@ .. sourcecode:: python from cubicweb.selectors import is_instance - from cubicweb.web import box - from cubicweb.web.views import basetemplates, error + from cubicweb.web import component + from cubicweb.web.views import error class FourOhFour(error.FourOhFour): __select__ = error.FourOhFour.__select__ & anonymous_user() @@ -122,19 +122,19 @@ self.w(u"

%s

" % self._cw._('this resource does not exist')) self.w(u"

%s

" % self._cw._('have you tried to login?')) - class LoginBox(box.BoxTemplate, basetemplates.LogFormView): + + class LoginBox(component.CtxComponent): """display a box containing links to all startup views""" __regid__ = 'sytweb.loginbox' - __select__ = box.BoxTemplate.__select__ & anonymous_user() + __select__ = component.CtxComponent.__select__ & anonymous_user() title = _('Authenticate yourself') order = 70 - def call(self, **kwargs): - self.w(u'
%s
' % self.title) - self.w(u'') + def render_body(self, w): + cw = self._cw + form = cw.vreg['forms'].select('logform', cw) + form.render(w=w, table_class='', display_progress_div=False) The first class provides a new specific implementation of the default page you get on 404 error, to display an adapted message to anonymous user. @@ -147,11 +147,9 @@ such case (hence the object won't be selectable) The second class defines a simple box, that will be displayed by default with -boxes in the left column, thanks to default `box.BoxTemplate`'selector. The HTML -is written to match default CubicWeb boxes style. To get the actual login form, -we inherit from the `LogFormView` view which provides a `login_form` method -(handling some stuff under the cover for us, hence the multiple inheritance), that -we simply have to call to get the form's HTML. +boxes in the left column, thanks to default :class:`component.CtxComponent` +selector. The HTML is written to match default CubicWeb boxes style. The code +fetch the actual login form and render it. .. figure:: ../../images/tutos-photowebsite_login-box.png