[api] work in progress, use __regid__, cw_*, etc.
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 23 Sep 2009 19:40:19 +0200
changeset 3451 6b46d73823f5
parent 3448 495862266785
child 3452 7c008d31ef1f
[api] work in progress, use __regid__, cw_*, etc.
common/mixins.py
cwvreg.py
entities/__init__.py
entities/lib.py
entities/test/unittest_base.py
entities/wfobjs.py
view.py
web/action.py
web/box.py
web/component.py
web/facet.py
web/form.py
web/formfields.py
web/formwidgets.py
web/httpcache.py
web/test/unittest_viewselector.py
web/views/__init__.py
web/views/actions.py
web/views/ajaxedit.py
web/views/authentication.py
web/views/autoform.py
web/views/basecomponents.py
web/views/basecontrollers.py
web/views/basetemplates.py
web/views/baseviews.py
web/views/bookmark.py
web/views/boxes.py
web/views/calendar.py
web/views/csvexport.py
web/views/cwproperties.py
web/views/cwuser.py
web/views/debug.py
web/views/editcontroller.py
web/views/editforms.py
web/views/editviews.py
web/views/emailaddress.py
web/views/embedding.py
web/views/error.py
web/views/facets.py
web/views/formrenderers.py
web/views/forms.py
web/views/ibreadcrumbs.py
web/views/idownloadable.py
web/views/igeocodable.py
web/views/iprogress.py
web/views/isioc.py
web/views/magicsearch.py
web/views/management.py
web/views/massmailing.py
web/views/navigation.py
web/views/old_calendar.py
web/views/owl.py
web/views/plots.py
web/views/primary.py
web/views/pyviews.py
web/views/schema.py
web/views/sparql.py
web/views/startup.py
web/views/tableview.py
web/views/tabs.py
web/views/timeline.py
web/views/timetable.py
web/views/treeview.py
web/views/urlrewrite.py
web/views/vcard.py
web/views/wdoc.py
web/views/workflow.py
web/views/xbel.py
web/views/xmlrss.py
--- a/common/mixins.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/common/mixins.py	Wed Sep 23 19:40:19 2009 +0200
@@ -38,7 +38,7 @@
                            entities=entities)
         if entities:
             return [e for e in res if e.e_schema != self.e_schema]
-        return res.filtered_rset(lambda x: x.e_schema != self.e_schema, self.col)
+        return res.filtered_rset(lambda x: x.e_schema != self.e_schema, self.cw_col)
 
     def same_type_children(self, entities=True):
         """return children entities of the same type as this entity.
@@ -50,7 +50,7 @@
                            entities=entities)
         if entities:
             return [e for e in res if e.e_schema == self.e_schema]
-        return res.filtered_rset(lambda x: x.e_schema == self.e_schema, self.col)
+        return res.filtered_rset(lambda x: x.e_schema == self.e_schema, self.cw_col)
 
     def iterchildren(self, _done=None):
         if _done is None:
@@ -249,7 +249,7 @@
 
 class TreePathMixIn(object):
     """a recursive path view"""
-    id = 'path'
+    __regid__ = 'path'
     item_vid = 'oneline'
     separator = u'&#160;&gt;&#160;'
 
--- a/cwvreg.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/cwvreg.py	Wed Sep 23 19:40:19 2009 +0200
@@ -210,7 +210,7 @@
 
     def possible_actions(self, req, rset=None, **kwargs):
         if rset is None:
-            actions = self.possible_vobjects(req, rset=rset, **kwargs)
+            actions = self.poss_visible_objects(req, rset=rset, **kwargs)
         else:
             actions = rset.possible_actions(**kwargs) # cached implementation
         result = {}
--- a/entities/__init__.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/entities/__init__.py	Wed Sep 23 19:40:19 2009 +0200
@@ -82,7 +82,7 @@
 
     def dc_date(self, date_format=None):# XXX default to ISO 8601 ?
         """return latest modification date of this entity"""
-        return self.format_date(self.modification_date, date_format=date_format)
+        return self._cw.format_date(self.modification_date, date_format=date_format)
 
     def dc_type(self, form=''):
         """return the display name for the type of this entity (translated)"""
@@ -95,7 +95,7 @@
         for rschema, attrschema in self.e_schema.attribute_definitions():
             if rschema.rproperty(self.e_schema, attrschema,
                                  'internationalizable'):
-                return self._cw._(self.req.user.property_value('ui.language'))
+                return self._cw._(self._cw.user.property_value('ui.language'))
         return self._cw._(self._cw.vreg.property_value('ui.language'))
 
     @property
@@ -125,7 +125,7 @@
                 if 'vtitle' in self._cw.form:
                     # embeding for instance
                     path.append( self._cw.form['vtitle'] )
-            elif view.id != 'primary' and hasattr(view, 'title'):
+            elif view.__regid__ != 'primary' and hasattr(view, 'title'):
                 path.append( self._cw._(view.title) )
         return path
 
--- a/entities/lib.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/entities/lib.py	Wed Sep 23 19:40:19 2009 +0200
@@ -51,7 +51,7 @@
         if not ('sender' in subjrels and 'recipients' in subjrels):
             return
         rql = 'DISTINCT Any X, S, D ORDERBY D DESC WHERE X sender Y or X recipients Y, X subject S, X date D, Y eid %(y)s'
-        rset = self.req.execute(rql, {'y': self.eid}, 'y')
+        rset = self._cw.execute(rql, {'y': self.eid}, 'y')
         if skipeids is None:
             skipeids = set()
         for i in xrange(len(rset)):
@@ -88,13 +88,13 @@
     fetch_attrs, fetch_order = fetch_config(['title', 'path'])
 
     def actual_url(self):
-        url = self.req.build_url(self.path)
+        url = self._cw.build_url(self.path)
         if self.title:
             urlparts = list(urlsplit(url))
             if urlparts[3]:
-                urlparts[3] += '&vtitle=%s' % self.req.url_quote(self.title)
+                urlparts[3] += '&vtitle=%s' % self._cw.url_quote(self.title)
             else:
-                urlparts[3] = 'vtitle=%s' % self.req.url_quote(self.title)
+                urlparts[3] = 'vtitle=%s' % self._cw.url_quote(self.title)
             url = urlunsplit(urlparts)
         return url
 
@@ -113,7 +113,7 @@
 
     def dc_description(self, format='text/plain'):
         try:
-            return self.req._(self.vreg.property_info(self.pkey)['help'])
+            return self._cw._(self.vreg.property_info(self.pkey)['help'])
         except UnknownProperty:
             return u''
 
@@ -130,7 +130,7 @@
     fetch_attrs, fetch_order = fetch_config(['name'])
 
     def touch(self):
-        self.req.execute('SET X timestamp %(t)s WHERE X eid %(x)s',
+        self._cw.execute('SET X timestamp %(t)s WHERE X eid %(x)s',
                          {'t': datetime.now(), 'x': self.eid}, 'x')
 
     def valid(self, date):
--- a/entities/test/unittest_base.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/entities/test/unittest_base.py	Wed Sep 23 19:40:19 2009 +0200
@@ -142,7 +142,7 @@
                 self.assertEquals(eclass.__bases__[0].__bases__, (Foo,))
         # check Division eclass is still selected for plain Division entities
         eclass = self.select_eclass('Division')
-        self.assertEquals(eclass.id, 'Division')
+        self.assertEquals(eclass.__regid__, 'Division')
 
 if __name__ == '__main__':
     unittest_main()
--- a/entities/wfobjs.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/entities/wfobjs.py	Wed Sep 23 19:40:19 2009 +0200
@@ -408,11 +408,11 @@
             return wfrset.get_entity(0, 0)
         if len(wfrset) > 1:
             for wf in wfrset.entities():
-                if wf.is_default_workflow_of(self.id):
+                if wf.is_default_workflow_of(self.__regid__):
                     return wf
-            self.warning("can't find default workflow for %s", self.id)
+            self.warning("can't find default workflow for %s", self.__regid__)
         else:
-            self.warning("can't find any workflow for %s", self.id)
+            self.warning("can't find any workflow for %s", self.__regid__)
         return None
 
     def possible_transitions(self):
@@ -452,7 +452,7 @@
         """
         assert self.current_workflow
         tr = self.current_workflow.transition_by_name(trname)
-        assert tr is not None, 'not a %s transition: %s' % (self.id, trname)
+        assert tr is not None, 'not a %s transition: %s' % (self.__regid__, trname)
         return self._add_trinfo(comment, commentformat, tr.eid)
 
     def change_state(self, statename, comment=None, commentformat=None, tr=None):
@@ -471,7 +471,7 @@
             else:
                 state = self.current_workflow.state_by_name(statename)
             if state is None:
-                raise WorkflowException('not a %s state: %s' % (self.id,
+                raise WorkflowException('not a %s state: %s' % (self.__regid__,
                                                                 statename))
             stateeid = state.eid
         # XXX try to find matching transition?
--- a/view.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/view.py	Wed Sep 23 19:40:19 2009 +0200
@@ -106,7 +106,7 @@
 
     @property
     def content_type(self):
-        return self.req.html_content_type()
+        return self._cw.html_content_type()
 
     def set_stream(self, w=None):
         if self.w is not None:
@@ -155,8 +155,8 @@
         """
         from cubicweb.ext.tal import CubicWebContext
         context = CubicWebContext()
-        context.update({'self': self, 'rset': self.rset, '_' : self.req._,
-                        'req': self.req, 'user': self.req.user})
+        context.update({'self': self, 'rset': self.cw_rset, '_' : self._cw._,
+                        'req': self._cw, 'user': self._cw.user})
         context.update(variables)
         output = UStringIO()
         template.expand(context, output)
@@ -175,14 +175,14 @@
 
         Views applicable on None result sets have to override this method
         """
-        rset = self.rset
+        rset = self.cw_rset
         if rset is None:
             raise NotImplementedError, self
         wrap = self.templatable and len(rset) > 1 and self.add_div_section
         for i in xrange(len(rset)):
             if wrap:
                 self.w(u'<div class="section">')
-            self.wview(self.id, rset, row=i, **kwargs)
+            self.wview(self.__regid__, rset, row=i, **kwargs)
             if wrap:
                 self.w(u"</div>")
 
@@ -200,23 +200,23 @@
         return True
 
     def is_primary(self):
-        return self.id == 'primary'
+        return self.__regid__ == 'primary'
 
     def url(self):
         """return the url associated with this view. Should not be
         necessary for non linkable views, but a default implementation
         is provided anyway.
         """
-        rset = self.rset
+        rset = self.cw_rset
         if rset is None:
-            return self.build_url('view', vid=self.id)
+            return self._cw.build_url('view', vid=self.__regid__)
         coltypes = rset.column_types(0)
         if len(coltypes) == 1:
             etype = iter(coltypes).next()
-            if not self.schema.eschema(etype).is_final():
+            if not self._cw.schema.eschema(etype).is_final():
                 if len(rset) == 1:
                     entity = rset.get_entity(0, 0)
-                    return entity.absolute_url(vid=self.id)
+                    return entity.absolute_url(vid=self.__regid__)
             # don't want to generate /<etype> url if there is some restriction
             # on something else than the entity type
             restr = rset.syntax_tree().children[0].where
@@ -226,25 +226,25 @@
             norestriction = (isinstance(restr, nodes.Relation) and
                              restr.is_types_restriction())
             if norestriction:
-                return self.build_url(etype.lower(), vid=self.id)
-        return self.build_url('view', rql=rset.printable_rql(), vid=self.id)
+                return self._cw.build_url(etype.lower(), vid=self.__regid__)
+        return self._cw.build_url('view', rql=rset.printable_rql(), vid=self.__regid__)
 
     def set_request_content_type(self):
         """set the content type returned by this view"""
-        self.req.set_content_type(self.content_type)
+        self._cw.set_content_type(self.content_type)
 
     # view utilities ##########################################################
 
     def wview(self, __vid, rset=None, __fallback_vid=None, **kwargs):
         """shortcut to self.view method automatically passing self.w as argument
         """
-        self.view(__vid, rset, __fallback_vid, w=self.w, **kwargs)
+        self._cw.view(__vid, rset, __fallback_vid, w=self.w, **kwargs)
 
     # XXX Template bw compat
     template = deprecated('[3.4] .template is deprecated, use .view')(wview)
 
     def whead(self, data):
-        self.req.html_headers.write(data)
+        self._cw.html_headers.write(data)
 
     def wdata(self, data):
         """simple helper that escapes `data` and writes into `self.w`"""
@@ -262,34 +262,34 @@
         """returns a title according to the result set - used for the
         title in the HTML header
         """
-        vtitle = self.req.form.get('vtitle')
+        vtitle = self._cw.form.get('vtitle')
         if vtitle:
-            return self.req._(vtitle)
+            return self._cw._(vtitle)
         # class defined title will only be used if the resulting title doesn't
         # seem clear enough
         vtitle = getattr(self, 'title', None) or u''
         if vtitle:
-            vtitle = self.req._(vtitle)
-        rset = self.rset
+            vtitle = self._cw._(vtitle)
+        rset = self.cw_rset
         if rset and rset.rowcount:
             if rset.rowcount == 1:
                 try:
-                    entity = self.complete_entity(0)
+                    entity = rset.complete_entity(0, 0)
                     # use long_title to get context information if any
                     clabel = entity.dc_long_title()
                 except NotAnEntity:
-                    clabel = display_name(self.req, rset.description[0][0])
+                    clabel = display_name(self._cw, rset.description[0][0])
                     clabel = u'%s (%s)' % (clabel, vtitle)
             else :
                 etypes = rset.column_types(0)
                 if len(etypes) == 1:
                     etype = iter(etypes).next()
-                    clabel = display_name(self.req, etype, 'plural')
+                    clabel = display_name(self._cw, etype, 'plural')
                 else :
                     clabel = u'#[*] (%s)' % vtitle
         else:
             clabel = vtitle
-        return u'%s (%s)' % (clabel, self.req.property_value('ui.site-title'))
+        return u'%s (%s)' % (clabel, self._cw.property_value('ui.site-title'))
 
     def output_url_builder( self, name, url, args ):
         self.w(u'<script language="JavaScript"><!--\n' \
@@ -305,7 +305,7 @@
 
     def create_url(self, etype, **kwargs):
         """ return the url of the entity creation form for a given entity type"""
-        return self.req.build_url('add/%s'%etype, **kwargs)
+        return self._cw.build_url('add/%s'%etype, **kwargs)
 
     def field(self, label, value, row=True, show_label=True, w=None, tr=True):
         """ read-only field """
@@ -315,7 +315,7 @@
             w(u'<div class="row">')
         if show_label and label:
             if tr:
-                label = display_name(self.req, label)
+                label = display_name(self._cw, label)
             w(u'<span class="label">%s</span>' % label)
         w(u'<div class="field">%s</div>' % value)
         if row:
@@ -370,11 +370,11 @@
         """override call to execute rql returned by the .startup_rql method if
         necessary
         """
-        if self.rset is None:
-            self.rset = self.req.execute(self.startup_rql())
-        rset = self.rset
+        rset = self.cw_rset
+        if rset is None:
+            rset = self.cw_rset = self._cw.execute(self.startup_rql())
         for i in xrange(len(rset)):
-            self.wview(self.id, rset, row=i, **kwargs)
+            self.wview(self.__regid__, rset, row=i, **kwargs)
 
 
 class AnyRsetView(View):
@@ -385,18 +385,18 @@
 
     def columns_labels(self, mainindex=0, tr=True):
         if tr:
-            translate = lambda val, req=self.req: display_name(req, val)
+            translate = lambda val, req=self._cw: display_name(req, val)
         else:
             translate = lambda val: val
         # XXX [0] because of missing Union support
-        rqlstdescr = self.rset.syntax_tree().get_description(mainindex,
-                                                             translate)[0]
+        rqlstdescr = self.cw_rset.syntax_tree().get_description(mainindex,
+                                                                translate)[0]
         labels = []
         for colindex, label in enumerate(rqlstdescr):
             # compute column header
             if label == 'Any': # find a better label
                 label = ','.join(translate(et)
-                                 for et in self.rset.column_types(colindex))
+                                 for et in self.cw_rset.column_types(colindex))
             labels.append(label)
         return labels
 
@@ -411,7 +411,7 @@
 
     @property
     def doctype(self):
-        if self.req.xhtml_browser():
+        if self._cw.xhtml_browser():
             return STRICT_DOCTYPE
         return STRICT_DOCTYPE_NOEXT
 
@@ -422,7 +422,7 @@
             if self.binary:
                 self._stream = stream = StringIO()
             else:
-                self._stream = stream = HTMLStream(self.req)
+                self._stream = stream = HTMLStream(self._cw)
             w = stream.write
         else:
             stream = None
@@ -447,18 +447,18 @@
         """register the given user callback and return an url to call it ready to be
         inserted in html
         """
-        self.req.add_js('cubicweb.ajax.js')
+        self._cw.add_js('cubicweb.ajax.js')
         if nonify:
             _cb = cb
             def cb(*args):
                 _cb(*args)
-        cbname = self.req.register_onetime_callback(cb, *args)
+        cbname = self._cw.register_onetime_callback(cb, *args)
         return self.build_js(cbname, xml_escape(msg or ''))
 
     def build_update_js_call(self, cbname, msg):
-        rql = xml_escape(self.rset.printable_rql())
+        rql = xml_escape(self.cw_rset.printable_rql())
         return "javascript:userCallbackThenUpdateUI('%s', '%s', '%s', '%s', '%s', '%s')" % (
-            cbname, self.id, rql, msg, self.__registry__, self.div_id())
+            cbname, self.__regid__, rql, msg, self.__registry__, self.div_id())
 
     def build_reload_js_call(self, cbname, msg):
         return "javascript:userCallbackThenReloadPage('%s', '%s')" % (cbname, msg)
@@ -477,8 +477,8 @@
     # XXX huummm, much probably useless
     htmlclass = 'mainRelated'
     def div_class(self):
-        return '%s %s' % (self.htmlclass, self.id)
+        return '%s %s' % (self.htmlclass, self.__regid__)
 
-    # XXX a generic '%s%s' % (self.id, self.__registry__.capitalize()) would probably be nicer
+    # XXX a generic '%s%s' % (self.__regid__, self.__registry__.capitalize()) would probably be nicer
     def div_id(self):
-        return '%sComponent' % self.id
+        return '%sComponent' % self.__regid__
--- a/web/action.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/action.py	Wed Sep 23 19:40:19 2009 +0200
@@ -49,13 +49,13 @@
         raise NotImplementedError
 
     def html_class(self):
-        if self.req.selected(self.url()):
+        if self._cw.selected(self.url()):
             return 'selected'
         if self.category:
             return 'box' + self.category.capitalize()
 
     def build_action(self, title, path, **kwargs):
-        return UnregisteredAction(self.req, self.rset, title, path, **kwargs)
+        return UnregisteredAction(self._cw, self.cw_rset, title, path, **kwargs)
 
 
 class UnregisteredAction(Action):
@@ -89,9 +89,9 @@
     submenu = 'addrelated'
 
     def url(self):
-        current_entity = self.rset.get_entity(self.row or 0, self.col or 0)
+        current_entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         linkto = '%s:%s:%s' % (self.rtype, current_entity.eid, target(self))
         return self.build_url('add/%s' % self.etype, __linkto=linkto,
                               __redirectpath=current_entity.rest_path(), # should not be url quoted!
-                              __redirectvid=self.req.form.get('__redirectvid', ''))
+                              __redirectvid=self._cw.form.get('__redirectvid', ''))
 
--- a/web/box.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/box.py	Wed Sep 23 19:40:19 2009 +0200
@@ -77,18 +77,18 @@
         return self.box_action(self._action(title, path, **kwargs))
 
     def _action(self, title, path, **kwargs):
-        return UnregisteredAction(self.req, self.rset, title, path, **kwargs)
+        return UnregisteredAction(self._cw, self.cw_rset, title, path, **kwargs)
 
     # formating callbacks
 
     def boxitem_link_tooltip(self, action):
-        if action.id:
-            return u'keyword: %s' % action.id
+        if action.__regid__:
+            return u'keyword: %s' % action.__regid__
         return u''
 
     def box_action(self, action):
         cls = getattr(action, 'html_class', lambda: None)() or self.htmlitemclass
-        return BoxLink(action.url(), self.req._(action.title),
+        return BoxLink(action.url(), self._cw._(action.title),
                        cls, self.boxitem_link_tooltip(action))
 
 
@@ -105,18 +105,18 @@
     rql  = None
 
     def to_display_rql(self):
-        assert self.rql is not None, self.id
+        assert self.rql is not None, self.__regid__
         return (self.rql,)
 
     def call(self, **kwargs):
         try:
-            rset = self.req.execute(*self.to_display_rql())
+            rset = self._cw.execute(*self.to_display_rql())
         except Unauthorized:
             # can't access to something in the query, forget this box
             return
         if len(rset) == 0:
             return
-        box = BoxWidget(self.req._(self.title), self.id)
+        box = BoxWidget(self._cw._(self.title), self.__regid__)
         for i, (teid, tname) in enumerate(rset):
             entity = rset.get_entity(i, 0)
             box.append(self.mk_action(tname, entity.absolute_url()))
@@ -129,8 +129,8 @@
     """
 
     def to_display_rql(self):
-        assert self.rql is not None, self.id
-        return (self.rql, {'x': self.req.user.eid}, 'x')
+        assert self.rql is not None, self.__regid__
+        return (self.rql, {'x': self._cw.user.eid}, 'x')
 
 
 class EntityBoxTemplate(BoxTemplate):
@@ -147,12 +147,12 @@
     __select__ = EntityBoxTemplate.__select__ & partial_has_related_entities()
 
     def cell_call(self, row, col, **kwargs):
-        entity = self.rset.get_entity(row, col)
-        limit = self.req.property_value('navigation.related-limit') + 1
+        entity = self.cw_rset.get_entity(row, col)
+        limit = self._cw.property_value('navigation.related-limit') + 1
         role = get_role(self)
         self.w(u'<div class="sideBox">')
         self.wview('sidebox', entity.related(self.rtype, role, limit=limit),
-                   title=display_name(self.req, self.rtype, role))
+                   title=display_name(self._cw, self.rtype, role))
         self.w(u'</div>')
 
 
@@ -165,9 +165,9 @@
     """
 
     def cell_call(self, row, col, view=None, **kwargs):
-        self.req.add_js('cubicweb.ajax.js')
-        entity = self.rset.get_entity(row, col)
-        box = SideBoxWidget(display_name(self.req, self.rtype), self.id)
+        self._cw.add_js('cubicweb.ajax.js')
+        entity = self.cw_rset.get_entity(row, col)
+        box = SideBoxWidget(display_name(self._cw, self.rtype), self.__regid__)
         related = self.related_boxitems(entity)
         unrelated = self.unrelated_boxitems(entity)
         box.extend(related)
@@ -177,7 +177,7 @@
         box.render(self.w)
 
     def div_id(self):
-        return self.id
+        return self.__regid__
 
     def box_item(self, entity, etarget, rql, label):
         """builds HTML link to edit relation between `entity` and `etarget`
@@ -218,12 +218,12 @@
             return entity.unrelated(self.rtype, self.etype, get_role(self)).entities()
         # in other cases, use vocabulary functions
         entities = []
-        form = self.vreg['forms'].select('edition', self.req, rset=self.rset,
-                                         row=self.row or 0)
+        form = self.vreg['forms'].select('edition', self._cw, rset=self.cw_rset,
+                                         row=self.cw_row or 0)
         field = form.field_by_name(self.rtype, get_role(self), entity.e_schema)
         for _, eid in form.form_field_vocabulary(field):
             if eid is not None:
-                rset = self.req.eid_rset(eid)
+                rset = self._cw.eid_rset(eid)
                 entities.append(rset.get_entity(0, 0))
         return entities
 
--- a/web/component.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/component.py	Wed Sep 23 19:40:19 2009 +0200
@@ -86,10 +86,10 @@
         except AttributeError:
             page_size = self.extra_kwargs.get('page_size')
             if page_size is None:
-                if 'page_size' in self.req.form:
-                    page_size = int(self.req.form['page_size'])
+                if 'page_size' in self._cw.form:
+                    page_size = int(self._cw.form['page_size'])
                 else:
-                    page_size = self.req.property_value(self.page_size_property)
+                    page_size = self._cw.property_value(self.page_size_property)
             self._page_size = page_size
             return page_size
 
@@ -100,8 +100,8 @@
 
     def page_boundaries(self):
         try:
-            stop = int(self.req.form[self.stop_param]) + 1
-            start = int(self.req.form[self.start_param])
+            stop = int(self._cw.form[self.stop_param]) + 1
+            start = int(self._cw.form[self.start_param])
         except KeyError:
             start, stop = 0, self.page_size
         self.starting_from = start
@@ -117,7 +117,7 @@
         params = merge_dicts(params, {self.start_param : start,
                                       self.stop_param : stop,})
         if path == 'json':
-            rql = params.pop('rql', self.rset.printable_rql())
+            rql = params.pop('rql', self.cw_rset.printable_rql())
             # latest 'true' used for 'swap' mode
             url = 'javascript: replacePageChunk(%s, %s, %s, %s, true)' % (
                 dumps(params.get('divid', 'paginated-content')),
@@ -163,15 +163,15 @@
     def cell_call(self, row, col, view=None):
         rql = self.rql()
         if rql is None:
-            entity = self.rset.get_entity(row, col)
+            entity = self.cw_rset.get_entity(row, col)
             rset = entity.related(self.rtype, role(self))
         else:
-            eid = self.rset[row][col]
-            rset = self.req.execute(self.rql(), {'x': eid}, 'x')
+            eid = self.cw_rset[row][col]
+            rset = self._cw.execute(self.rql(), {'x': eid}, 'x')
         if not rset.rowcount:
             return
         self.w(u'<div class="%s">' % self.div_class())
-        self.wview(self.vid, rset, title=self.req._(self.title).capitalize())
+        self.wview(self.vid, rset, title=self._cw._(self.title).capitalize())
         self.w(u'</div>')
 
 
--- a/web/facet.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/facet.py	Wed Sep 23 19:40:19 2009 +0200
@@ -282,7 +282,7 @@
         self.filtered_variable = filtered_variable
 
     def init_from_rset(self):
-        self.rqlst = self.rset.syntax_tree().children[0]
+        self.rqlst = self.cw_rset.syntax_tree().children[0]
 
     def init_from_form(self, rqlst):
         self.rqlst = rqlst
@@ -290,7 +290,7 @@
     @property
     def operator(self):
         # OR between selected values by default
-        return self.req.form.get(self.id + '_andor', 'OR')
+        return self._cw.form.get(self.__regid__ + '_andor', 'OR')
 
     def get_widget(self):
         """return the widget instance to use to display this facet
@@ -315,12 +315,12 @@
         if len(vocab) <= 1:
             return None
         wdg = FacetVocabularyWidget(self)
-        selected = frozenset(typed_eid(eid) for eid in self.req.list_form_param(self.id))
+        selected = frozenset(typed_eid(eid) for eid in self._cw.list_form_param(self.__regid__))
         for label, value in vocab:
             if value is None:
                 wdg.append(FacetSeparator(label))
             else:
-                wdg.append(FacetItem(self.req, label, value, value in selected))
+                wdg.append(FacetItem(self._cw, label, value, value in selected))
         return wdg
 
     def vocabulary(self):
@@ -339,7 +339,7 @@
 
     def rqlexec(self, rql, args=None, cachekey=None):
         try:
-            return self.req.execute(rql, args, cachekey)
+            return self._cw.execute(rql, args, cachekey)
         except Unauthorized:
             return []
 
@@ -360,7 +360,7 @@
 
     @property
     def title(self):
-        return display_name(self.req, self.rtype, form=self.role)
+        return display_name(self._cw, self.rtype, form=self.role)
 
     def vocabulary(self):
         """return vocabulary for this facet, eg a list of 2-uple (label, value)
@@ -376,14 +376,14 @@
             insert_attr_select_relation(rqlst, mainvar, self.rtype, self.role,
                                         self.target_attr, self.sortfunc, sort)
             try:
-                rset = self.rqlexec(rqlst.as_string(), self.rset.args, self.rset.cachekey)
+                rset = self.rqlexec(rqlst.as_string(), self.cw_rset.args, self.cw_rset.cachekey)
             except:
                 self.exception('error while getting vocabulary for %s, rql: %s',
                                self, rqlst.as_string())
                 return ()
         finally:
             rqlst.recover()
-        return self.rset_vocabulary(rset)
+        return self.cw_rset_vocabulary(rset)
 
     def possible_values(self):
         """return a list of possible values (as string since it's used to
@@ -400,7 +400,7 @@
 
     def rset_vocabulary(self, rset):
         if self.label_vid is None:
-            _ = self.req._
+            _ = self._cw._
             return [(_(label), eid) for eid, label in rset]
         if self.sortfunc is None:
             return sorted((entity.view(self.label_vid), entity.eid)
@@ -416,7 +416,7 @@
         else:
             cardidx = 1
         # XXX when called via ajax, no rset to compute possible types
-        possibletypes = self.rset and self.rset.column_types(0)
+        possibletypes = self.cw_rset and self.cw_rset.column_types(0)
         for subjtype, objtype in rschema.iter_rdefs():
             if possibletypes is not None:
                 if self.role == 'subject':
@@ -430,7 +430,7 @@
 
     def add_rql_restrictions(self):
         """add restriction for this facet into the rql syntax tree"""
-        value = self.req.form.get(self.id)
+        value = self._cw.form.get(self.__regid__)
         if not value:
             return
         mainvar = self.filtered_variable
@@ -469,17 +469,17 @@
             newvar = _prepare_vocabulary_rqlst(rqlst, mainvar, self.rtype, self.role)
             _set_orderby(rqlst, newvar, self.sortasc, self.sortfunc)
             try:
-                rset = self.rqlexec(rqlst.as_string(), self.rset.args, self.rset.cachekey)
+                rset = self.rqlexec(rqlst.as_string(), self.cw_rset.args, self.cw_rset.cachekey)
             except:
                 self.exception('error while getting vocabulary for %s, rql: %s',
                                self, rqlst.as_string())
                 return ()
         finally:
             rqlst.recover()
-        return self.rset_vocabulary(rset)
+        return self.cw_rset_vocabulary(rset)
 
     def rset_vocabulary(self, rset):
-        _ = self.req._
+        _ = self._cw._
         return [(_(value), value) for value, in rset]
 
     def support_and(self):
@@ -487,7 +487,7 @@
 
     def add_rql_restrictions(self):
         """add restriction for this facet into the rql syntax tree"""
-        value = self.req.form.get(self.id)
+        value = self._cw.form.get(self.__regid__)
         if not value:
             return
         mainvar = self.filtered_variable
@@ -499,16 +499,16 @@
     """called by javascript to get a rql string from filter form"""
 
     def __init__(self, req):
-        self.req = req
+        self._cw = req
 
     def build_rql(self):#, tablefilter=False):
-        form = self.req.form
+        form = self._cw.form
         facetids = form['facets'].split(',')
         select = parse(form['baserql']).children[0] # XXX Union unsupported yet
         mainvar = filtered_variable(select)
         toupdate = []
         for facetid in facetids:
-            facet = get_facet(self.req, facetid, select, mainvar)
+            facet = get_facet(self._cw, facetid, select, mainvar)
             facet.add_rql_restrictions()
             if facet.needs_update:
                 toupdate.append(facetid)
@@ -529,10 +529,10 @@
         return self.wdgclass(self, min(values), max(values))
 
     def infvalue(self):
-        return self.req.form.get('%s_inf' % self.id)
+        return self._cw.form.get('%s_inf' % self.__regid__)
 
     def supvalue(self):
-        return self.req.form.get('%s_sup' % self.id)
+        return self._cw.form.get('%s_sup' % self.__regid__)
 
     def formatvalue(self, value):
         """format `value` before in order to insert it in the RQL query"""
@@ -571,20 +571,20 @@
 
     @property
     def title(self):
-        return display_name(self.req, self.rtype, self.role)
+        return display_name(self._cw, self.rtype, self.role)
 
     def support_and(self):
         return False
 
     def get_widget(self):
-        return CheckBoxFacetWidget(self.req, self,
+        return CheckBoxFacetWidget(self._cw, self,
                                    '%s:%s' % (self.rtype, self),
-                                   self.req.form.get(self.id))
+                                   self._cw.form.get(self.__regid__))
 
     def add_rql_restrictions(self):
         """add restriction for this facet into the rql syntax tree"""
         self.rqlst.set_distinct(True) # XXX
-        value = self.req.form.get(self.id)
+        value = self._cw.form.get(self.__regid__)
         if not value: # no value sent for this facet
             return
         var = self.rqlst.make_variable()
@@ -607,12 +607,12 @@
 
     def _render(self):
         title = xml_escape(self.facet.title)
-        facetid = xml_escape(self.facet.id)
+        facetid = xml_escape(self.facet.__regid__)
         self.w(u'<div id="%s" class="facet">\n' % facetid)
         self.w(u'<div class="facetTitle" cubicweb:facetName="%s">%s</div>\n' %
                (xml_escape(facetid), title))
         if self.facet.support_and():
-            _ = self.facet.req._
+            _ = self.facet._cw._
             self.w(u'''<select name="%s" class="radio facetOperator" title="%s">
   <option value="OR">%s</option>
   <option value="AND">%s</option>
@@ -637,7 +637,7 @@
 
     def _render(self):
         title = xml_escape(self.facet.title)
-        facetid = xml_escape(self.facet.id)
+        facetid = xml_escape(self.facet.__regid__)
         self.w(u'<div id="%s" class="facet">\n' % facetid)
         self.w(u'<div class="facetTitle" cubicweb:facetName="%s">%s</div>\n' %
                (facetid, title))
@@ -677,11 +677,11 @@
 
     def _render(self):
         facet = self.facet
-        facet.req.add_js('ui.slider.js')
-        facet.req.add_css('ui.all.css')
+        facet._cw.add_js('ui.slider.js')
+        facet._cw.add_css('ui.all.css')
         sliderid = make_uid('theslider')
-        facetid = xml_escape(self.facet.id)
-        facet.req.html_headers.add_onload(self.onload % {
+        facetid = xml_escape(self.facet.__regid__)
+        facet._cw.html_headers.add_onload(self.onload % {
             'sliderid': sliderid,
             'facetid': facetid,
             'minvalue': self.minvalue,
@@ -715,8 +715,8 @@
         super(DateFacetRangeWidget, self).__init__(facet,
                                                    datetime2ticks(minvalue),
                                                    datetime2ticks(maxvalue))
-        fmt = facet.req.property_value('ui.date-format')
-        facet.req.html_headers.define_var('DATE_FMT', fmt)
+        fmt = facet._cw.property_value('ui.date-format')
+        facet._cw.html_headers.define_var('DATE_FMT', fmt)
 
 
 class FacetItem(HTMLWidget):
@@ -725,7 +725,7 @@
     unselected_img = "no-check-no-border.png"
 
     def __init__(self, req, label, value, selected=False):
-        self.req = req
+        self._cw = req
         self.label = label
         self.value = value
         self.selected = selected
@@ -733,12 +733,12 @@
     def _render(self):
         if self.selected:
             cssclass = ' facetValueSelected'
-            imgsrc = self.req.datadir_url + self.selected_img
-            imgalt = self.req._('selected')
+            imgsrc = self._cw.datadir_url + self.selected_img
+            imgalt = self._cw._('selected')
         else:
             cssclass = ''
-            imgsrc = self.req.datadir_url + self.unselected_img
-            imgalt = self.req._('not selected')
+            imgsrc = self._cw.datadir_url + self.unselected_img
+            imgalt = self._cw._('not selected')
         self.w(u'<div class="facetValue facetCheckBox%s" cubicweb:value="%s">\n'
                % (cssclass, xml_escape(unicode(self.value))))
         self.w(u'<img src="%s" alt="%s"/>&#160;' % (imgsrc, imgalt))
@@ -751,23 +751,23 @@
     unselected_img = "black-uncheck.png"
 
     def __init__(self, req, facet, value, selected):
-        self.req = req
+        self._cw = req
         self.facet = facet
         self.value = value
         self.selected = selected
 
     def _render(self):
         title = xml_escape(self.facet.title)
-        facetid = xml_escape(self.facet.id)
+        facetid = xml_escape(self.facet.__regid__)
         self.w(u'<div id="%s" class="facet">\n' % facetid)
         if self.selected:
             cssclass = ' facetValueSelected'
-            imgsrc = self.req.datadir_url + self.selected_img
-            imgalt = self.req._('selected')
+            imgsrc = self._cw.datadir_url + self.selected_img
+            imgalt = self._cw._('selected')
         else:
             cssclass = ''
-            imgsrc = self.req.datadir_url + self.unselected_img
-            imgalt = self.req._('not selected')
+            imgsrc = self._cw.datadir_url + self.unselected_img
+            imgalt = self._cw._('not selected')
         self.w(u'<div class="facetValue facetCheckBox%s" cubicweb:value="%s">\n'
                % (cssclass, xml_escape(unicode(self.value))))
         self.w(u'<div class="facetCheckBoxWidget">')
--- a/web/form.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/form.py	Wed Sep 23 19:40:19 2009 +0200
@@ -44,7 +44,7 @@
         """return the key that may be used to store / retreive data about a
         previous post which failed because of a validation error
         """
-        return '%s#%s' % (self.req.url(), self.domid)
+        return '%s#%s' % (self._cw.url(), self.domid)
 
     def __init__(self, req, rset, **kwargs):
         super(FormMixIn, self).__init__(req, rset=rset, **kwargs)
@@ -55,12 +55,12 @@
         # deleting validation errors here breaks form reloading (errors are
         # no more available), they have to be deleted by application's publish
         # method on successful commit
-        forminfo = self.req.get_session_data(sessionkey, pop=True)
+        forminfo = self._cw.get_session_data(sessionkey, pop=True)
         if forminfo:
             # XXX remove req.data assigment once cw.web.widget is killed
-            self.req.data['formvalues'] = self.form_previous_values = forminfo['values']
-            self.req.data['formerrors'] = self.form_valerror = forminfo['errors']
-            self.req.data['displayederrors'] = self.form_displayed_errors = set()
+            self._cw.data['formvalues'] = self.form_previous_values = forminfo['values']
+            self._cw.data['formerrors'] = self.form_valerror = forminfo['errors']
+            self._cw.data['displayederrors'] = self.form_displayed_errors = set()
             # if some validation error occured on entity creation, we have to
             # get the original variable name from its attributed eid
             foreid = self.form_valerror.entity
@@ -98,7 +98,7 @@
 
     def button(self, label, klass='validateButton', tabindex=None, **kwargs):
         if tabindex is None:
-            tabindex = self.req.next_tabindex()
+            tabindex = self._cw.next_tabindex()
         return tags.input(value=label, klass=klass, **kwargs)
 
     def action_button(self, label, onclick=None, __action=None, **kwargs):
@@ -109,24 +109,24 @@
 
     def button_ok(self, label=None, type='submit', name='defaultsubmit',
                   **kwargs):
-        label = self.req._(label or stdmsgs.BUTTON_OK).capitalize()
+        label = self._cw._(label or stdmsgs.BUTTON_OK).capitalize()
         return self.button(label, name=name, type=type, **kwargs)
 
     def button_apply(self, label=None, type='button', **kwargs):
-        label = self.req._(label or stdmsgs.BUTTON_APPLY).capitalize()
+        label = self._cw._(label or stdmsgs.BUTTON_APPLY).capitalize()
         return self.action_button(label, __action='apply', type=type, **kwargs)
 
     def button_delete(self, label=None, type='button', **kwargs):
-        label = self.req._(label or stdmsgs.BUTTON_DELETE).capitalize()
+        label = self._cw._(label or stdmsgs.BUTTON_DELETE).capitalize()
         return self.action_button(label, __action='delete', type=type, **kwargs)
 
     def button_cancel(self, label=None, type='button', **kwargs):
-        label = self.req._(label or stdmsgs.BUTTON_CANCEL).capitalize()
+        label = self._cw._(label or stdmsgs.BUTTON_CANCEL).capitalize()
         return self.action_button(label, __action='cancel', type=type, **kwargs)
 
     def button_reset(self, label=None, type='reset', name='__action_cancel',
                      **kwargs):
-        label = self.req._(label or stdmsgs.BUTTON_CANCEL).capitalize()
+        label = self._cw._(label or stdmsgs.BUTTON_CANCEL).capitalize()
         return self.button(label, type=type, **kwargs)
 
     def need_multipart(self, entity, categories=('primary', 'secondary')):
@@ -140,7 +140,7 @@
             assert len(targettypes) == 1, \
                    "I'm not able to deal with several targets and inlineview"
             ttype = targettypes[0]
-            inlined_entity = self.vreg.etype_class(ttype)(self.req, None, None)
+            inlined_entity = self.vreg.etype_class(ttype)(self._cw, None, None)
             for irschema, _, x in inlined_entity.relations_by_category(categories):
                 if inlined_entity.get_widget(irschema, x).need_multipart:
                     return True
@@ -151,11 +151,11 @@
 
         This method should be called once inlined field errors has been consumed
         """
-        errex = self.req.data.get('formerrors') or self.form_valerror
+        errex = self._cw.data.get('formerrors') or self.form_valerror
         # get extra errors
         if errex is not None:
-            errormsg = self.req._('please correct the following errors:')
-            displayed = self.req.data.get('displayederrors') or self.form_displayed_errors
+            errormsg = self._cw._('please correct the following errors:')
+            displayed = self._cw.data.get('displayederrors') or self.form_displayed_errors
             errors = sorted((field, err) for field, err in errex.errors.items()
                             if not field in displayed)
             if errors:
@@ -167,7 +167,7 @@
                     if field is None:
                         errormsg += templstr % err
                     else:
-                        errormsg += templstr % '%s: %s' % (self.req._(field), err)
+                        errormsg += templstr % '%s: %s' % (self._cw._(field), err)
                 if len(errors) > 1:
                     errormsg = '<ul>%s</ul>' % errormsg
             return u'<div class="errorMessage">%s</div>' % errormsg
--- a/web/formfields.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/formfields.py	Wed Sep 23 19:40:19 2009 +0200
@@ -195,7 +195,7 @@
                 except TypeError:
                     warn('vocabulary method (eg field.choices) should now take '
                          'the form instance as argument', DeprecationWarning)
-                    vocab = self.choices(req=form.req)
+                    vocab = self.choices(req=form._cw)
             else:
                 vocab = self.choices
             if vocab and not isinstance(vocab[0], (list, tuple)):
@@ -203,7 +203,7 @@
         else:
             vocab = form.form_field_vocabulary(self)
         if self.internationalizable:
-            vocab = [(form.req._(label), value) for label, value in vocab]
+            vocab = [(form._cw._(label), value) for label, value in vocab]
         if self.sort:
             vocab = vocab_sort(vocab)
         return vocab
@@ -284,7 +284,7 @@
             return self.format_field
         # we have to cache generated field since it's use as key in the
         # context dictionnary
-        req = form.req
+        req = form._cw
         try:
             return req.data[self]
         except KeyError:
@@ -316,7 +316,7 @@
         """return True if fckeditor should be used to edit entity's attribute named
         `attr`, according to user preferences
         """
-        if form.req.use_fckeditor():
+        if form._cw.use_fckeditor():
             return form.form_field_format(self) == 'text/html'
         return False
 
@@ -354,9 +354,9 @@
             divid = '%s-advanced' % form.context[self]['name']
             wdgs.append(u'<a href="%s" title="%s"><img src="%s" alt="%s"/></a>' %
                         (xml_escape(uilib.toggle_action(divid)),
-                         form.req._('show advanced fields'),
-                         xml_escape(form.req.build_url('data/puce_down.png')),
-                         form.req._('show advanced fields')))
+                         form._cw._('show advanced fields'),
+                         xml_escape(form._cw.build_url('data/puce_down.png')),
+                         form._cw._('show advanced fields')))
             wdgs.append(u'<div id="%s" class="hidden">' % divid)
             if self.format_field:
                 wdgs.append(self.render_subfield(form, self.format_field, renderer))
@@ -368,7 +368,7 @@
             wdgs.append(u'<br/>')
             wdgs.append(tags.input(name=u'%s__detach' % form.context[self]['name'],
                                    type=u'checkbox'))
-            wdgs.append(form.req._('detach attached file'))
+            wdgs.append(form._cw._('detach attached file'))
         return u'\n'.join(wdgs)
 
     def render_subfield(self, form, field, renderer):
@@ -378,7 +378,7 @@
                 + u'<br/>')
 
     def process_form_value(self, form):
-        posted = form.req.form
+        posted = form._cw.form
         value = posted.get(form.form_field_name(self))
         formkey = form.form_field_name(self)
         if ('%s__detach' % form.context[self]['name']) in posted:
@@ -412,13 +412,13 @@
                     pass
                 else:
                     if not self.required:
-                        msg = form.req._(
+                        msg = form._cw._(
                             'You can either submit a new file using the browse button above'
                             ', or choose to remove already uploaded file by checking the '
                             '"detach attached file" check-box, or edit file content online '
                             'with the widget below.')
                     else:
-                        msg = form.req._(
+                        msg = form._cw._(
                             'You can either submit a new file using the browse button above'
                             ', or edit file content online with the widget below.')
                     wdgs.append(u'<p><b>%s</b></p>' % msg)
@@ -427,7 +427,7 @@
         return '\n'.join(wdgs)
 
     def process_form_value(self, form):
-        value = form.req.form.get(form.form_field_name(self))
+        value = form._cw.form.get(form.form_field_name(self))
         if isinstance(value, unicode):
             # file modified using a text widget
             encoding = form.form_field_encoding(self)
@@ -453,7 +453,7 @@
     def vocabulary(self, form):
         if self.choices:
             return self.choices
-        return [(form.req._('yes'), '1'), (form.req._('no'), '')]
+        return [(form._cw._('yes'), '1'), (form._cw._('no'), '')]
 
     def process_form_value(self, form):
         return bool(Field.process_form_value(self, form))
@@ -534,7 +534,7 @@
 
     def vocabulary(self, form):
         entity = form.edited_entity
-        req = entity.req
+        req = entity._cw
         # first see if its specified by __linkto form parameters
         linkedto = entity.linked_to(self.name, self.role)
         if linkedto:
--- a/web/formwidgets.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/formwidgets.py	Wed Sep 23 19:40:19 2009 +0200
@@ -39,9 +39,9 @@
     def add_media(self, form):
         """adds media (CSS & JS) required by this widget"""
         if self.needs_js:
-            form.req.add_js(self.needs_js)
+            form._cw.add_js(self.needs_js)
         if self.needs_css:
-            form.req.add_css(self.needs_css)
+            form._cw.add_css(self.needs_css)
 
     def render(self, form, field, renderer):
         """render the widget for the given `field` of `form`.
@@ -60,12 +60,12 @@
         if self.setdomid:
             attrs['id'] = form.context[field]['id']
         if self.settabindex and not 'tabindex' in attrs:
-            attrs['tabindex'] = form.req.next_tabindex()
+            attrs['tabindex'] = form._cw.next_tabindex()
         return name, values, attrs
 
     def process_field_data(self, form, field):
         formkey = form.form_field_name(field)
-        posted = form.req.form
+        posted = form._cw.form
         return posted.get(formkey)
 
 class Input(FieldWidget):
@@ -114,19 +114,19 @@
                   '<br/>',
                   tags.input(name=confirmname, value=values[0], type=self.type,
                              **attrs),
-                  '&#160;', tags.span(form.req._('confirm password'),
+                  '&#160;', tags.span(form._cw._('confirm password'),
                                       **{'class': 'emphasis'})]
         return u'\n'.join(inputs)
 
     def process_field_data(self, form, field):
         passwd1 = super(PasswordInput, self).process_field_data(form, field)
         fieldname = form.form_field_name(field)
-        passwd2 = form.req.form[fieldname+'-confirm']
+        passwd2 = form._cw.form[fieldname+'-confirm']
         if passwd1 == passwd2:
             if passwd1 is None:
                 return None
             return passwd1.encode('utf-8')
-        raise ProcessFormError(form.req._("password and confirmation don't match"))
+        raise ProcessFormError(form._cw._("password and confirmation don't match"))
 
 class PasswordSingleInput(Input):
     """<input type='password'> without a confirmation field"""
@@ -192,7 +192,7 @@
         self.attrs['cubicweb:type'] = 'wysiwyg'
 
     def render(self, form, field, renderer):
-        form.req.fckeditor_config()
+        form._cw.fckeditor_config()
         return super(FCKEditor, self).render(form, field, renderer)
 
 
@@ -293,9 +293,9 @@
         actual_fields = field.fields
         assert len(actual_fields) == 2
         return u'<div>%s %s %s %s</div>' % (
-            form.req._('from_interval_start'),
+            form._cw._('from_interval_start'),
             actual_fields[0].render(form, renderer),
-            form.req._('to_interval_end'),
+            form._cw._('to_interval_end'),
             actual_fields[1].render(form, renderer),
             )
 
@@ -342,7 +342,7 @@
 
     def render(self, form, field, renderer):
         txtwidget = super(DateTimePicker, self).render(form, field, renderer)
-        self.add_localized_infos(form.req)
+        self.add_localized_infos(form._cw)
         cal_button = self._render_calendar_popup(form, field)
         return txtwidget + cal_button
 
@@ -356,8 +356,8 @@
         return (u"""<a onclick="toggleCalendar('%s', '%s', %s, %s);" class="calhelper">
 <img src="%s" title="%s" alt="" /></a><div class="calpopup hidden" id="%s"></div>"""
                 % (helperid, inputid, year, month,
-                   form.req.external_resource('CALENDAR_ICON'),
-                   form.req._('calendar'), helperid) )
+                   form._cw.external_resource('CALENDAR_ICON'),
+                   form._cw._('calendar'), helperid) )
 
 
 
@@ -419,8 +419,8 @@
             fname = entity.autocomplete_initfuncs[field.name]
         else:
             fname = self.autocomplete_initfunc
-        return entity.req.build_url('json', fname=fname, mode='remote',
-                                    pageid=entity.req.pageid)
+        return entity._cw.build_url('json', fname=fname, mode='remote',
+                                    pageid=entity._cw.pageid)
 
 
 class StaticFileAutoCompletionWidget(AutoCompletionWidget):
@@ -433,7 +433,7 @@
             fname = entity.autocomplete_initfuncs[field.name]
         else:
             fname = self.autocomplete_initfunc
-        return entity.req.datadir_url + fname
+        return entity._cw.datadir_url + fname
 
 
 class RestrictedAutoCompletionWidget(AutoCompletionWidget):
@@ -480,7 +480,7 @@
         self.attrs.setdefault('klass', 'validateButton')
 
     def render(self, form, field=None, renderer=None):
-        label = form.req._(self.label)
+        label = form._cw._(self.label)
         attrs = self.attrs.copy()
         if self.cwaction:
             assert self.onclick is None
@@ -493,7 +493,7 @@
             if self.setdomid:
                 attrs['id'] = self.name
         if self.settabindex and not 'tabindex' in attrs:
-            attrs['tabindex'] = form.req.next_tabindex()
+            attrs['tabindex'] = form._cw.next_tabindex()
         return tags.input(value=label, type=self.type, **attrs)
 
 
@@ -523,8 +523,8 @@
         self.label = label
 
     def render(self, form, field=None, renderer=None):
-        label = form.req._(self.label)
-        imgsrc = form.req.external_resource(self.imgressource)
+        label = form._cw._(self.label)
+        imgsrc = form._cw.external_resource(self.imgressource)
         return '<a id="%(domid)s" href="%(href)s">'\
                '<img src="%(imgsrc)s" alt="%(label)s"/>%(label)s</a>' % {
             'label': label, 'imgsrc': imgsrc,
--- a/web/httpcache.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/httpcache.py	Wed Sep 23 19:40:19 2009 +0200
@@ -18,7 +18,7 @@
     def __init__(self, view):
         self.view = view
         self.req = view.req
-        self.rset = view.rset
+        self.cw_rset = view.rset
 
     def set_headers(self):
         self.req.set_header('Cache-control', 'no-cache')
@@ -72,12 +72,12 @@
       with a modification time to consider) using the `last_modified` method
     """
     def etag(self):
-        if self.rset is None or len(self.rset) == 0: # entity startup view for instance
+        if self.cw_rset is None or len(self.cw_rset) == 0: # entity startup view for instance
             return super(EntityHTTPCacheManager, self).etag()
-        if len(self.rset) > 1:
+        if len(self.cw_rset) > 1:
             raise NoEtag()
         etag = super(EntityHTTPCacheManager, self).etag()
-        eid = self.rset[0][0]
+        eid = self.cw_rset[0][0]
         if self.req.user.owns(eid):
             etag += ',owners'
         return str(eid) + '/' + etag
--- a/web/test/unittest_viewselector.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/test/unittest_viewselector.py	Wed Sep 23 19:40:19 2009 +0200
@@ -83,12 +83,14 @@
                               ])
 
     def test_possible_views_noresult(self):
-        rset, req = self.rset_and_req('Any X WHERE X eid 999999')
+        req = self.request()
+        rset = req.execute('Any X WHERE X eid 999999')
         self.assertListEqual(self.pviews(req, rset),
                              [])
 
     def test_possible_views_one_egroup(self):
-        rset, req = self.rset_and_req('CWGroup X WHERE X name "managers"')
+        req = self.request()
+        rset = req.execute('CWGroup X WHERE X name "managers"')
         self.assertListEqual(self.pviews(req, rset),
                              [('adaptedlist', baseviews.AdaptedListView),
                               ('csvexport', csvexport.CSVRsetView),
@@ -111,7 +113,8 @@
                               ])
 
     def test_possible_views_multiple_egroups(self):
-        rset, req = self.rset_and_req('CWGroup X')
+        req = self.request()
+        rset = req.execute('CWGroup X')
         self.assertListEqual(self.pviews(req, rset),
                              [('adaptedlist', baseviews.AdaptedListView),
                               ('csvexport', csvexport.CSVRsetView),
@@ -135,16 +138,20 @@
 
     def test_propertiesform_admin(self):
         assert self.vreg['views']['propertiesform']
-        rset1, req1 = self.rset_and_req('CWUser X WHERE X login "admin"')
-        rset2, req2 = self.rset_and_req('CWUser X WHERE X login "anon"')
+        req1 = self.request()
+        req2 = self.request()
+        rset1 = req1.execute('CWUser X WHERE X login "admin"')
+        rset2 = req2.execute('CWUser X WHERE X login "anon"')
         self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=None))
         self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=rset1))
         self.failUnless(self.vreg['views'].select('propertiesform', req2, rset=rset2))
 
     def test_propertiesform_anon(self):
         self.login('anon')
-        rset1, req1 = self.rset_and_req('CWUser X WHERE X login "admin"')
-        rset2, req2 = self.rset_and_req('CWUser X WHERE X login "anon"')
+        req1 = self.request()
+        req2 = self.request()
+        rset1 = req1.execute('CWUser X WHERE X login "admin"')
+        rset2 = req2.execute('CWUser X WHERE X login "anon"')
         self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=None)
         self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset1)
         self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset2)
@@ -152,14 +159,17 @@
     def test_propertiesform_jdoe(self):
         self.create_user('jdoe')
         self.login('jdoe')
-        rset1, req1 = self.rset_and_req('CWUser X WHERE X login "admin"')
-        rset2, req2 = self.rset_and_req('CWUser X WHERE X login "jdoe"')
+        req1 = self.request()
+        req2 = self.request()
+        rset1 = req1.execute('CWUser X WHERE X login "admin"')
+        rset2 = req2.execute('CWUser X WHERE X login "jdoe"')
         self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=None))
         self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset1)
         self.failUnless(self.vreg['views'].select('propertiesform', req2, rset=rset2))
 
     def test_possible_views_multiple_different_types(self):
-        rset, req = self.rset_and_req('Any X')
+        req = self.request()
+        rset = req.execute('Any X')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', csvexport.CSVRsetView),
                               ('ecsvexport', csvexport.CSVEntityView),
@@ -181,7 +191,8 @@
                               ])
 
     def test_possible_views_any_rset(self):
-        rset, req = self.rset_and_req('Any N, X WHERE X in_group Y, Y name N')
+        req = self.request()
+        rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
         self.assertListEqual(self.pviews(req, rset),
                              [('csvexport', csvexport.CSVRsetView),
                               ('editable-table', tableview.EditableTableView),
@@ -190,7 +201,8 @@
                               ])
 
     def test_possible_views_multiple_eusers(self):
-        rset, req = self.rset_and_req('CWUser X')
+        req = self.request()
+        rset = req.execute('CWUser X')
         self.assertListEqual(self.pviews(req, rset),
                              [('adaptedlist', baseviews.AdaptedListView),
                               ('csvexport', csvexport.CSVRsetView),
@@ -223,14 +235,16 @@
 
                               })
     def test_possible_actions_no_entity(self):
-        rset, req = self.rset_and_req('Any X WHERE X eid 999999')
+        req = self.request()
+        rset = req.execute('Any X WHERE X eid 999999')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
                               })
 
     def test_possible_actions_same_type_entities(self):
-        rset, req = self.rset_and_req('CWGroup X')
+        req = self.request()
+        rset = req.execute('CWGroup X')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
@@ -240,7 +254,8 @@
                               })
 
     def test_possible_actions_different_types_entities(self):
-        rset, req = self.rset_and_req('Any X')
+        req = self.request()
+        rset = req.execute('Any X')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
@@ -248,13 +263,15 @@
                               })
 
     def test_possible_actions_final_entities(self):
-        rset, req = self.rset_and_req('Any N, X WHERE X in_group Y, Y name N')
+        req = self.request()
+        rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS})
 
     def test_possible_actions_eetype_cwuser_entity(self):
-        rset, req = self.rset_and_req('CWEType X WHERE X name "CWUser"')
+        req = self.request()
+        rset = req.execute('CWEType X WHERE X name "CWUser"')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
@@ -296,7 +313,8 @@
                              self.vreg['views'].select, 'table', req, rset=rset)
 
         # no entity
-        rset, req = self.rset_and_req('Any X WHERE X eid 999999')
+        req = self.request()
+        rset = req.execute('Any X WHERE X eid 999999')
         self.failUnlessRaises(NoSelectableObject,
                               self.vreg['views'].select, 'index', req, rset=rset)
         self.failUnlessRaises(NoSelectableObject,
@@ -306,7 +324,8 @@
         self.failUnlessRaises(NoSelectableObject,
                              self.vreg['views'].select, 'table', req, rset=rset)
         # one entity
-        rset, req = self.rset_and_req('CWGroup X WHERE X name "managers"')
+        req = self.request()
+        rset = req.execute('CWGroup X WHERE X name "managers"')
         self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
                              primary.PrimaryView)
         self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
@@ -320,7 +339,8 @@
         self.failUnlessRaises(NoSelectableObject,
                               self.vreg['views'].select, 'index', req, rset=rset)
         # list of entities of the same type
-        rset, req = self.rset_and_req('CWGroup X')
+        req = self.request()
+        rset = req.execute('CWGroup X')
         self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
                              primary.PrimaryView)
         self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
@@ -330,7 +350,8 @@
         self.failUnlessRaises(NoSelectableObject,
                               self.vreg['views'].select, 'creation', req, rset=rset)
         # list of entities of different types
-        rset, req = self.rset_and_req('Any X')
+        req = self.request()
+        rset = req.execute('Any X')
         self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
                                   primary.PrimaryView)
         self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
@@ -342,7 +363,8 @@
         self.failUnlessRaises(NoSelectableObject,
                               self.vreg['views'].select, 'index', req, rset=rset)
         # whatever
-        rset, req = self.rset_and_req('Any N, X WHERE X in_group Y, Y name N')
+        req = self.request()
+        rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
         self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
                                   tableview.TableView)
         self.failUnlessRaises(NoSelectableObject,
@@ -356,7 +378,8 @@
         self.failUnlessRaises(NoSelectableObject,
                              self.vreg['views'].select, 'edition', req, rset=rset)
         # mixed query
-        rset, req = self.rset_and_req('Any U,G WHERE U is CWUser, G is CWGroup')
+        req = self.request()
+        rset = req.execute('Any U,G WHERE U is CWUser, G is CWGroup')
         self.failUnlessRaises(NoSelectableObject,
                               self.vreg['views'].select, 'edition', req, rset=rset)
         self.failUnlessRaises(NoSelectableObject,
@@ -367,7 +390,8 @@
     def test_interface_selector(self):
         image = self.add_entity('Image', name=u'bim.png', data=Binary('bim'))
         # image primary view priority
-        rset, req = self.rset_and_req('Image X WHERE X name "bim.png"')
+        req = self.request()
+        rset = req.execute('Image X WHERE X name "bim.png"')
         self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
                               idownloadable.IDownloadablePrimaryView)
 
@@ -375,12 +399,14 @@
     def test_score_entity_selector(self):
         image = self.add_entity('Image', name=u'bim.png', data=Binary('bim'))
         # image primary view priority
-        rset, req = self.rset_and_req('Image X WHERE X name "bim.png"')
+        req = self.request()
+        rset = req.execute('Image X WHERE X name "bim.png"')
         self.assertIsInstance(self.vreg['views'].select('image', req, rset=rset),
                               idownloadable.ImageView)
         fileobj = self.add_entity('File', name=u'bim.txt', data=Binary('bim'))
         # image primary view priority
-        rset, req = self.rset_and_req('File X WHERE X name "bim.txt"')
+        req = self.request()
+        rset = req.execute('File X WHERE X name "bim.txt"')
         self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'image', req, rset=rset)
 
 
@@ -390,7 +416,8 @@
             rset = None
             req = self.request()
         else:
-            rset, req = self.rset_and_req(rql)
+            req = self.request()
+            rset = req.execute(rql)
         try:
             self.vreg['views'].render(vid, req, rset=rset, **args)
         except:
@@ -443,7 +470,8 @@
         del self.vreg['actions']['testaction']
 
     def test(self):
-        rset, req = self.rset_and_req('CWEType X WHERE X name "CWEType"')
+        req = self.request()
+        rset = req.execute('CWEType X WHERE X name "CWEType"')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
@@ -455,7 +483,8 @@
                                               ('testaction', CWETypeRQLAction),
                                               ],
                               })
-        rset, req = self.rset_and_req('CWEType X WHERE X name "CWRType"')
+        req = self.request()
+        rset = req.execute('CWEType X WHERE X name "CWRType"')
         self.assertDictEqual(self.pactions(req, rset),
                              {'useractions': USERACTIONS,
                               'siteactions': SITEACTIONS,
--- a/web/views/__init__.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/__init__.py	Wed Sep 23 19:40:19 2009 +0200
@@ -110,7 +110,7 @@
         self.cell_call()
 
     def cell_call(self, row=0, col=0):
-        self.row, self.col = row, col # in case one needs it
+        self.cw_row, self.cw_col = row, col # in case one needs it
         fd, tmpfile = tempfile.mkstemp('.png')
         os.close(fd)
         self._generate(tmpfile)
--- a/web/views/actions.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/actions.py	Wed Sep 23 19:40:19 2009 +0200
@@ -48,7 +48,7 @@
 def view_is_not_default_view(cls, req, rset=None, **kwargs):
     # interesting if it propose another view than the current one
     vid = req.form.get('vid')
-    if vid and vid != vid_from_rset(req, rset, cls.schema):
+    if vid and vid != vid_from_rset(req, rset, req.vreg.schema):
         return 1
     return 0
 
@@ -61,7 +61,7 @@
         select = rqlst.children[0]
         if len(select.defined_vars) == 1 and len(select.solutions) == 1:
             rset._searched_etype = select.solutions[0].itervalues().next()
-            eschema = cls.schema.eschema(rset._searched_etype)
+            eschema = req.schema.eschema(rset._searched_etype)
             if not (eschema.is_final() or eschema.is_subobject(strict=True)) \
                    and eschema.has_perm(req, 'add'):
                 return 1
@@ -82,7 +82,7 @@
     order = 0
 
     def url(self):
-        return linksearch_select_url(self.req, self.rset)
+        return linksearch_select_url(self._cw, self.cw_rset)
 
 
 class CancelSelectAction(Action):
@@ -94,9 +94,9 @@
     order = 10
 
     def url(self):
-        target, eid, r_type, searched_type = self.req.search_state[1]
-        return self.build_url(str(eid),
-                              vid='edition', __mode='normal')
+        target, eid, r_type, searched_type = self._cw.search_state[1]
+        return self._cw.build_url(str(eid),
+                                  vid='edition', __mode='normal')
 
 
 class ViewAction(Action):
@@ -111,11 +111,11 @@
     order = 0
 
     def url(self):
-        params = self.req.form.copy()
+        params = self._cw.form.copy()
         for param in ('vid', '__message') + controller.NAV_FORM_PARAMETERS:
             params.pop(param, None)
-        return self.build_url(self.req.relative_path(includeparams=False),
-                              **params)
+        return self._cw.build_url(self._cw.relative_path(includeparams=False),
+                                  **params)
 
 
 class ModifyAction(Action):
@@ -129,7 +129,7 @@
     order = 10
 
     def url(self):
-        entity = self.rset.get_entity(self.row or 0, self.col or 0)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         return entity.absolute_url(vid='edition')
 
 
@@ -144,7 +144,7 @@
     order = 10
 
     def url(self):
-        return self.build_url('view', rql=self.rset.rql, vid='muledit')
+        return self._cw.build_url('view', rql=self.cw_rset.rql, vid='muledit')
 
 
 # generic "more" actions #######################################################
@@ -167,7 +167,7 @@
         return super(ManagePermissionsAction, cls).__registered__(vreg)
 
     def url(self):
-        return self.rset.get_entity(self.row or 0, self.col or 0).absolute_url(vid='security')
+        return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).absolute_url(vid='security')
 
 
 class DeleteAction(Action):
@@ -179,10 +179,10 @@
     order = 20
 
     def url(self):
-        if len(self.rset) == 1:
-            entity = self.rset.get_entity(self.row or 0, self.col or 0)
-            return self.build_url(entity.rest_path(), vid='deleteconf')
-        return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf')
+        if len(self.cw_rset) == 1:
+            entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
+            return self._cw.build_url(entity.rest_path(), vid='deleteconf')
+        return self._cw.build_url(rql=self.cw_rset.printable_rql(), vid='deleteconf')
 
 
 class CopyAction(Action):
@@ -194,7 +194,7 @@
     order = 30
 
     def url(self):
-        entity = self.rset.get_entity(self.row or 0, self.col or 0)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         return entity.absolute_url(vid='copy')
 
 
@@ -213,16 +213,16 @@
 
     @property
     def rsettype(self):
-        if self.rset:
-            return self.rset.description[0][0]
-        return self.rset._searched_etype
+        if self.cw_rset:
+            return self.cw_rset.description[0][0]
+        return self.cw_rset._searched_etype
 
     @property
     def title(self):
-        return self.req.__('add a %s' % self.rsettype) # generated msgid
+        return self._cw.__('add a %s' % self.rsettype) # generated msgid
 
     def url(self):
-        return self.build_url('add/%s' % self.rsettype)
+        return self._cw.build_url('add/%s' % self.rsettype)
 
 
 class AddRelatedActions(Action):
@@ -236,11 +236,11 @@
     def fill_menu(self, box, menu):
         # when there is only one item in the sub-menu, replace the sub-menu by
         # item's title prefixed by 'add'
-        menu.label_prefix = self.req._('add')
+        menu.label_prefix = self._cw._('add')
         super(AddRelatedActions, self).fill_menu(box, menu)
 
     def actual_actions(self):
-        entity = self.rset.get_entity(self.row or 0, self.col or 0)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         eschema = entity.e_schema
         for rschema, teschema, x in self.add_related_schemas(entity):
             if x == 'subject':
@@ -249,7 +249,7 @@
             else:
                 label = 'add %s %s %s %s' % (teschema, rschema, eschema, x)
                 url = self.linkto_url(entity, rschema, teschema, 'subject')
-            yield self.build_action(self.req._(label), url)
+            yield self.build_action(self._cw._(label), url)
 
     def add_related_schemas(self, entity):
         """this is actually used ui method to generate 'addrelated' actions from
@@ -260,7 +260,7 @@
         them by using uicfg.actionbox_appearsin_addmenu
         """
         appearsin_addmenu = uicfg.actionbox_appearsin_addmenu
-        req = self.req
+        req = self._cw
         eschema = entity.e_schema
         for role, rschemas in (('subject', eschema.subject_relations()),
                                ('object', eschema.object_relations())):
@@ -284,10 +284,10 @@
                         yield rschema, teschema, role
 
     def linkto_url(self, entity, rtype, etype, target):
-        return self.build_url('add/%s' % etype,
-                              __linkto='%s:%s:%s' % (rtype, entity.eid, target),
-                              __redirectpath=entity.rest_path(), # should not be url quoted!
-                              __redirectvid=self.req.form.get('vid', ''))
+        return self._cw.build_url('add/%s' % etype,
+                                  __linkto='%s:%s:%s' % (rtype, entity.eid, target),
+                                  __redirectpath=entity.rest_path(), # should not be url quoted!
+                                  __redirectvid=self._cw.form.get('vid', ''))
 
 
 # logged user actions #########################################################
@@ -301,7 +301,7 @@
     order = 10
 
     def url(self):
-        return self.build_url(self.id)
+        return self._cw.build_url(self.__regid__)
 
 
 class UserInfoAction(Action):
@@ -313,7 +313,7 @@
     order = 20
 
     def url(self):
-        return self.build_url('cwuser/%s'%self.req.user.login, vid='edition')
+        return self._cw.build_url('cwuser/%s'%self._cw.user.login, vid='edition')
 
 
 class LogoutAction(Action):
@@ -325,7 +325,7 @@
     order = 30
 
     def url(self):
-        return self.build_url(self.id)
+        return self._cw.build_url(self.__regid__)
 
 
 # site actions ################################################################
@@ -337,7 +337,7 @@
     category = 'siteactions'
 
     def url(self):
-        return self.build_url(self.id)
+        return self._cw.build_url(self.__regid__)
 
 
 class SiteConfigurationAction(ManagersAction):
--- a/web/views/ajaxedit.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/ajaxedit.py	Wed Sep 23 19:40:19 2009 +0200
@@ -28,11 +28,11 @@
     build_js = EditRelationBoxTemplate.build_reload_js_call
 
     def cell_call(self, row, col, rtype=None, target=None, etype=None):
-        self.rtype = rtype or self.req.form['rtype']
-        self.target = target or self.req.form['target']
-        self.etype = etype or self.req.form.get('etype')
-        entity = self.rset.get_entity(row, col)
-        rschema = self.schema.rschema(self.rtype)
+        self.rtype = rtype or self._cw.form['rtype']
+        self.target = target or self._cw.form['target']
+        self.etype = etype or self._cw.form.get('etype')
+        entity = self.cw_rset.get_entity(row, col)
+        rschema = self._cw.schema.rschema(self.rtype)
         if not self.etype:
             if self.target == 'object':
                 etypes = rschema.objects(entity.e_schema)
@@ -40,9 +40,9 @@
                 etypes = rschema.subjects(entity.e_schema)
             if len(etypes) == 1:
                 self.etype = etypes[0]
-        self.w(u'<div id="%s">' % self.id)
-        self.w(u'<h1>%s</h1>' % self.req._('relation %(relname)s of %(ent)s')
-               % {'relname': rschema.display_name(self.req, role(self)),
+        self.w(u'<div id="%s">' % self.__regid__)
+        self.w(u'<h1>%s</h1>' % self._cw._('relation %(relname)s of %(ent)s')
+               % {'relname': rschema.display_name(self._cw, role(self)),
                   'ent': entity.view('incontext')})
         self.w(u'<ul>')
         for boxitem in self.unrelated_boxitems(entity):
@@ -59,13 +59,13 @@
         if getattr(self, 'etype', None):
             rset = entity.unrelated(self.rtype, self.etype, role(self),
                                     ordermethod='fetch_order')
-            self.pagination(self.req, rset, w=self.w)
+            self.pagination(self._cw, rset, w=self.w)
             return rset.entities()
         # in other cases, use vocabulary functions
         entities = []
         # XXX to update for 3.2
         for _, eid in entity.vocabulary(self.rtype, role(self)):
             if eid is not None:
-                rset = self.req.eid_rset(eid)
+                rset = self._cw.eid_rset(eid)
                 entities.append(rset.get_entity(0, 0))
         return entities
--- a/web/views/authentication.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/authentication.py	Wed Sep 23 19:40:19 2009 +0200
@@ -73,19 +73,19 @@
             login, password = req.get_authorization()
         if not login:
             # No session and no login -> try anonymous
-            login, password = self.vreg.config.anonymous_user()
+            login, password = self._cw.vreg.config.anonymous_user()
             if not login: # anonymous not authorized
                 raise ExplicitLogin()
         # remove possibly cached cursor coming from closed connection
         clear_cache(req, 'cursor')
-        cnxprops = ConnectionProperties(self.vreg.config.repo_method,
+        cnxprops = ConnectionProperties(self._cw.vreg.config.repo_method,
                                         close=False, log=self.log_queries)
         try:
             cnx = repo_connect(self.repo, login, password, cnxprops=cnxprops)
         except AuthenticationError:
             req.set_message(req._('authentication failure'))
             # restore an anonymous connection if possible
-            anonlogin, anonpassword = self.vreg.config.anonymous_user()
+            anonlogin, anonpassword = self._cw.vreg.config.anonymous_user()
             if anonlogin and anonlogin != login:
                 cnx = repo_connect(self.repo, anonlogin, anonpassword,
                                    cnxprops=cnxprops)
@@ -100,9 +100,9 @@
 
     def _init_cnx(self, cnx, login, password):
         # decorate connection
-        if login == self.vreg.config.anonymous_user()[0]:
+        if login == self._cw.vreg.config.anonymous_user()[0]:
             cnx.anonymous_connection = True
-        cnx.vreg = self.vreg
+        cnx.vreg = self._cw.vreg
         cnx.login = login
         cnx.password = password
 
--- a/web/views/autoform.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/autoform.py	Wed Sep 23 19:40:19 2009 +0200
@@ -140,9 +140,9 @@
         try:
             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
         except form.FieldNotFound:
-            if eschema is None or not name in cls_or_self.schema:
+            if eschema is None or not name in cls_or_self._cw.schema:
                 raise
-            rschema = cls_or_self.schema.rschema(name)
+            rschema = cls_or_self._cw.schema.rschema(name)
             # XXX use a sample target type. Document this.
             tschemas = rschema.targets(eschema, role)
             fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role,
@@ -211,8 +211,8 @@
                 continue
             targettype = targettypes[0]
             if self.should_inline_relation_form(rschema, targettype, role):
-                entity = self.vreg['etypes'].etype_class(targettype)(self._cw)
-                subform = self.vreg['forms'].select('edition', self._cw, entity=entity)
+                entity = self._cw.vreg['etypes'].etype_class(targettype)(self._cw)
+                subform = self._cw.vreg['forms'].select('edition', self._cw, entity=entity)
                 if subform.form_needs_multipart:
                     return True
         return False
@@ -245,8 +245,6 @@
         """return a list of (relation schema, target schemas, role) matching
         given category(ies) and permission
         """
-        # we'll need an initialized varmaker if there are some inlined relation
-        self.initialize_varmaker()
         return self.erelations_by_category(self.edited_entity, True, 'add',
                                            self.rinlined)
 
@@ -329,7 +327,7 @@
         """return true if the given relation with entity has role and a
         targettype target should be inlined
         """
-        return self.rinlined.etype_get(self.edited_entity.id, rschema, role,
+        return self.rinlined.etype_get(self.edited_entity.__regid__, rschema, role,
                                        targettype)
 
     def display_inline_edition_form(self, w, rschema, targettype, role,
--- a/web/views/basecomponents.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/basecomponents.py	Wed Sep 23 19:40:19 2009 +0200
@@ -37,11 +37,11 @@
         if hasattr(view, 'filter_box_context_info'):
             rset = view.filter_box_context_info()[0]
         else:
-            rset = self.rset
+            rset = self.cw_rset
         # display multilines query as one line
-        rql = rset is not None and rset.printable_rql(encoded=False) or self.req.form.get('rql', '')
+        rql = rset is not None and rset.printable_rql(encoded=False) or self._cw.form.get('rql', '')
         rql = rql.replace(u"\n", u" ")
-        req = self.req
+        req = self._cw
         self.w(u'''<div id="rqlinput" class="%s">
           <form action="%s">
 <fieldset>
@@ -49,9 +49,9 @@
 <input type="submit" value="" class="rqlsubmit" tabindex="%s" />
 </fieldset>
 ''' % (not self.cw_propval('visible') and 'hidden' or '',
-       self.build_url('view'), xml_escape(rql), req._('full text or RQL query'), req.next_tabindex(),
+       self._cw.build_url('view'), xml_escape(rql), req._('full text or RQL query'), req.next_tabindex(),
         req.next_tabindex()))
-        if self.req.search_state[0] != 'normal':
+        if self._cw.search_state[0] != 'normal':
             self.w(u'<input type="hidden" name="__mode" value="%s"/>'
                    % ':'.join(req.search_state[1]))
         self.w(u'</form></div>')
@@ -66,7 +66,7 @@
 
     def call(self):
         self.w(u'<a href="%s"><img class="logo" src="%s" alt="logo"/></a>'
-               % (self.req.base_url(), self.req.external_resource('LOGO')))
+               % (self._cw.base_url(), self._cw.external_resource('LOGO')))
 
 
 class ApplHelp(component.Component):
@@ -75,8 +75,8 @@
     cw_property_defs = VISIBLE_PROP_DEF
     def call(self):
         self.w(u'<a href="%s" class="help" title="%s">&#160;</a>'
-               % (self.build_url(_restpath='doc/main'),
-                  self.req._(u'help'),))
+               % (self._cw.build_url(_restpath='doc/main'),
+                  self._cw._(u'help'),))
 
 
 class UserLink(component.Component):
@@ -89,33 +89,33 @@
     __regid__ = 'loggeduserlink'
 
     def call(self):
-        if not self.req.cnx.anonymous_connection:
+        if not self._cw.cnx.anonymous_connection:
             # display useractions and siteactions
-            actions = self.vreg['actions'].possible_actions(self.req, rset=self.rset)
+            actions = self._cw.vreg['actions'].possible_actions(self._cw, rset=self.cw_rset)
             box = MenuWidget('', 'userActionsBox', _class='', islist=False)
-            menu = PopupBoxMenu(self.req.user.login, isitem=False)
+            menu = PopupBoxMenu(self._cw.user.login, isitem=False)
             box.append(menu)
             for action in actions.get('useractions', ()):
-                menu.append(BoxLink(action.url(), self.req._(action.title),
+                menu.append(BoxLink(action.url(), self._cw._(action.title),
                                     action.html_class()))
             if actions.get('useractions') and actions.get('siteactions'):
                 menu.append(BoxSeparator())
             for action in actions.get('siteactions', ()):
-                menu.append(BoxLink(action.url(), self.req._(action.title),
+                menu.append(BoxLink(action.url(), self._cw._(action.title),
                                     action.html_class()))
             box.render(w=self.w)
         else:
             self.anon_user_link()
 
     def anon_user_link(self):
-        if self.config['auth-mode'] == 'cookie':
-            self.w(self.req._('anonymous'))
+        if self._cw.config['auth-mode'] == 'cookie':
+            self.w(self._cw._('anonymous'))
             self.w(u'''&#160;[<a class="logout" href="javascript: popupLoginBox();">%s</a>]'''
-                   % (self.req._('i18n_login_popup')))
+                   % (self._cw._('i18n_login_popup')))
         else:
-            self.w(self.req._('anonymous'))
+            self.w(self._cw._('anonymous'))
             self.w(u'&#160;[<a class="logout" href="%s">%s</a>]'
-                   % (self.build_url('login'), self.req._('login')))
+                   % (self._cw.build_url('login'), self._cw._('login')))
 
 
 class ApplicationMessage(component.Component):
@@ -128,8 +128,8 @@
     cw_property_defs = {}
 
     def call(self):
-        msgs = [msg for msg in (self.req.get_shared_data('sources_error', pop=True),
-                                self.req.message) if msg]
+        msgs = [msg for msg in (self._cw.get_shared_data('sources_error', pop=True),
+                                self._cw.message) if msg]
         self.w(u'<div id="appMsg" onclick="%s" class="%s">\n' %
                (toggle_action('appMsg'), (msgs and ' ' or 'hidden')))
         for msg in msgs:
@@ -146,10 +146,10 @@
     site_wide = True
 
     def call(self):
-        title = self.req.property_value('ui.site-title')
+        title = self._cw.property_value('ui.site-title')
         if title:
             self.w(u'<span id="appliName"><a href="%s">%s</a></span>' % (
-                self.req.base_url(), xml_escape(title)))
+                self._cw.base_url(), xml_escape(title)))
 
 
 class SeeAlsoVComponent(component.RelatedObjectsVComponent):
@@ -177,20 +177,20 @@
     visible = False # disabled by default
 
     def call(self):
-        _ = self.req._
+        _ = self._cw._
         self.w(u'<div id="etyperestriction">')
-        restrtype = self.req.form.get('__restrtype')
-        restrtypes = self.req.form.get('__restrtypes', '').split(',')
-        restrrql = self.req.form.get('__restrrql')
+        restrtype = self._cw.form.get('__restrtype')
+        restrtypes = self._cw.form.get('__restrtypes', '').split(',')
+        restrrql = self._cw.form.get('__restrrql')
         if not restrrql:
-            rqlst = self.rset.syntax_tree()
-            restrrql = rqlst.as_string(self.req.encoding, self.rset.args)
-            restrtypes = self.rset.column_types(0)
+            rqlst = self.cw_rset.syntax_tree()
+            restrrql = rqlst.as_string(self._cw.encoding, self.cw_rset.args)
+            restrtypes = self.cw_rset.column_types(0)
         else:
             rqlst = parse(restrrql)
         html = []
         on_etype = False
-        etypes = sorted((display_name(self.req, etype).capitalize(), etype)
+        etypes = sorted((display_name(self._cw, etype).capitalize(), etype)
                         for etype in restrtypes)
         for elabel, etype in etypes:
             if etype == restrtype:
@@ -200,14 +200,14 @@
                 rqlst.save_state()
                 for select in rqlst.children:
                     select.add_type_restriction(select.selection[0], etype)
-                newrql = rqlst.as_string(self.req.encoding, self.rset.args)
-                url = self.build_url(rql=newrql, __restrrql=restrrql,
-                                     __restrtype=etype, __restrtypes=','.join(restrtypes))
+                newrql = rqlst.as_string(self._cw.encoding, self.cw_rset.args)
+                url = self._cw.build_url(rql=newrql, __restrrql=restrrql,
+                                         __restrtype=etype, __restrtypes=','.join(restrtypes))
                 html.append(u'<span><a href="%s">%s</a></span>' % (
                         xml_escape(url), elabel))
                 rqlst.recover()
         if on_etype:
-            url = self.build_url(rql=restrrql)
+            url = self._cw.build_url(rql=restrrql)
             html.insert(0, u'<span><a href="%s">%s</a></span>' % (
                     url, _('Any')))
         else:
@@ -229,7 +229,7 @@
         entity = self.entity(0,0)
         url = entity.absolute_url(vid=vid, __template='pdf-main-template')
         self.w(u'<a href="%s" class="otherView"><img src="data/pdf_icon.gif" alt="%s"/></a>' %
-               (xml_escape(url), self.req._('download page as pdf')))
+               (xml_escape(url), self._cw._('download page as pdf')))
 
 
 
--- a/web/views/basecontrollers.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/basecontrollers.py	Wed Sep 23 19:40:19 2009 +0200
@@ -36,7 +36,7 @@
     results
     """
     def wrapper(self, *args, **kwargs):
-        self.req.set_content_type('application/json')
+        self._cw.set_content_type('application/json')
         return json_dumps(func(self, *args, **kwargs))
     wrapper.__name__ = func.__name__
     return wrapper
@@ -44,9 +44,9 @@
 def xhtmlize(func):
     """decorator to sets correct content_type and calls `xmlize` on results"""
     def wrapper(self, *args, **kwargs):
-        self.req.set_content_type(self.req.html_content_type())
+        self._cw.set_content_type(self._cw.html_content_type())
         result = func(self, *args, **kwargs)
-        return ''.join((self.req.document_surrounding_div(), result.strip(),
+        return ''.join((self._cw.document_surrounding_div(), result.strip(),
                         u'</div>'))
     wrapper.__name__ = func.__name__
     return wrapper
@@ -56,9 +56,9 @@
     user's session data
     """
     def wrapper(self, *args, **kwargs):
-        data = self.req.get_session_data(self.req.pageid)
+        data = self._cw.get_session_data(self._cw.pageid)
         if data is None:
-            raise RemoteCallFailed(self.req._('pageid-not-found'))
+            raise RemoteCallFailed(self._cw._('pageid-not-found'))
         return func(self, *args, **kwargs)
     return wrapper
 
@@ -68,12 +68,12 @@
 
     def publish(self, rset=None):
         """log in the instance"""
-        if self.config['auth-mode'] == 'http':
+        if self._cw.config['auth-mode'] == 'http':
             # HTTP authentication
             raise ExplicitLogin()
         else:
             # Cookie authentication
-            return self.appli.need_login_content(self.req)
+            return self.appli.need_login_content(self._cw)
 
 
 class LogoutController(Controller):
@@ -81,7 +81,7 @@
 
     def publish(self, rset=None):
         """logout from the instance"""
-        return self.appli.session_handler.logout(self.req)
+        return self.appli.session_handler.logout(self._cw)
 
 
 class ViewController(Controller):
@@ -97,12 +97,12 @@
         view, rset = self._select_view_and_rset(rset)
         self.add_to_breadcrumbs(view)
         self.validate_cache(view)
-        template = self.appli.main_template_id(self.req)
-        return self.vreg['views'].main_template(self.req, template,
+        template = self.appli.main_template_id(self._cw)
+        return self._cw.vreg['views'].main_template(self._cw, template,
                                                 rset=rset, view=view)
 
     def _select_view_and_rset(self, rset):
-        req = self.req
+        req = self._cw
         if rset is None and not hasattr(req, '_rql_processed'):
             req._rql_processed = True
             rset = self.process_rql(req.form.get('rql'))
@@ -116,14 +116,14 @@
             except Exception, ex:
                 self.exception('while handling __method')
                 req.set_message(req._("error while handling __method: %s") % req._(ex))
-        vid = req.form.get('vid') or vid_from_rset(req, rset, self.schema)
+        vid = req.form.get('vid') or vid_from_rset(req, rset, self._cw.schema)
         try:
-            view = self.vreg['views'].select(vid, req, rset=rset)
+            view = self._cw.vreg['views'].select(vid, req, rset=rset)
         except ObjectNotFound:
             self.warning("the view %s could not be found", vid)
             req.set_message(req._("The view %s could not be found") % vid)
-            vid = vid_from_rset(req, rset, self.schema)
-            view = self.vreg['views'].select(vid, req, rset=rset)
+            vid = vid_from_rset(req, rset, self._cw.schema)
+            view = self._cw.vreg['views'].select(vid, req, rset=rset)
         except NoSelectableObject:
             if rset:
                 req.set_message(req._("The view %s can not be applied to this query") % vid)
@@ -131,8 +131,8 @@
                 req.set_message(req._("You have no access to this view or it can not "
                                       "be used to display the current data."))
             self.warning("the view %s can not be applied to this query", vid)
-            vid = vid_from_rset(req, rset, self.schema)
-            view = self.vreg['views'].select(vid, req, rset=rset)
+            vid = vid_from_rset(req, rset, self._cw.schema)
+            view = self._cw.vreg['views'].select(vid, req, rset=rset)
         return view, rset
 
     def add_to_breadcrumbs(self, view):
@@ -140,11 +140,11 @@
         # specifies explicitly it should not be added to breadcrumb or the
         # view is a binary view
         if view.add_to_breadcrumbs and not view.binary:
-            self.req.update_breadcrumbs()
+            self._cw.update_breadcrumbs()
 
     def validate_cache(self, view):
         view.set_http_cache_headers()
-        self.req.validate_cache()
+        self._cw.validate_cache()
 
     def execute_linkto(self, eid=None):
         """XXX __linkto parameter may cause security issue
@@ -152,7 +152,7 @@
         defined here since custom application controller inheriting from this
         one use this method?
         """
-        req = self.req
+        req = self._cw
         if not '__linkto' in req.form:
             return
         if eid is None:
@@ -211,10 +211,10 @@
     __regid__ = 'validateform'
 
     def response(self, domid, status, args, entity):
-        callback = str(self.req.form.get('__onsuccess', 'null'))
-        errback = str(self.req.form.get('__onfailure', 'null'))
-        cbargs = str(self.req.form.get('__cbargs', 'null'))
-        self.req.set_content_type('text/html')
+        callback = str(self._cw.form.get('__onsuccess', 'null'))
+        errback = str(self._cw.form.get('__onfailure', 'null'))
+        cbargs = str(self._cw.form.get('__cbargs', 'null'))
+        self._cw.set_content_type('text/html')
         jsargs = simplejson.dumps((status, args, entity), cls=CubicWebJsonEncoder)
         return """<script type="text/javascript">
  wp = window.parent;
@@ -222,12 +222,12 @@
 </script>""" %  (domid, callback, errback, jsargs, cbargs)
 
     def publish(self, rset=None):
-        self.req.json_request = True
+        self._cw.json_request = True
         # XXX unclear why we have a separated controller here vs
         # js_validate_form on the json controller
-        status, args, entity = _validate_form(self.req, self.vreg)
-        domid = self.req.form.get('__domid', 'entityForm').encode(
-            self.req.encoding)
+        status, args, entity = _validate_form(self._cw, self._cw.vreg)
+        domid = self._cw.form.get('__domid', 'entityForm').encode(
+            self._cw.encoding)
         return self.response(domid, status, args, entity)
 
 
@@ -243,17 +243,17 @@
         note: it's the responsability of js_* methods to set the correct
         response content type
         """
-        self.req.json_request = True
-        self.req.pageid = self.req.form.get('pageid')
+        self._cw.json_request = True
+        self._cw.pageid = self._cw.form.get('pageid')
         try:
-            fname = self.req.form['fname']
+            fname = self._cw.form['fname']
             func = getattr(self, 'js_%s' % fname)
         except KeyError:
             raise RemoteCallFailed('no method specified')
         except AttributeError:
             raise RemoteCallFailed('no %s method' % fname)
         # no <arg> attribute means the callback takes no argument
-        args = self.req.form.get('arg', ())
+        args = self._cw.form.get('arg', ())
         if not isinstance(args, (list, tuple)):
             args = (args,)
         args = [simplejson.loads(arg) for arg in args]
@@ -271,7 +271,7 @@
             return ''
         # get unicode on @htmlize methods, encoded string on @jsonize methods
         elif isinstance(result, unicode):
-            return result.encode(self.req.encoding)
+            return result.encode(self._cw.encoding)
         return result
 
     def _rebuild_posted_form(self, names, values, action=None):
@@ -297,16 +297,16 @@
     def _exec(self, rql, args=None, eidkey=None, rocheck=True):
         """json mode: execute RQL and return resultset as json"""
         if rocheck:
-            self.req.ensure_ro_rql(rql)
+            self._cw.ensure_ro_rql(rql)
         try:
-            return self.req.execute(rql, args, eidkey)
+            return self._cw.execute(rql, args, eidkey)
         except Exception, ex:
             self.exception("error in _exec(rql=%s): %s", rql, ex)
             return None
         return None
 
     def _call_view(self, view, **kwargs):
-        req = self.req
+        req = self._cw
         divid = req.form.get('divid', 'pageContent')
         # we need to call pagination before with the stream set
         stream = view.set_stream()
@@ -314,7 +314,7 @@
             if divid == 'pageContent':
                 # mimick main template behaviour
                 stream.write(u'<div id="pageContent">')
-                vtitle = self.req.form.get('vtitle')
+                vtitle = self._cw.form.get('vtitle')
                 if vtitle:
                     stream.write(u'<h1 class="vtitle">%s</h1>\n' % vtitle)
             view.paginate()
@@ -333,30 +333,30 @@
     @xhtmlize
     def js_view(self):
         # XXX try to use the page-content template
-        req = self.req
+        req = self._cw
         rql = req.form.get('rql')
         if rql:
             rset = self._exec(rql)
         else:
             rset = None
-        vid = req.form.get('vid') or vid_from_rset(req, rset, self.schema)
+        vid = req.form.get('vid') or vid_from_rset(req, rset, self._cw.schema)
         try:
-            view = self.vreg['views'].select(vid, req, rset=rset)
+            view = self._cw.vreg['views'].select(vid, req, rset=rset)
         except NoSelectableObject:
             vid = req.form.get('fallbackvid', 'noresult')
-            view = self.vreg['views'].select(vid, req, rset=rset)
+            view = self._cw.vreg['views'].select(vid, req, rset=rset)
         return self._call_view(view)
 
     @xhtmlize
     def js_prop_widget(self, propkey, varname, tabindex=None):
         """specific method for CWProperty handling"""
-        entity = self.vreg['etypes'].etype_class('CWProperty')(self.req)
+        entity = self._cw.vreg['etypes'].etype_class('CWProperty')(self._cw)
         entity.eid = varname
         entity['pkey'] = propkey
-        form = self.vreg['forms'].select('edition', self.req, entity=entity)
+        form = self._cw.vreg['forms'].select('edition', self._cw, entity=entity)
         form.form_build_context()
         vfield = form.field_by_name('value')
-        renderer = FormRenderer(self.req)
+        renderer = FormRenderer(self._cw)
         return vfield.render(form, renderer, tabindex=tabindex) \
                + renderer.render_help(form, vfield)
 
@@ -366,7 +366,7 @@
             rset = self._exec(rql)
         else:
             rset = None
-        comp = self.vreg[registry].select(compid, self.req, rset=rset)
+        comp = self._cw.vreg[registry].select(compid, self._cw, rset=rset)
         if extraargs is None:
             extraargs = {}
         else: # we receive unicode keys which is not supported by the **syntax
@@ -378,7 +378,7 @@
     @check_pageid
     @xhtmlize
     def js_inline_creation_form(self, peid, ttype, rtype, role, i18nctx):
-        view = self.vreg['views'].select('inline-creation', self.req,
+        view = self._cw.vreg['views'].select('inline-creation', self._cw,
                                          etype=ttype, peid=peid, rtype=rtype,
                                          role=role)
         return self._call_view(view, etype=ttype, peid=peid,
@@ -389,8 +389,8 @@
         return self.validate_form(action, names, values)
 
     def validate_form(self, action, names, values):
-        self.req.form = self._rebuild_posted_form(names, values, action)
-        return _validate_form(self.req, self.vreg)
+        self._cw.form = self._rebuild_posted_form(names, values, action)
+        return _validate_form(self._cw, self._cw.vreg)
 
     @jsonize
     def js_edit_field(self, action, names, values, rtype, eid, default):
@@ -398,7 +398,7 @@
         if success:
             # Any X,N where we don't seem to use N is an optimisation
             # printable_value won't need to query N again
-            rset = self.req.execute('Any X,N WHERE X eid %%(x)s, X %s N' % rtype,
+            rset = self._cw.execute('Any X,N WHERE X eid %%(x)s, X %s N' % rtype,
                                     {'x': eid}, 'x')
             entity = rset.get_entity(0, 0)
             value = entity.printable_value(rtype) or default
@@ -409,14 +409,14 @@
     @jsonize
     def js_reledit_form(self, eid, rtype, role, default, lzone):
         """XXX we should get rid of this and use loadxhtml"""
-        entity = self.req.entity_from_eid(eid)
+        entity = self._cw.entity_from_eid(eid)
         return entity.view('reledit', rtype=rtype, role=role,
                            default=default, landing_zone=lzone)
 
     @jsonize
     def js_i18n(self, msgids):
         """returns the translation of `msgid`"""
-        return [self.req._(msgid) for msgid in msgids]
+        return [self._cw._(msgid) for msgid in msgids]
 
     @jsonize
     def js_format_date(self, strdate):
@@ -427,41 +427,41 @@
     @jsonize
     def js_external_resource(self, resource):
         """returns the URL of the external resource named `resource`"""
-        return self.req.external_resource(resource)
+        return self._cw.external_resource(resource)
 
     @check_pageid
     @jsonize
     def js_user_callback(self, cbname):
-        page_data = self.req.get_session_data(self.req.pageid, {})
+        page_data = self._cw.get_session_data(self._cw.pageid, {})
         try:
             cb = page_data[cbname]
         except KeyError:
             return None
-        return cb(self.req)
+        return cb(self._cw)
 
     if HAS_SEARCH_RESTRICTION:
         @jsonize
         def js_filter_build_rql(self, names, values):
             form = self._rebuild_posted_form(names, values)
-            self.req.form = form
-            builder = FilterRQLBuilder(self.req)
+            self._cw.form = form
+            builder = FilterRQLBuilder(self._cw)
             return builder.build_rql()
 
         @jsonize
         def js_filter_select_content(self, facetids, rql):
-            rqlst = self.vreg.parse(self.req, rql) # XXX Union unsupported yet
+            rqlst = self._cw.vreg.parse(self._cw, rql) # XXX Union unsupported yet
             mainvar = prepare_facets_rqlst(rqlst)[0]
             update_map = {}
             for facetid in facetids:
-                facet = get_facet(self.req, facetid, rqlst.children[0], mainvar)
+                facet = get_facet(self._cw, facetid, rqlst.children[0], mainvar)
                 update_map[facetid] = facet.possible_values()
             return update_map
 
     def js_unregister_user_callback(self, cbname):
-        self.req.unregister_callback(self.req.pageid, cbname)
+        self._cw.unregister_callback(self._cw.pageid, cbname)
 
     def js_unload_page_data(self):
-        self.req.del_session_data(self.req.pageid)
+        self._cw.del_session_data(self._cw.pageid)
 
     def js_cancel_edition(self, errorurl):
         """cancelling edition from javascript
@@ -470,21 +470,21 @@
           - errorurl
           - pending insertions / deletions
         """
-        self.req.cancel_edition(errorurl)
+        self._cw.cancel_edition(errorurl)
 
     def js_delete_bookmark(self, beid):
         rql = 'DELETE B bookmarked_by U WHERE B eid %(b)s, U eid %(u)s'
-        self.req.execute(rql, {'b': typed_eid(beid), 'u' : self.req.user.eid})
+        self._cw.execute(rql, {'b': typed_eid(beid), 'u' : self._cw.user.eid})
 
     def js_node_clicked(self, treeid, nodeeid):
         """add/remove eid in treestate cookie"""
         from cubicweb.web.views.treeview import treecookiename
-        cookies = self.req.get_cookie()
+        cookies = self._cw.get_cookie()
         statename = treecookiename(treeid)
         treestate = cookies.get(statename)
         if treestate is None:
             cookies[statename] = nodeeid
-            self.req.set_cookie(cookies, statename)
+            self._cw.set_cookie(cookies, statename)
         else:
             marked = set(filter(None, treestate.value.split(';')))
             if nodeeid in marked:
@@ -492,28 +492,28 @@
             else:
                 marked.add(nodeeid)
             cookies[statename] = ';'.join(marked)
-            self.req.set_cookie(cookies, statename)
+            self._cw.set_cookie(cookies, statename)
 
     def js_set_cookie(self, cookiename, cookievalue):
         # XXX we should consider jQuery.Cookie
         cookiename, cookievalue = str(cookiename), str(cookievalue)
-        cookies = self.req.get_cookie()
+        cookies = self._cw.get_cookie()
         cookies[cookiename] = cookievalue
-        self.req.set_cookie(cookies, cookiename)
+        self._cw.set_cookie(cookies, cookiename)
 
     # relations edition stuff ##################################################
 
     def _add_pending(self, eidfrom, rel, eidto, kind):
         key = 'pending_%s' % kind
-        pendings = self.req.get_session_data(key, set())
+        pendings = self._cw.get_session_data(key, set())
         pendings.add( (typed_eid(eidfrom), rel, typed_eid(eidto)) )
-        self.req.set_session_data(key, pendings)
+        self._cw.set_session_data(key, pendings)
 
     def _remove_pending(self, eidfrom, rel, eidto, kind):
         key = 'pending_%s' % kind
-        pendings = self.req.get_session_data(key)
+        pendings = self._cw.get_session_data(key)
         pendings.remove( (typed_eid(eidfrom), rel, typed_eid(eidto)) )
-        self.req.set_session_data(key, pendings)
+        self._cw.set_session_data(key, pendings)
 
     def js_remove_pending_insert(self, (eidfrom, rel, eidto)):
         self._remove_pending(eidfrom, rel, eidto, 'insert')
@@ -532,7 +532,7 @@
     @jsonize
     def js_add_and_link_new_entity(self, etype_to, rel, eid_to, etype_from, value_from):
         # create a new entity
-        eid_from = self.req.execute('INSERT %s T : T name "%s"' % ( etype_from, value_from ))[0][0]
+        eid_from = self._cw.execute('INSERT %s T : T name "%s"' % ( etype_from, value_from ))[0][0]
         # link the new entity to the main entity
         rql = 'SET F %(rel)s T WHERE F eid %(eid_to)s, T eid %(eid_from)s' % {'rel' : rel, 'eid_to' : eid_to, 'eid_from' : eid_from}
         return eid_from
@@ -544,12 +544,12 @@
 
     def recipients(self):
         """returns an iterator on email's recipients as entities"""
-        eids = self.req.form['recipient']
+        eids = self._cw.form['recipient']
         # make sure we have a list even though only one recipient was specified
         if isinstance(eids, basestring):
             eids = (eids,)
         rql = 'Any X WHERE X eid in (%s)' % (','.join(eids))
-        rset = self.req.execute(rql)
+        rset = self._cw.execute(rql)
         for entity in rset.entities():
             entity.complete() # XXX really?
             yield entity
@@ -557,33 +557,33 @@
     @property
     @cached
     def smtp(self):
-        mailhost, port = self.config['smtp-host'], self.config['smtp-port']
+        mailhost, port = self._cw.config['smtp-host'], self._cw.config['smtp-port']
         try:
             return SMTP(mailhost, port)
         except Exception, ex:
             self.exception("can't connect to smtp server %s:%s (%s)",
                              mailhost, port, ex)
-            url = self.build_url(__message=self.req._('could not connect to the SMTP server'))
+            url = self.build_url(__message=self._cw._('could not connect to the SMTP server'))
             raise Redirect(url)
 
     def sendmail(self, recipient, subject, body):
-        helo_addr = '%s <%s>' % (self.config['sender-name'],
-                                 self.config['sender-addr'])
-        msg = format_mail({'email' : self.req.user.get_email(),
-                           'name' : self.req.user.dc_title(),},
+        helo_addr = '%s <%s>' % (self._cw.config['sender-name'],
+                                 self._cw.config['sender-addr'])
+        msg = format_mail({'email' : self._cw.user.get_email(),
+                           'name' : self._cw.user.dc_title(),},
                           [recipient], body, subject)
         self.smtp.sendmail(helo_addr, [recipient], msg.as_string())
 
     def publish(self, rset=None):
         # XXX this allows users with access to an cubicweb instance to use it as
         # a mail relay
-        body = self.req.form['mailbody']
-        subject = self.req.form['subject']
+        body = self._cw.form['mailbody']
+        subject = self._cw.form['subject']
         for recipient in self.recipients():
             text = body % recipient.as_email_context()
             self.sendmail(recipient.get_email(), subject, text)
-        # breadcrumbs = self.req.get_session_data('breadcrumbs', None)
-        url = self.build_url(__message=self.req._('emails successfully sent'))
+        # breadcrumbs = self._cw.get_session_data('breadcrumbs', None)
+        url = self.build_url(__message=self._cw._('emails successfully sent'))
         raise Redirect(url)
 
 
@@ -592,8 +592,8 @@
     __select__ = yes()
 
     def publish(self, rset=None):
-        body = self.req.form['description']
-        self.sendmail(self.config['submit-mail'], _('%s error report') % self.config.appid, body)
-        url = self.build_url(__message=self.req._('bug report sent'))
+        body = self._cw.form['description']
+        self.sendmail(self._cw.config['submit-mail'], _('%s error report') % self._cw.config.appid, body)
+        url = self.build_url(__message=self._cw._('bug report sent'))
         raise Redirect(url)
 
--- a/web/views/basetemplates.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/basetemplates.py	Wed Sep 23 19:40:19 2009 +0200
@@ -24,7 +24,7 @@
         self.set_request_content_type()
         w = self.w
         self.write_doctype()
-        self.template_header('text/html', self.req._('login_action'))
+        self.template_header('text/html', self._cw._('login_action'))
         w(u'<body>\n')
         self.content(w)
         w(u'</body>')
@@ -32,13 +32,13 @@
     def template_header(self, content_type, view=None, page_title='', additional_headers=()):
         w = self.whead
         # explictly close the <base> tag to avoid IE 6 bugs while browsing DOM
-        w(u'<base href="%s"></base>' % xml_escape(self.req.base_url()))
+        w(u'<base href="%s"></base>' % xml_escape(self._cw.base_url()))
         w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n'
-          % (content_type, self.req.encoding))
+          % (content_type, self._cw.encoding))
         w(NOINDEX)
         w(NOFOLLOW)
         w(u'\n'.join(additional_headers) + u'\n')
-        self.wview('htmlheader', rset=self.rset)
+        self.wview('htmlheader', rset=self.cw_rset)
         w(u'<title>%s</title>\n' % xml_escape(page_title))
 
 
@@ -47,7 +47,7 @@
     title = 'log in'
 
     def content(self, w):
-        self.wview('logform', rset=self.rset, id='loginBox', klass='')
+        self.wview('logform', rset=self.cw_rset, id='loginBox', klass='')
 
 
 class LoggedOutTemplate(LogInOutTemplate):
@@ -56,13 +56,13 @@
 
     def content(self, w):
         # FIXME Deprecated code ?
-        msg = self.req._('you have been logged out')
+        msg = self._cw._('you have been logged out')
         w(u'<h2>%s</h2>\n' % msg)
-        if self.config['anonymous-user']:
+        if self._cw.config['anonymous-user']:
             indexurl = self.build_url('view', vid='index', __message=msg)
             w(u'<p><a href="%s">%s</a><p>' % (
                 xml_escape(indexurl),
-                self.req._('go back to the index page')))
+                self._cw._('go back to the index page')))
 
 @objectify_selector
 def templatable_view(cls, req, rset, *args, **kwargs):
@@ -84,9 +84,9 @@
     def call(self, view):
         view.set_request_content_type()
         view.set_stream()
-        if (self.req.form.has_key('__notemplate') and view.templatable
-            and view.content_type == self.req.html_content_type()):
-            view.w(self.req.document_surrounding_div())
+        if (self._cw.form.has_key('__notemplate') and view.templatable
+            and view.content_type == self._cw.html_content_type()):
+            view.w(self._cw.document_surrounding_div())
             view.render()
             view.w(u'</div>')
         else:
@@ -109,12 +109,12 @@
         self.template_header(self.content_type, view)
         w = self.w
         w(u'<div id="pageContent">\n')
-        vtitle = self.req.form.get('vtitle')
+        vtitle = self._cw.form.get('vtitle')
         if vtitle:
             w(u'<h1 class="vtitle">%s</h1>\n' % xml_escape(vtitle))
         # display entity type restriction component
-        etypefilter = self.vreg['components'].select_or_none(
-            'etypenavigation', self.req, rset=self.rset)
+        etypefilter = self._cw.vreg['components'].select_or_none(
+            'etypenavigation', self._cw, rset=self.cw_rset)
         if etypefilter and etypefilter.cw_propval('visible'):
             etypefilter.render(w=w)
         self.nav_html = UStringIO()
@@ -136,29 +136,29 @@
 
     def template_html_header(self, content_type, page_title, additional_headers=()):
         w = self.whead
-        lang = self.req.lang
+        lang = self._cw.lang
         self.write_doctype()
         # explictly close the <base> tag to avoid IE 6 bugs while browsing DOM
-        w(u'<base href="%s"></base>' % xml_escape(self.req.base_url()))
+        w(u'<base href="%s"></base>' % xml_escape(self._cw.base_url()))
         w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n'
-          % (content_type, self.req.encoding))
+          % (content_type, self._cw.encoding))
         w(u'\n'.join(additional_headers) + u'\n')
-        self.wview('htmlheader', rset=self.rset)
+        self.wview('htmlheader', rset=self.cw_rset)
         if page_title:
             w(u'<title>%s</title>\n' % xml_escape(page_title))
 
     def template_body_header(self, view):
         w = self.w
         w(u'<body>\n')
-        self.wview('header', rset=self.rset, view=view)
+        self.wview('header', rset=self.cw_rset, view=view)
         w(u'<div id="page"><table width="100%" border="0" id="mainLayout"><tr>\n')
         self.nav_column(view, 'left')
         w(u'<td id="contentcol">\n')
-        components = self.vreg['components']
-        rqlcomp = components.select_or_none('rqlinput', self.req, rset=self.rset)
+        components = self._cw.vreg['components']
+        rqlcomp = components.select_or_none('rqlinput', self._cw, rset=self.cw_rset)
         if rqlcomp:
             rqlcomp.render(w=self.w, view=view)
-        msgcomp = components.select_or_none('applmessages', self.req, rset=self.rset)
+        msgcomp = components.select_or_none('applmessages', self._cw, rset=self.cw_rset)
         if msgcomp:
             msgcomp.render(w=self.w)
         self.content_header(view)
@@ -168,12 +168,12 @@
         self.w(u'</td>\n')
         self.nav_column(view, 'right')
         self.w(u'</tr></table></div>\n')
-        self.wview('footer', rset=self.rset)
+        self.wview('footer', rset=self.cw_rset)
         self.w(u'</body>')
 
     def nav_column(self, view, context):
-        boxes = list(self.vreg['boxes'].poss_visible_objects(
-            self.req, rset=self.rset, view=view, context=context))
+        boxes = list(self._cw.vreg['boxes'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, view=view, context=context))
         if boxes:
             self.w(u'<td class="navcol"><div class="navboxes">\n')
             for box in boxes:
@@ -182,10 +182,10 @@
 
     def content_header(self, view=None):
         """by default, display informal messages in content header"""
-        self.wview('contentheader', rset=self.rset, view=view)
+        self.wview('contentheader', rset=self.cw_rset, view=view)
 
     def content_footer(self, view=None):
-        self.wview('contentfooter', rset=self.rset, view=view)
+        self.wview('contentfooter', rset=self.cw_rset, view=view)
 
 
 class ErrorTemplate(TheMainTemplate):
@@ -198,21 +198,21 @@
     def call(self):
         """display an unexpected error"""
         self.set_request_content_type()
-        self.req.reset_headers()
-        view = self.vreg['views'].select('error', self.req, rset=self.rset)
-        self.template_header(self.content_type, view, self.req._('an error occured'),
+        self._cw.reset_headers()
+        view = self._cw.vreg['views'].select('error', self._cw, rset=self.cw_rset)
+        self.template_header(self.content_type, view, self._cw._('an error occured'),
                              [NOINDEX, NOFOLLOW])
         view.render(w=self.w)
         self.template_footer(view)
 
     def template_header(self, content_type, view=None, page_title='', additional_headers=()):
         w = self.whead
-        lang = self.req.lang
+        lang = self._cw.lang
         self.write_doctype()
         w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n'
-          % (content_type, self.req.encoding))
+          % (content_type, self._cw.encoding))
         w(u'\n'.join(additional_headers))
-        self.wview('htmlheader', rset=self.rset)
+        self.wview('htmlheader', rset=self.cw_rset)
         w(u'<title>%s</title>\n' % xml_escape(page_title))
         self.w(u'<body>\n')
 
@@ -228,12 +228,12 @@
         page_title = page_title or view.page_title()
         additional_headers = additional_headers or view.html_headers()
         whead = self.whead
-        lang = self.req.lang
+        lang = self._cw.lang
         self.write_doctype()
         whead(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n'
-              % (content_type, self.req.encoding))
+              % (content_type, self._cw.encoding))
         whead(u'\n'.join(additional_headers) + u'\n')
-        self.wview('htmlheader', rset=self.rset)
+        self.wview('htmlheader', rset=self.cw_rset)
         w = self.w
         w(u'<title>%s</title>\n' % xml_escape(page_title))
         w(u'<body>\n')
@@ -241,8 +241,8 @@
         w(u'<table width="100%" height="100%" border="0"><tr>\n')
         w(u'<td class="navcol">\n')
         self.topleft_header()
-        boxes = list(self.vreg['boxes'].poss_visible_objects(
-            self.req, rset=self.rset, view=view, context='left'))
+        boxes = list(self._cw.vreg['boxes'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, view=view, context='left'))
         if boxes:
             w(u'<div class="navboxes">\n')
             for box in boxes:
@@ -251,13 +251,13 @@
         w(u'</td>')
         w(u'<td id="contentcol" rowspan="2">')
         w(u'<div id="pageContent">\n')
-        vtitle = self.req.form.get('vtitle')
+        vtitle = self._cw.form.get('vtitle')
         if vtitle:
             w(u'<h1 class="vtitle">%s</h1>' % xml_escape(vtitle))
 
     def topleft_header(self):
-        logo = self.vreg['components'].select_or_none('logo', self.req,
-                                                      rset=self.rset)
+        logo = self._cw.vreg['components'].select_or_none('logo', self._cw,
+                                                      rset=self.cw_rset)
         if logo and logo.cw_propval('visible'):
             self.w(u'<table id="header"><tr>\n')
             self.w(u'<td>')
@@ -279,9 +279,9 @@
             """build the standard view, then when it's all done, convert xhtml to pdf
             """
             super(PdfMainTemplate, self).call(view)
-            section = self.req.form.pop('section', 'contentmain')
+            section = self._cw.form.pop('section', 'contentmain')
             pdf = self.to_pdf(self._stream, section)
-            self.req.set_content_type('application/pdf', filename='report.pdf')
+            self._cw.set_content_type('application/pdf', filename='report.pdf')
             self.binary = True
             self.w = None
             self.set_stream()
@@ -318,12 +318,12 @@
         self.pageid()
 
     def favicon(self):
-        favicon = self.req.external_resource('FAVICON', None)
+        favicon = self._cw.external_resource('FAVICON', None)
         if favicon:
             self.whead(u'<link rel="shortcut icon" href="%s"/>\n' % favicon)
 
     def stylesheets(self):
-        req = self.req
+        req = self._cw
         add_css = req.add_css
         for css in req.external_resource('STYLESHEETS'):
             add_css(css, localfile=False)
@@ -333,18 +333,18 @@
             add_css(css, localfile=False, ieonly=True)
 
     def javascripts(self):
-        for jscript in self.req.external_resource('JAVASCRIPTS'):
-            self.req.add_js(jscript, localfile=False)
+        for jscript in self._cw.external_resource('JAVASCRIPTS'):
+            self._cw.add_js(jscript, localfile=False)
 
     def alternates(self):
-        urlgetter = self.vreg['components'].select_or_none('rss_feed_url',
-                                                           self.req, rset=self.rset)
+        urlgetter = self._cw.vreg['components'].select_or_none('rss_feed_url',
+                                                           self._cw, rset=self.cw_rset)
         if urlgetter is not None:
             self.whead(u'<link rel="alternate" type="application/rss+xml" title="RSS feed" href="%s"/>\n'
                        %  xml_escape(urlgetter.feed_url()))
 
     def pageid(self):
-        req = self.req
+        req = self._cw
         pid = make_uid(id(req))
         req.pageid = pid
         req.html_headers.define_var('pageid', pid)
@@ -368,28 +368,28 @@
         """build the top menu with authentification info and the rql box"""
         self.w(u'<table id="header"><tr>\n')
         self.w(u'<td id="firstcolumn">')
-        logo = self.vreg['components'].select_or_none(
-            'logo', self.req, rset=self.rset)
+        logo = self._cw.vreg['components'].select_or_none(
+            'logo', self._cw, rset=self.cw_rset)
         if logo and logo.cw_propval('visible'):
             logo.render(w=self.w)
         self.w(u'</td>\n')
         # appliname and breadcrumbs
         self.w(u'<td id="headtext">')
         for cid in self.main_cell_components:
-            comp = self.vreg['components'].select_or_none(
-                cid, self.req, rset=self.rset)
+            comp = self._cw.vreg['components'].select_or_none(
+                cid, self._cw, rset=self.cw_rset)
             if comp and comp.cw_propval('visible'):
                 comp.render(w=self.w)
         self.w(u'</td>')
         # logged user and help
         self.w(u'<td>\n')
-        comp = self.vreg['components'].select_or_none(
-            'loggeduserlink', self.req, rset=self.rset)
+        comp = self._cw.vreg['components'].select_or_none(
+            'loggeduserlink', self._cw, rset=self.cw_rset)
         if comp and comp.cw_propval('visible'):
             comp.render(w=self.w)
         self.w(u'</td><td>')
-        helpcomp = self.vreg['components'].select_or_none(
-            'help', self.req, rset=self.rset)
+        helpcomp = self._cw.vreg['components'].select_or_none(
+            'help', self._cw, rset=self.cw_rset)
         if helpcomp and helpcomp.cw_propval('visible'):
             helpcomp.render(w=self.w)
         self.w(u'</td>')
@@ -397,20 +397,20 @@
         self.w(u'<td id="lastcolumn">')
         self.w(u'</td>\n')
         self.w(u'</tr></table>\n')
-        self.wview('logform', rset=self.rset, id='popupLoginBox', klass='hidden',
+        self.wview('logform', rset=self.cw_rset, id='popupLoginBox', klass='hidden',
                    title=False, message=False)
 
     def state_header(self):
-        state = self.req.search_state
+        state = self._cw.search_state
         if state[0] == 'normal':
             return
-        _ = self.req._
-        value = self.view('oneline', self.req.eid_rset(state[1][1]))
+        _ = self._cw._
+        value = self.view('oneline', self._cw.eid_rset(state[1][1]))
         msg = ' '.join((_("searching for"),
-                        display_name(self.req, state[1][3]),
+                        display_name(self._cw, state[1][3]),
                         _("to associate with"), value,
                         _("by relation"), '"',
-                        display_name(self.req, state[1][2], state[1][0]),
+                        display_name(self._cw, state[1][2], state[1][0]),
                         '"'))
         return self.w(u'<div class="stateMessage">%s</div>' % msg)
 
@@ -422,7 +422,7 @@
     __regid__ = 'footer'
 
     def call(self, **kwargs):
-        req = self.req
+        req = self._cw
         self.w(u'<div class="footer">')
         # XXX Take object from the registry if in there? would be
         #     better anyway
@@ -444,8 +444,8 @@
 
     def call(self, view, **kwargs):
         """by default, display informal messages in content header"""
-        components = self.vreg['contentnavigation'].poss_visible_objects(
-            self.req, rset=self.rset, view=view, context='navtop')
+        components = self._cw.vreg['contentnavigation'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, view=view, context='navtop')
         if components:
             self.w(u'<div id="contentheader">')
             for comp in components:
@@ -460,8 +460,8 @@
     __regid__ = 'contentfooter'
 
     def call(self, view, **kwargs):
-        components = self.vreg['contentnavigation'].poss_visible_objects(
-            self.req, rset=self.rset, view=view, context='navbottom')
+        components = self._cw.vreg['contentnavigation'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, view=view, context='navbottom')
         if components:
             self.w(u'<div id="contentfooter">')
             for comp in components:
@@ -476,10 +476,10 @@
     title = 'log in'
 
     def call(self, id, klass, title=True, message=True):
-        self.req.add_css('cubicweb.login.css')
+        self._cw.add_css('cubicweb.login.css')
         self.w(u'<div id="%s" class="%s">' % (id, klass))
         if title:
-            stitle = self.req.property_value('ui.site-title')
+            stitle = self._cw.property_value('ui.site-title')
             if stitle:
                 stitle = xml_escape(stitle)
             else:
@@ -489,7 +489,7 @@
 
         if message:
             self.display_message()
-        if self.config['auth-mode'] == 'http':
+        if self._cw.config['auth-mode'] == 'http':
             # HTTP authentication
             pass
         else:
@@ -498,17 +498,17 @@
         self.w(u'</div></div>\n')
 
     def display_message(self):
-        message = self.req.message
+        message = self._cw.message
         if message:
             self.w(u'<div class="simpleMessage">%s</div>\n' % message)
 
     def login_form(self, id):
-        _ = self.req._
+        _ = self._cw._
         self.w(u'<form method="post" action="%s" id="login_form">\n'
-               % xml_escape(login_form_url(self.config, self.req)))
+               % xml_escape(login_form_url(self._cw.config, self._cw)))
         self.w(u'<table>\n')
         self.w(u'<tr>\n')
-        msg = (self.config['allow-email-login'] and _('login or email')) or _('login')
+        msg = (self._cw.config['allow-email-login'] and _('login or email')) or _('login')
         self.w(u'<td><label for="__login">%s</label></td>' % msg)
         self.w(u'<td><input name="__login" id="__login" class="data" type="text" /></td>')
         self.w(u'</tr><tr>\n')
@@ -519,7 +519,7 @@
         self.w(u'</tr>\n')
         self.w(u'</table>\n')
         self.w(u'</form>\n')
-        self.req.html_headers.add_onload('jQuery("#__login:visible").focus()')
+        self._cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
 
 
 def login_form_url(config, req):
--- a/web/views/baseviews.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/baseviews.py	Wed Sep 23 19:40:19 2009 +0200
@@ -44,7 +44,7 @@
 
     def call(self, **kwargs):
         self.w(u'<div class="searchMessage"><strong>%s</strong></div>\n'
-               % self.req._('No result matching query'))
+               % self._cw._('No result matching query'))
 
 
 class FinalView(AnyRsetView):
@@ -69,11 +69,11 @@
     _('%d seconds')
 
     def cell_call(self, row, col, props=None, format='text/html'):
-        etype = self.rset.description[row][col]
-        value = self.rset.rows[row][col]
+        etype = self.cw_rset.description[row][col]
+        value = self.cw_rset.rows[row][col]
 
         if etype == 'String':
-            entity, rtype = self.rset.related_entity(row, col)
+            entity, rtype = self.cw_rset.related_entity(row, col)
             if entity is not None:
                 # yes !
                 self.w(entity.printable_value(rtype, value, format=format))
@@ -93,21 +93,21 @@
             else:
                 space = ' '
             if value.days > 730: # 2 years
-                self.w(self.req.__('%%d%syears' % space) % (value.days // 365))
+                self.w(self._cw.__('%%d%syears' % space) % (value.days // 365))
             elif value.days > 60: # 2 months
-                self.w(self.req.__('%%d%smonths' % space) % (value.days // 30))
+                self.w(self._cw.__('%%d%smonths' % space) % (value.days // 30))
             elif value.days > 14: # 2 weeks
-                self.w(self.req.__('%%d%sweeks' % space) % (value.days // 7))
+                self.w(self._cw.__('%%d%sweeks' % space) % (value.days // 7))
             elif value.days > 2:
-                self.w(self.req.__('%%d%sdays' % space) % int(value.days))
+                self.w(self._cw.__('%%d%sdays' % space) % int(value.days))
             elif value.seconds > 3600:
-                self.w(self.req.__('%%d%shours' % space) % int(value.seconds // 3600))
+                self.w(self._cw.__('%%d%shours' % space) % int(value.seconds // 3600))
             elif value.seconds >= 120:
-                self.w(self.req.__('%%d%sminutes' % space) % int(value.seconds // 60))
+                self.w(self._cw.__('%%d%sminutes' % space) % int(value.seconds // 60))
             else:
-                self.w(self.req.__('%%d%sseconds' % space) % int(value.seconds))
+                self.w(self._cw.__('%%d%sseconds' % space) % int(value.seconds))
             return
-        self.wdata(printable_value(self.req, etype, value, props))
+        self.wdata(printable_value(self._cw, etype, value, props))
 
 
 # XXX deprecated
@@ -119,9 +119,9 @@
         """the secondary view for an entity
         secondary = icon + view(oneline)
         """
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(u'&#160;')
-        self.wview('oneline', self.rset, row=row, col=col)
+        self.wview('oneline', self.cw_rset, row=row, col=col)
 
 
 class OneLineView(EntityView):
@@ -131,9 +131,9 @@
     def cell_call(self, row, col):
         """the one line view for an entity: linked text view
         """
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(u'<a href="%s">' % xml_escape(entity.absolute_url()))
-        self.w(xml_escape(self.view('text', self.rset, row=row, col=col)))
+        self.w(xml_escape(self._cw.view('text', self.cw_rset, row=row, col=col)))
         self.w(u'</a>')
 
 
@@ -150,11 +150,11 @@
 
         Views applicable on None result sets have to override this method
         """
-        rset = self.rset
+        rset = self.cw_rset
         if rset is None:
             raise NotImplementedError, self
         for i in xrange(len(rset)):
-            self.wview(self.id, rset, row=i, **kwargs)
+            self.wview(self.__regid__, rset, row=i, **kwargs)
             if len(rset) > 1:
                 self.w(u"\n")
 
@@ -170,20 +170,20 @@
     show_eid = True
 
     def cell_call(self, row, col):
-        _ = self.req._
-        entity = self.rset.get_entity(row, col)
+        _ = self._cw._
+        entity = self.cw_rset.get_entity(row, col)
         self.w(u'<div class="metadata">')
         if self.show_eid:
             self.w(u'#%s - ' % entity.eid)
         if entity.modification_date != entity.creation_date:
             self.w(u'<span>%s</span> ' % _('latest update on'))
             self.w(u'<span class="value">%s</span>, '
-                   % self.format_date(entity.modification_date))
+                   % self._cw.format_date(entity.modification_date))
         # entities from external source may not have a creation date (eg ldap)
         if entity.creation_date:
             self.w(u'<span>%s</span> ' % _('created on'))
             self.w(u'<span class="value">%s</span>'
-                   % self.format_date(entity.creation_date))
+                   % self._cw.format_date(entity.creation_date))
         if entity.creator:
             self.w(u' <span>%s</span> ' % _('by'))
             self.w(u'<span class="value">%s</span>' % entity.creator.name())
@@ -194,7 +194,7 @@
     __regid__ = 'textincontext'
     title = None # not listed as a possible view
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(entity.dc_title())
 
 
@@ -202,7 +202,7 @@
     __regid__ = 'textoutofcontext'
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(entity.dc_long_title())
 
 
@@ -210,12 +210,12 @@
     __regid__ = 'incontext'
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         desc = cut(entity.dc_description(), 50)
         self.w(u'<a href="%s" title="%s">' % (
             xml_escape(entity.absolute_url()), xml_escape(desc)))
-        self.w(xml_escape(self.view('textincontext', self.rset,
-                                     row=row, col=col)))
+        self.w(xml_escape(self._cw.view('textincontext', self.cw_rset,
+                                        row=row, col=col)))
         self.w(u'</a>')
 
 
@@ -223,12 +223,12 @@
     __regid__ = 'outofcontext'
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         desc = cut(entity.dc_description(), 50)
         self.w(u'<a href="%s" title="%s">' % (
             xml_escape(entity.absolute_url()), xml_escape(desc)))
-        self.w(xml_escape(self.view('textoutofcontext', self.rset,
-                                     row=row, col=col)))
+        self.w(xml_escape(self._cw.view('textoutofcontext', self.cw_rset,
+                                        row=row, col=col)))
         self.w(u'</a>')
 
 
@@ -245,8 +245,8 @@
         :param listid: the DOM id to use for the root element
         """
         # XXX much of the behaviour here should probably be outside this view
-        if subvid is None and 'subvid' in self.req.form:
-            subvid = self.req.form.pop('subvid') # consume it
+        if subvid is None and 'subvid' in self._cw.form:
+            subvid = self._cw.form.pop('subvid') # consume it
         if listid:
             listid = u' id="%s"' % listid
         else:
@@ -256,7 +256,7 @@
             self.w(u'<ul>\n')
         else:
             self.w(u'<ul%s class="%s">\n' % (listid, klass or 'section'))
-        for i in xrange(self.rset.rowcount):
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(row=i, col=0, vid=subvid, **kwargs)
         self.w(u'</ul>\n')
         if title:
@@ -264,7 +264,7 @@
 
     def cell_call(self, row, col=0, vid=None, **kwargs):
         self.w(u'<li>')
-        self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs)
+        self.wview(self.item_vid, self.cw_rset, row=row, col=col, vid=vid, **kwargs)
         self.w(u'</li>\n')
 
 
@@ -273,7 +273,7 @@
 
     @property
     def redirect_vid(self):
-        if self.req.search_state[0] == 'normal':
+        if self._cw.search_state[0] == 'normal':
             return 'outofcontext'
         return 'outofcontext-search'
 
@@ -281,11 +281,11 @@
         if not vid:
             vid = self.redirect_vid
         try:
-            self.wview(vid, self.rset, row=row, col=col, **kwargs)
+            self.wview(vid, self.cw_rset, row=row, col=col, **kwargs)
         except NoSelectableObject:
             if vid == self.redirect_vid:
                 raise
-            self.wview(self.redirect_vid, self.rset, row=row, col=col, **kwargs)
+            self.wview(self.redirect_vid, self.cw_rset, row=row, col=col, **kwargs)
 
 
 class SimpleListView(ListItemView):
@@ -302,17 +302,17 @@
 
     @property
     def title(self):
-        etype = iter(self.rset.column_types(0)).next()
-        return display_name(self.req, etype, form='plural')
+        etype = iter(self.cw_rset.column_types(0)).next()
+        return display_name(self._cw, etype, form='plural')
 
     def call(self, **kwargs):
         """display a list of entities by calling their <item_vid> view"""
-        if not 'vtitle' in self.req.form:
+        if not 'vtitle' in self._cw.form:
             self.w(u'<h1>%s</h1>' % self.title)
         super(AdaptedListView, self).call(**kwargs)
 
     def cell_call(self, row, col=0, vid=None, **kwargs):
-        self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs)
+        self.wview(self.item_vid, self.cw_rset, row=row, col=col, vid=vid, **kwargs)
 
 
 class AdaptedListItemView(ListItemView):
@@ -324,7 +324,7 @@
     redirect_vid = 'incontext'
 
     def call(self, **kwargs):
-        rset = self.rset
+        rset = self.cw_rset
         for i in xrange(len(rset)):
             self.cell_call(i, 0, vid=kwargs.get('vid'))
             if i < rset.rowcount-1:
@@ -335,7 +335,7 @@
     __regid__ = 'treeitem'
 
     def cell_call(self, row, col):
-        self.wview('incontext', self.rset, row=row, col=col)
+        self.wview('incontext', self.cw_rset, row=row, col=col)
 
 class TextSearchResultView(EntityView):
     """this view is used to display full-text search
@@ -347,9 +347,9 @@
     __regid__ = 'tsearch'
 
     def cell_call(self, row, col, **kwargs):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         self.w(entity.view('incontext'))
-        searched = self.rset.searched_text()
+        searched = self.cw_rset.searched_text()
         if searched is None:
             return
         searched = searched.lower()
@@ -376,7 +376,7 @@
     """A entity view used in a tooltip"""
     __regid__ = 'tooltip'
     def cell_call(self, row, col):
-        self.wview('oneline', self.rset, row=row, col=col)
+        self.wview('oneline', self.cw_rset, row=row, col=col)
 
 
 # XXX bw compat
--- a/web/views/bookmark.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/bookmark.py	Wed Sep 23 19:40:19 2009 +0200
@@ -27,7 +27,7 @@
     category = 'mainactions'
 
     def url(self):
-        return self.rset.get_entity(self.row or 0, self.col or 0).actual_url()
+        return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).actual_url()
 
 
 class BookmarkPrimaryView(primary.PrimaryView):
@@ -35,15 +35,15 @@
 
     def cell_call(self, row, col):
         """the primary view for bookmark entity"""
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         self.w(u'&#160;')
         self.w(u"<span class='title'><b>")
-        self.w(u"%s : %s" % (self.req._('Bookmark'), xml_escape(entity.title)))
+        self.w(u"%s : %s" % (self._cw._('Bookmark'), xml_escape(entity.title)))
         self.w(u"</b></span>")
         self.w(u'<br/><br/><div class="content"><a href="%s">' % (
             xml_escape(entity.actual_url())))
         self.w(u'</a>')
-        self.w(u'<p>%s%s</p>' % (self.req._('Used by:'), ', '.join(xml_escape(u.name())
+        self.w(u'<p>%s%s</p>' % (self._cw._('Used by:'), ', '.join(xml_escape(u.name())
                                                                    for u in entity.bookmarked_by)))
         self.w(u'</div>')
 
@@ -61,17 +61,17 @@
 
 
     def call(self, **kwargs):
-        req = self.req
+        req = self._cw
         ueid = req.user.eid
         try:
             rset = req.execute(self.rql, {'x': ueid})
         except Unauthorized:
             # can't access to something in the query, forget this box
             return
-        box = BoxWidget(req._(self.title), self.id)
+        box = BoxWidget(req._(self.title), self.__regid__)
         box.listing_class = 'sideBox'
-        rschema = self.schema.rschema(self.rtype)
-        eschema = self.schema.eschema(self.etype)
+        rschema = self._cw.schema.rschema(self.rtype)
+        eschema = self._cw.schema.eschema(self.etype)
         candelete = rschema.has_perm(req, 'delete', toeid=ueid)
         if candelete:
             req.add_js( ('cubicweb.ajax.js', 'cubicweb.bookmarks.js') )
@@ -105,11 +105,11 @@
                                                 build_descr=False)
                     bookmarksrql %= {'x': ueid}
                 if erset:
-                    url = self.build_url(vid='muledit', rql=bookmarksrql)
-                    boxmenu.append(self.mk_action(self.req._('edit bookmarks'), url, category='manage'))
+                    url = self._cw.build_url(vid='muledit', rql=bookmarksrql)
+                    boxmenu.append(self.mk_action(self._cw._('edit bookmarks'), url, category='manage'))
             url = req.user.absolute_url(vid='xaddrelation', rtype='bookmarked_by',
                                         target='subject')
-            boxmenu.append(self.mk_action(self.req._('pick existing bookmarks'), url, category='manage'))
+            boxmenu.append(self.mk_action(self._cw._('pick existing bookmarks'), url, category='manage'))
             box.append(boxmenu)
         if not box.is_empty():
             box.render(self.w)
--- a/web/views/boxes.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/boxes.py	Wed Sep 23 19:40:19 2009 +0200
@@ -40,19 +40,19 @@
     order = 2
 
     def call(self, view=None, **kwargs):
-        _ = self.req._
+        _ = self._cw._
         title = _(self.title)
-        if self.rset:
-            etypes = self.rset.column_types(0)
+        if self.cw_rset:
+            etypes = self.cw_rset.column_types(0)
             if len(etypes) == 1:
-                plural = self.rset.rowcount > 1 and 'plural' or ''
-                etypelabel = display_name(self.req, iter(etypes).next(), plural)
+                plural = self.cw_rset.rowcount > 1 and 'plural' or ''
+                etypelabel = display_name(self._cw, iter(etypes).next(), plural)
                 title = u'%s - %s' % (title, etypelabel.lower())
-        box = BoxWidget(title, self.id, _class="greyBoxFrame")
+        box = BoxWidget(title, self.__regid__, _class="greyBoxFrame")
         self._menus_in_order = []
         self._menus_by_id = {}
         # build list of actions
-        actions = self.vreg['actions'].possible_actions(self.req, self.rset,
+        actions = self._cw.vreg['actions'].possible_actions(self._cw, self.cw_rset,
                                                         view=view)
         other_menu = self._get_menu('moreactions', _('more actions'))
         for category, defaultmenu in (('mainactions', box),
@@ -85,7 +85,7 @@
             return self._menus_by_id[id]
         except KeyError:
             if title is None:
-                title = self.req._(id)
+                title = self._cw._(id)
             self._menus_by_id[id] = menu = BoxMenu(title)
             menu.label_prefix = label_prefix
             self._menus_in_order.append(menu)
@@ -122,7 +122,7 @@
 </form>"""
 
     def call(self, view=None, **kwargs):
-        req = self.req
+        req = self._cw
         if req.form.pop('__fromsearchbox', None):
             rql = req.form.get('rql', '')
         else:
@@ -130,7 +130,7 @@
         form = self.formdef % (req.build_url('view'), req.next_tabindex(),
                                xml_escape(rql), req.next_tabindex())
         title = u"""<span onclick="javascript: toggleVisibility('rqlinput')">%s</span>""" % req._(self.title)
-        box = BoxWidget(title, self.id, _class="searchBoxFrame", islist=False, escape=False)
+        box = BoxWidget(title, self.__regid__, _class="searchBoxFrame", islist=False, escape=False)
         box.append(BoxHtml(form))
         box.render(self.w)
 
@@ -147,9 +147,9 @@
     order = 10
 
     def call(self, **kwargs):
-        box = BoxWidget(self.req._(self.title), self.id)
-        views = [v for v in self.vreg['views'].possible_views(self.req,
-                                                              rset=self.rset)
+        box = BoxWidget(self._cw._(self.title), self.__regid__)
+        views = [v for v in self._cw.vreg['views'].possible_views(self._cw,
+                                                              rset=self.cw_rset)
                  if v.category != 'startupview']
         for category, views in self.sort_actions(views):
             menu = BoxMenu(category)
@@ -168,8 +168,8 @@
     order = 70
 
     def call(self, **kwargs):
-        box = BoxWidget(self.req._(self.title), self.id)
-        for view in self.vreg['views'].possible_views(self.req, None):
+        box = BoxWidget(self._cw._(self.title), self.__regid__)
+        for view in self._cw.vreg['views'].possible_views(self._cw, None):
             if view.category == 'startupview':
                 box.append(self.box_action(view))
 
@@ -189,19 +189,19 @@
             self.w(u'<div class="sideBoxTitle"><span>%s</span></div>' % title)
         self.w(u'<div class="%s"><div class="sideBoxBody">' % boxclass)
         # if not too much entities, show them all in a list
-        maxrelated = self.req.property_value('navigation.related-limit')
-        if self.rset.rowcount <= maxrelated:
-            if len(self.rset) == 1:
-                self.wview('incontext', self.rset, row=0)
-            elif 1 < len(self.rset) < 5:
-                self.wview('csv', self.rset)
+        maxrelated = self._cw.property_value('navigation.related-limit')
+        if self.cw_rset.rowcount <= maxrelated:
+            if len(self.cw_rset) == 1:
+                self.wview('incontext', self.cw_rset, row=0)
+            elif 1 < len(self.cw_rset) < 5:
+                self.wview('csv', self.cw_rset)
             else:
-                self.wview('simplelist', self.rset)
+                self.wview('simplelist', self.cw_rset)
         # else show links to display related entities
         else:
-            self.rset.limit(maxrelated)
-            rql = self.rset.printable_rql(encoded=False)
-            self.wview('simplelist', self.rset)
-            self.w(u'[<a href="%s">%s</a>]' % (self.build_url(rql=rql),
-                                               self.req._('see them all')))
+            self.cw_rset.limit(maxrelated)
+            rql = self.cw_rset.printable_rql(encoded=False)
+            self.wview('simplelist', self.cw_rset)
+            self.w(u'[<a href="%s">%s</a>]' % (self._cw.build_url(rql=rql),
+                                               self._cw._('see them all')))
         self.w(u'</div>\n</div>\n')
--- a/web/views/calendar.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/calendar.py	Wed Sep 23 19:40:19 2009 +0200
@@ -48,7 +48,7 @@
 
         def call(self):
             ical = iCalendar()
-            for i in range(len(self.rset.rows)):
+            for i in range(len(self.cw_rset.rows)):
                 task = self.complete_entity(i)
                 event = ical.add('vevent')
                 event.add('summary').value = task.dc_title()
@@ -60,7 +60,7 @@
 
             buff = ical.serialize()
             if not isinstance(buff, unicode):
-                buff = unicode(buff, self.req.encoding)
+                buff = unicode(buff, self._cw.encoding)
             self.w(buff)
 
 except ImportError:
@@ -79,7 +79,7 @@
 
     def call(self):
         self.w(u'<div class="hcalendar">')
-        for i in range(len(self.rset.rows)):
+        for i in range(len(self.cw_rset.rows)):
             task = self.complete_entity(i)
             self.w(u'<div class="vevent">')
             self.w(u'<h3 class="summary">%s</h3>' % xml_escape(task.dc_title()))
@@ -101,8 +101,8 @@
         task.view('oneline', w=self.w)
         if dates:
             if task.start and task.stop:
-                self.w('<br/>' % self.req._('from %(date)s' % {'date': self.format_date(task.start)}))
-                self.w('<br/>' % self.req._('to %(date)s' % {'date': self.format_date(task.stop)}))
+                self.w('<br/>' % self._cw._('from %(date)s' % {'date': self.format_date(task.start)}))
+                self.w('<br/>' % self._cw._('to %(date)s' % {'date': self.format_date(task.stop)}))
                 self.w('<br/>to %s'%self.format_date(task.stop))
 
 class CalendarLargeItemView(CalendarItemView):
@@ -135,17 +135,17 @@
     title = _('one month')
 
     def call(self):
-        self.req.add_js('cubicweb.ajax.js')
-        self.req.add_css('cubicweb.calendar.css')
+        self._cw.add_js('cubicweb.ajax.js')
+        self._cw.add_css('cubicweb.calendar.css')
         # XXX: restrict courses directy with RQL
         _today =  datetime.today()
 
-        if 'year' in self.req.form:
-            year = int(self.req.form['year'])
+        if 'year' in self._cw.form:
+            year = int(self._cw.form['year'])
         else:
             year = _today.year
-        if 'month' in self.req.form:
-            month = int(self.req.form['month'])
+        if 'month' in self._cw.form:
+            month = int(self._cw.form['month'])
         else:
             month = _today.month
 
@@ -159,10 +159,10 @@
         month_dates = list(date_range(firstday, lastday))
         dates = {}
         task_max = 0
-        for row in xrange(self.rset.rowcount):
-            task = self.rset.get_entity(row, 0)
-            if len(self.rset[row]) > 1 and self.rset.description[row][1] == 'CWUser':
-                user = self.rset.get_entity(row, 1)
+        for row in xrange(self.cw_rset.rowcount):
+            task = self.cw_rset.get_entity(row, 0)
+            if len(self.cw_rset[row]) > 1 and self.cw_rset.description[row][1] == 'CWUser':
+                user = self.cw_rset.get_entity(row, 1)
             else:
                 user = None
             the_dates = []
@@ -244,12 +244,12 @@
         prevlink, nextlink = self._prevnext_links(curdate)  # XXX
         self.w(u'<tr><th><a href="%s">&lt;&lt;</a></th><th colspan="5">%s %s</th>'
                u'<th><a href="%s">&gt;&gt;</a></th></tr>' %
-               (xml_escape(prevlink), self.req._(curdate.strftime('%B').lower()),
+               (xml_escape(prevlink), self._cw._(curdate.strftime('%B').lower()),
                 curdate.year, xml_escape(nextlink)))
 
         # output header
         self.w(u'<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>' %
-               tuple(self.req._(day) for day in WEEKDAYS))
+               tuple(self._cw._(day) for day in WEEKDAYS))
 
         # build calendar
         for mdate, task_rows in zip(month_dates, days):
@@ -263,11 +263,11 @@
     def _prevnext_links(self, curdate):
         prevdate = curdate - timedelta(31)
         nextdate = curdate + timedelta(31)
-        rql = self.rset.printable_rql()
-        prevlink = self.req.build_ajax_replace_url('onemonthcalid', rql, 'onemonthcal',
+        rql = self.cw_rset.printable_rql()
+        prevlink = self._cw.build_ajax_replace_url('onemonthcalid', rql, 'onemonthcal',
                                                    year=prevdate.year,
                                                    month=prevdate.month)
-        nextlink = self.req.build_ajax_replace_url('onemonthcalid', rql, 'onemonthcal',
+        nextlink = self._cw.build_ajax_replace_url('onemonthcalid', rql, 'onemonthcal',
                                                    year=nextdate.year,
                                                    month=nextdate.month)
         return prevlink, nextlink
@@ -283,16 +283,16 @@
         self.w(u'<div class="calCellTitle%s">' % classes)
         self.w(u'<div class="day">%s</div>' % celldate.day)
 
-        if len(self.rset.column_types(0)) == 1:
-            etype = list(self.rset.column_types(0))[0]
+        if len(self.cw_rset.column_types(0)) == 1:
+            etype = list(self.cw_rset.column_types(0))[0]
             url = self.build_url(vid='creation', etype=etype,
                                  schedule=True,
                                  start=self.format_date(celldate), stop=self.format_date(celldate),
-                                 __redirectrql=self.rset.printable_rql(),
-                                 __redirectparams=self.req.build_url_params(year=curdate.year, month=curmonth),
-                                 __redirectvid=self.id
+                                 __redirectrql=self.cw_rset.printable_rql(),
+                                 __redirectparams=self._cw.build_url_params(year=curdate.year, month=curmonth),
+                                 __redirectvid=self.__regid__
                                  )
-            self.w(u'<div class="cmd"><a href="%s">%s</a></div>' % (xml_escape(url), self.req._(u'add')))
+            self.w(u'<div class="cmd"><a href="%s">%s</a></div>' % (xml_escape(url), self._cw._(u'add')))
             self.w(u'&#160;')
         self.w(u'</div>')
         self.w(u'<div class="cellContent">')
@@ -302,9 +302,9 @@
                 self.w(u'<div class="task %s">' % task_descr.color)
                 task.view('calendaritem', w=self.w )
                 url = task.absolute_url(vid='edition',
-                                        __redirectrql=self.rset.printable_rql(),
-                                        __redirectparams=self.req.build_url_params(year=curdate.year, month=curmonth),
-                                        __redirectvid=self.id
+                                        __redirectrql=self.cw_rset.printable_rql(),
+                                        __redirectparams=self._cw.build_url_params(year=curdate.year, month=curmonth),
+                                        __redirectvid=self.__regid__
                                         )
 
                 self.w(u'<div class="tooltip" ondblclick="stopPropagation(event); window.location.assign(\'%s\'); return false;">' % xml_escape(url))
@@ -326,16 +326,16 @@
     title = _('one week')
 
     def call(self):
-        self.req.add_js( ('cubicweb.ajax.js', 'cubicweb.calendar.js') )
-        self.req.add_css('cubicweb.calendar.css')
+        self._cw.add_js( ('cubicweb.ajax.js', 'cubicweb.calendar.js') )
+        self._cw.add_css('cubicweb.calendar.css')
         # XXX: restrict directly with RQL
         _today =  datetime.today()
-        if 'year' in self.req.form:
-            year = int(self.req.form['year'])
+        if 'year' in self._cw.form:
+            year = int(self._cw.form['year'])
         else:
             year = _today.year
-        if 'week' in self.req.form:
-            week = int(self.req.form['week'])
+        if 'week' in self._cw.form:
+            week = int(self._cw.form['week'])
         else:
             week = _today.isocalendar()[1]
         # week - 1 since we get week number > 0 while we want it to start from 0
@@ -348,8 +348,8 @@
         colors = [ "col%x" % i for i in range(12) ]
         next_color_index = 0
         done_tasks = []
-        for row in xrange(self.rset.rowcount):
-            task = self.rset.get_entity(row, 0)
+        for row in xrange(self.cw_rset.rowcount):
+            task = self.cw_rset.get_entity(row, 0)
             if task in done_tasks:
                 continue
             done_tasks.append(task)
@@ -389,7 +389,7 @@
         self.w(u'<th><a href="%s">&lt;&lt;</a></th><th colspan="5">%s %s %s</th>'
                u'<th><a href="%s">&gt;&gt;</a></th></tr>' %
                (xml_escape(prevlink), first_day_of_week.year,
-                self.req._(u'week'), first_day_of_week.isocalendar()[1],
+                self._cw._(u'week'), first_day_of_week.isocalendar()[1],
                 xml_escape(nextlink)))
 
         # output header
@@ -399,9 +399,9 @@
         for i, day in enumerate(WEEKDAYS):
             wdate = first_day_of_week + timedelta(i)
             if wdate.isocalendar() == _today.isocalendar():
-                self.w(u'<th class="today">%s<br/>%s</th>' % (self.req._(day), self.format_date(wdate)))
+                self.w(u'<th class="today">%s<br/>%s</th>' % (self._cw._(day), self.format_date(wdate)))
             else:
-                self.w(u'<th>%s<br/>%s</th>' % (self.req._(day), self.format_date(wdate)))
+                self.w(u'<th>%s<br/>%s</th>' % (self._cw._(day), self.format_date(wdate)))
         self.w(u'</tr>')
 
         # build week calendar
@@ -420,13 +420,13 @@
             if wdate.isocalendar() == _today.isocalendar():
                 classes = " today"
             self.w(u'<td class="column %s" id="%s">' % (classes, day))
-            if len(self.rset.column_types(0)) == 1:
-                etype = list(self.rset.column_types(0))[0]
+            if len(self.cw_rset.column_types(0)) == 1:
+                etype = list(self.cw_rset.column_types(0))[0]
                 url = self.build_url(vid='creation', etype=etype,
                                      schedule=True,
-                                     __redirectrql=self.rset.printable_rql(),
-                                     __redirectparams=self.req.build_url_params(year=year, week=week),
-                                     __redirectvid=self.id
+                                     __redirectrql=self.cw_rset.printable_rql(),
+                                     __redirectparams=self._cw.build_url_params(year=year, week=week),
+                                     __redirectvid=self.__regid__
                                      )
                 extra = ' ondblclick="addCalendarItem(event, hmin=8, hmax=20, year=%s, month=%s, day=%s, duration=2, baseurl=\'%s\')"' % (
                     wdate.year, wdate.month, wdate.day, xml_escape(url))
@@ -496,9 +496,9 @@
                        (task_desc.color, style))
             task.view('calendaritem', dates=False, w=self.w)
             url = task.absolute_url(vid='edition',
-                                    __redirectrql=self.rset.printable_rql(),
-                                    __redirectparams=self.req.build_url_params(year=date.year, week=date.isocalendar()[1]),
-                                    __redirectvid=self.id
+                                    __redirectrql=self.cw_rset.printable_rql(),
+                                    __redirectparams=self._cw.build_url_params(year=date.year, week=date.isocalendar()[1]),
+                                    __redirectvid=self.__regid__
                                  )
 
             self.w(u'<div class="tooltip" ondblclick="stopPropagation(event); window.location.assign(\'%s\'); return false;">' % xml_escape(url))
@@ -520,11 +520,11 @@
     def _prevnext_links(self, curdate):
         prevdate = curdate - timedelta(7)
         nextdate = curdate + timedelta(7)
-        rql = self.rset.printable_rql()
-        prevlink = self.req.build_ajax_replace_url('oneweekcalid', rql, 'oneweekcal',
+        rql = self.cw_rset.printable_rql()
+        prevlink = self._cw.build_ajax_replace_url('oneweekcalid', rql, 'oneweekcal',
                                                    year=prevdate.year,
                                                    week=prevdate.isocalendar()[1])
-        nextlink = self.req.build_ajax_replace_url('oneweekcalid', rql, 'oneweekcal',
+        nextlink = self._cw.build_ajax_replace_url('oneweekcalid', rql, 'oneweekcal',
                                                    year=nextdate.year,
                                                    week=nextdate.isocalendar()[1])
         return prevlink, nextlink
--- a/web/views/csvexport.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/csvexport.py	Wed Sep 23 19:40:19 2009 +0200
@@ -23,12 +23,12 @@
 
     def set_request_content_type(self):
         """overriden to set a .csv filename"""
-        self.req.set_content_type(self.content_type, filename='cubicwebexport.csv')
+        self._cw.set_content_type(self.content_type, filename='cubicwebexport.csv')
 
     def csvwriter(self, **kwargs):
         params = self.csv_params.copy()
         params.update(kwargs)
-        return UnicodeCSVWriter(self.w, self.req.encoding, **params)
+        return UnicodeCSVWriter(self.w, self._cw.encoding, **params)
 
 
 class CSVRsetView(CSVMixIn, AnyRsetView):
@@ -39,20 +39,20 @@
     def call(self):
         writer = self.csvwriter()
         writer.writerow(self.columns_labels())
-        rset, descr = self.rset, self.rset.description
-        eschema = self.schema.eschema
+        rset, descr = self.cw_rset, self.cw_rset.description
+        eschema = self._cw.schema.eschema
         for rowindex, row in enumerate(rset):
             csvrow = []
             for colindex, val in enumerate(row):
                 etype = descr[rowindex][colindex]
                 if val is not None and not eschema(etype).is_final():
                     # csvrow.append(val) # val is eid in that case
-                    content = self.view('textincontext', rset,
-                                        row=rowindex, col=colindex)
+                    content = self._cw.view('textincontext', rset,
+                                            row=rowindex, col=colindex)
                 else:
-                    content = self.view('final', rset,
-                                        format='text/plain',
-                                        row=rowindex, col=colindex)
+                    content = self._cw.view('final', rset,
+                                            format='text/plain',
+                                            row=rowindex, col=colindex)
                 csvrow.append(content)
             writer.writerow(csvrow)
 
@@ -68,12 +68,12 @@
     title = _('csv entities export')
 
     def call(self):
-        req = self.req
+        req = self._cw
         rows_by_type = {}
         writer = self.csvwriter()
         rowdef_by_type = {}
-        for index in xrange(len(self.rset)):
-            entity = self.complete_entity(index)
+        for index in xrange(len(self.cw_rset)):
+            entity = self.cw_rset.complete_entity(index)
             if entity.e_schema not in rows_by_type:
                 rowdef_by_type[entity.e_schema] = [rs for rs, at in entity.e_schema.attribute_definitions()
                                                    if at != 'Bytes']
--- a/web/views/cwproperties.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/cwproperties.py	Wed Sep 23 19:40:19 2009 +0200
@@ -76,34 +76,34 @@
 
     def url(self):
         """return the url associated with this view. We can omit rql here"""
-        return self.build_url('view', vid=self.id)
+        return self._cw.build_url('view', vid=self.__regid__)
 
     def _cookie_name(self, somestr):
-        return str('%s_property_%s' % (self.config.appid, somestr))
+        return str('%s_property_%s' % (self._cw.config.appid, somestr))
 
     def _group_status(self, group, default=u'hidden'):
         """return css class name 'hidden' (collapsed), or '' (open)"""
-        cookies = self.req.get_cookie()
+        cookies = self._cw.get_cookie()
         cookiename = self._cookie_name(group)
         cookie = cookies.get(cookiename)
         if cookie is None:
             cookies[cookiename] = default
-            self.req.set_cookie(cookies, cookiename, maxage=None)
+            self._cw.set_cookie(cookies, cookiename, maxage=None)
             status = default
         else:
             status = cookie.value
         return status
 
     def call(self, **kwargs):
-        self.req.add_js(('cubicweb.edition.js', 'cubicweb.preferences.js', 'cubicweb.ajax.js'))
-        self.req.add_css('cubicweb.preferences.css')
-        vreg = self.vreg
+        self._cw.add_js(('cubicweb.edition.js', 'cubicweb.preferences.js', 'cubicweb.ajax.js'))
+        self._cw.add_css('cubicweb.preferences.css')
+        vreg = self._cw.vreg
         values = self.defined_keys
         groupedopts = {}
         mainopts = {}
         # "self.id=='systempropertiesform'" to skip site wide properties on
         # user's preference but not site's configuration
-        for key in vreg.user_property_keys(self.id=='systempropertiesform'):
+        for key in vreg.user_property_keys(self.__regid__=='systempropertiesform'):
             parts = key.split('.')
             if parts[0] in vreg:
                 # appobject configuration
@@ -120,7 +120,7 @@
                 groupedopts[group][oid] = self.form(group + '-' + oid, keys, True)
 
         w = self.w
-        req = self.req
+        req = self._cw
         _ = req._
         w(u'<h1>%s</h1>\n' % _(self.title))
         for label, group, form in sorted((_(g), g, f)
@@ -140,7 +140,7 @@
               (make_togglable_link('fieldset_' + group, label.capitalize())))
             w(u'<div id="fieldset_%s" %s>' % (group, status))
             # create selection
-            sorted_objects =  sorted((self.req.__('%s_%s' % (group, o)), o, f)
+            sorted_objects =  sorted((self._cw.__('%s_%s' % (group, o)), o, f)
                                            for o, f in objects.iteritems())
             for label, oid, form in sorted_objects:
                 w(u'<div class="component">')
@@ -165,7 +165,7 @@
     @property
     @cached
     def cwprops_rset(self):
-        return self.req.execute('Any P,K,V WHERE P is CWProperty, P pkey K, '
+        return self._cw.execute('Any P,K,V WHERE P is CWProperty, P pkey K, '
                                 'P value V, NOT P for_user U')
 
     @property
@@ -180,27 +180,27 @@
         if key in values:
             entity = self.cwprops_rset.get_entity(values[key], 0)
         else:
-            entity = self.vreg['etypes'].etype_class('CWProperty')(self.req)
-            entity.eid = self.req.varmaker.next()
+            entity = self._cw.vreg['etypes'].etype_class('CWProperty')(self._cw)
+            entity.eid = self._cw.varmaker.next()
             entity['pkey'] = key
-            entity['value'] = self.vreg.property_value(key)
+            entity['value'] = self._cw.vreg.property_value(key)
         return entity
 
     def form(self, formid, keys, splitlabel=False):
         buttons = [SubmitButton()]
-        form = self.vreg['forms'].select(
-            'composite', self.req, domid=formid, action=self.build_url(),
+        form = self._cw.vreg['forms'].select(
+            'composite', self._cw, domid=formid, action=self._cw.build_url(),
             form_buttons=buttons,
             onsubmit="return validatePrefsForm('%s')" % formid,
-            submitmsg=self.req._('changes applied'))
-        path = self.req.relative_path()
+            submitmsg=self._cw._('changes applied'))
+        path = self._cw.relative_path()
         if '?' in path:
             path, params = path.split('?', 1)
             form.form_add_hidden('__redirectparams', params)
         form.form_add_hidden('__redirectpath', path)
         for key in keys:
             self.form_row(form, key, splitlabel)
-        renderer = self.vreg['formrenderers'].select('cwproperties', self.req,
+        renderer = self._cw.vreg['formrenderers'].select('cwproperties', self._cw,
                                                      display_progress_div=False)
         return form.form_render(renderer=renderer)
 
@@ -210,11 +210,11 @@
             label = key.split('.')[-1]
         else:
             label = key
-        subform = self.vreg['forms'].select('base', self.req, entity=entity,
+        subform = self._cw.vreg['forms'].select('base', self._cw, entity=entity,
                                             mainform=False)
         subform.append_field(PropertyValueField(name='value', label=label,
                                                 eidparam=True))
-        subform.vreg = self.vreg
+        subform.vreg = self._cw.vreg
         subform.form_add_hidden('pkey', key, eidparam=True)
         form.form_add_subform(subform)
         return subform
@@ -238,14 +238,14 @@
 
     @property
     def user(self):
-        if self.rset is None:
-            return self.req.user
-        return self.rset.get_entity(self.row or 0, self.col or 0)
+        if self.cw_rset is None:
+            return self._cw.user
+        return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
 
     @property
     @cached
     def cwprops_rset(self):
-        return self.req.execute('Any P,K,V WHERE P is CWProperty, P pkey K, P value V,'
+        return self._cw.execute('Any P,K,V WHERE P is CWProperty, P pkey K, P value V,'
                                 'P for_user U, U eid %(x)s', {'x': self.user.eid})
 
     def form_row(self, form, key, splitlabel):
--- a/web/views/cwuser.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/cwuser.py	Wed Sep 23 19:40:19 2009 +0200
@@ -25,7 +25,7 @@
     category = 'mainactions'
 
     def url(self):
-        login = self.rset.get_entity(self.row or 0, self.col or 0).login
+        login = self.cw_rset.get_entity(self.cw_row or 0, self.col or 0).login
         return self.build_url('cwuser/%s'%login, vid='propertiesform')
 
 
@@ -41,8 +41,8 @@
         self.w(u'''<?xml version="1.0" encoding="%s"?>
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:rdfs="http://www.w3org/2000/01/rdf-schema#"
-         xmlns:foaf="http://xmlns.com/foaf/0.1/"> '''% self.req.encoding)
-        for i in xrange(self.rset.rowcount):
+         xmlns:foaf="http://xmlns.com/foaf/0.1/"> '''% self._cw.encoding)
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self.w(u'</rdf:RDF>\n')
 
--- a/web/views/debug.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/debug.py	Wed Sep 23 19:40:19 2009 +0200
@@ -34,7 +34,7 @@
         """display server information"""
         w = self.w
         w(u'<h1>server sessions</h1>')
-        sessions = self.req.cnx._repo._sessions.items()
+        sessions = self._cw.cnx._repo._sessions.items()
         if sessions:
             w(u'<ul>')
             for sid, session in sessions:
@@ -70,12 +70,12 @@
     def call(self, **kwargs):
         """The default view representing the instance's management"""
         self.w(u'<h1>%s</h1>' % _("Registry's content"))
-        keys = sorted(self.vreg)
+        keys = sorted(self._cw.vreg)
         self.w(u'<p>%s</p>\n' % ' - '.join('<a href="/_registry#%s">%s</a>'
                                            % (key, key) for key in keys))
         for key in keys:
             self.w(u'<h2><a name="%s">%s</a></h2>' % (key,key))
-            items = self.vreg[key].items()
+            items = self._cw.vreg[key].items()
             if items:
                 self.w(u'<table><tbody>')
                 for key, value in sorted(items):
--- a/web/views/editcontroller.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/editcontroller.py	Wed Sep 23 19:40:19 2009 +0200
@@ -53,28 +53,28 @@
 
     def publish(self, rset=None):
         """edit / create / copy / delete entity / relations"""
-        for key in self.req.form:
+        for key in self._cw.form:
             # There should be 0 or 1 action
             if key.startswith('__action_'):
                 cbname = key[1:]
                 try:
                     callback = getattr(self, cbname)
                 except AttributeError:
-                    raise RequestError(self.req._('invalid action %r' % key))
+                    raise RequestError(self._cw._('invalid action %r' % key))
                 else:
                     return callback()
         self._default_publish()
         self.reset()
 
     def _default_publish(self):
-        req = self.req
+        req = self._cw
         self.errors = []
         self.relations_rql = []
         # no specific action, generic edition
         self._to_create = req.data['eidmap'] = {}
         self._pending_relations = []
-        todelete = self.req.get_pending_deletes()
-        toinsert = self.req.get_pending_inserts()
+        todelete = self._cw.get_pending_deletes()
+        toinsert = self._cw.get_pending_inserts()
         try:
             methodname = req.form.pop('__method', None)
             for eid in req.edited_eids():
@@ -91,13 +91,13 @@
             elif not ('__delete' in req.form or '__insert' in req.form or todelete or toinsert):
                 raise ValidationError(None, {None: req._('nothing to edit')})
         for querydef in self.relations_rql:
-            self.req.execute(*querydef)
+            self._cw.execute(*querydef)
         # handle relations in newly created entities
         # XXX find a way to merge _pending_relations and relations_rql
         if self._pending_relations:
             for form, field, entity in self._pending_relations:
                 for querydef in self.handle_relation(form, field, entity, True):
-                    self.req.execute(*querydef)
+                    self._cw.execute(*querydef)
         # XXX this processes *all* pending operations of *all* entities
         if req.form.has_key('__delete'):
             todelete += req.list_form_param('__delete', req.form, pop=True)
@@ -107,18 +107,18 @@
             toinsert = req.list_form_param('__insert', req.form, pop=True)
         if toinsert:
             self.insert_relations(parse_relations_descr(toinsert))
-        self.req.remove_pending_operations()
+        self._cw.remove_pending_operations()
 
     def _insert_entity(self, etype, eid, rqlquery):
         rql = rqlquery.insert_query(etype)
         try:
             # get the new entity (in some cases, the type might have
             # changed as for the File --> Image mutation)
-            entity = self.req.execute(rql, rqlquery.kwargs).get_entity(0, 0)
+            entity = self._cw.execute(rql, rqlquery.kwargs).get_entity(0, 0)
             neweid = entity.eid
         except ValidationError, ex:
             self._to_create[eid] = ex.entity
-            if self.req.json_request: # XXX (syt) why?
+            if self._cw.json_request: # XXX (syt) why?
                 ex.entity = eid
             raise
         self._to_create[eid] = neweid
@@ -126,15 +126,15 @@
 
     def _update_entity(self, eid, rqlquery):
         rql = rqlquery.update_query(eid)
-        self.req.execute(rql, rqlquery.kwargs)
+        self._cw.execute(rql, rqlquery.kwargs)
 
     def edit_entity(self, formparams, multiple=False):
         """edit / create / copy an entity and return its eid"""
         etype = formparams['__type']
-        entity = self.vreg['etypes'].etype_class(etype)(self.req)
+        entity = self._cw.vreg['etypes'].etype_class(etype)(self._cw)
         entity.eid = formparams['eid']
         eid = self._get_eid(entity.eid)
-        is_main_entity = self.req.form.get('__maineid') == formparams['eid']
+        is_main_entity = self._cw.form.get('__maineid') == formparams['eid']
         # let a chance to do some entity specific stuff.tn
         entity.pre_web_edit()
         # create a rql query from parameters
@@ -142,8 +142,8 @@
         # process inlined relations at the same time as attributes
         # this will generate less rql queries and might be useful in
         # a few dark corners
-        formid = self.req.form.get('__form_id', 'edition')
-        form = self.vreg['forms'].select(formid, self.req, entity=entity)
+        formid = self._cw.form.get('__form_id', 'edition')
+        form = self._cw.vreg['forms'].select(formid, self._cw, entity=entity)
         for field in form.fields:
             if form.form_field_modified(field):
                 self.handle_formfield(form, field, entity, rqlquery)
@@ -154,12 +154,12 @@
         if is_main_entity:
             self.notify_edited(entity)
         if formparams.has_key('__delete'):
-            todelete = self.req.list_form_param('__delete', formparams, pop=True)
+            todelete = self._cw.list_form_param('__delete', formparams, pop=True)
             self.delete_relations(parse_relations_descr(todelete))
         if formparams.has_key('__cloned_eid'):
             entity.copy_relations(formparams['__cloned_eid'])
         if formparams.has_key('__insert'):
-            toinsert = self.req.list_form_param('__insert', formparams, pop=True)
+            toinsert = self._cw.list_form_param('__insert', formparams, pop=True)
             self.insert_relations(parse_relations_descr(toinsert))
         if is_main_entity: # only execute linkto for the main entity
             self.execute_linkto(eid)
@@ -174,7 +174,7 @@
                     or
                     (field.role == 'object' and eschema.has_object_relation(field.name))):
                     continue
-                rschema = self.schema.rschema(field.name)
+                rschema = self._cw.schema.rschema(field.name)
                 if rschema.is_final():
                     rqlquery.kwargs[attr] = value
                     rqlquery.edited.append('X %s %%(%s)s' % (attr, attr))
@@ -191,14 +191,14 @@
         self.reset()
 
     def _action_cancel(self):
-        errorurl = self.req.form.get('__errorurl')
+        errorurl = self._cw.form.get('__errorurl')
         if errorurl:
-            self.req.cancel_edition(errorurl)
-        self.req.message = self.req._('edit canceled')
+            self._cw.cancel_edition(errorurl)
+        self._cw.message = self._cw._('edit canceled')
         return self.reset()
 
     def _action_delete(self):
-        self.delete_entities(self.req.edited_eids(withtype=True))
+        self.delete_entities(self._cw.edited_eids(withtype=True))
         return self.reset()
 
     def _relation_values(self, form, field, entity, late=False):
@@ -242,7 +242,7 @@
         if values is None or values == origvalues:
             return # not edited / not modified / to do later
         etype = entity.e_schema
-        rschema = self.schema.rschema(field.name)
+        rschema = self._cw.schema.rschema(field.name)
         if field.role == 'subject':
             desttype = rschema.objects(etype)[0]
             card = rschema.rproperty(etype, desttype, 'cardinality')[0]
--- a/web/views/editforms.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/editforms.py	Wed Sep 23 19:40:19 2009 +0200
@@ -59,11 +59,11 @@
     def __init__(self, *args, **kwargs):
         super(DeleteConfForm, self).__init__(*args, **kwargs)
         done = set()
-        for entity in self.rset.entities():
+        for entity in self.cw_rset.entities():
             if entity.eid in done:
                 continue
             done.add(entity.eid)
-            subform = self.vreg['forms'].select('base', self.req, entity=entity,
+            subform = self._cw.vreg['forms'].select('base', self._cw, entity=entity,
                                                 mainform=False)
             self.form_add_subform(subform)
 
@@ -78,16 +78,16 @@
 
     def call(self, onsubmit=None):
         """ask for confirmation before real deletion"""
-        req, w = self.req, self.w
+        req, w = self._cw, self.w
         _ = req._
         w(u'<script type="text/javascript">updateMessage(\'%s\');</script>\n'
           % _('this action is not reversible!'))
         # XXX above message should have style of a warning
         w(u'<h4>%s</h4>\n' % _('Do you want to delete the following element(s) ?'))
-        form = self.vreg['forms'].select(self.id, req, rset=self.rset,
+        form = self._cw.vreg['forms'].select(self.__regid__, req, rset=self.cw_rset,
                                          onsubmit=onsubmit)
         w(u'<ul>\n')
-        for entity in self.rset.entities():
+        for entity in self.cw_rset.entities():
             # don't use outofcontext view or any other that may contain inline edition form
             w(u'<li>%s</li>' % tags.a(entity.view('textoutofcontext'),
                                       href=entity.absolute_url()))
@@ -124,11 +124,11 @@
         return self._one_rvid
 
     def _build_landing_zone(self, lzone):
-        return lzone or self._defaultlandingzone % {'msg' : xml_escape(self.req._(self._landingzonemsg))}
+        return lzone or self._defaultlandingzone % {'msg' : xml_escape(self._cw._(self._landingzonemsg))}
 
     def _build_renderer(self, entity, rtype, role):
-        return self.vreg['formrenderers'].select(
-            'base', self.req, entity=entity, display_label=False,
+        return self._cw.vreg['formrenderers'].select(
+            'base', self._cw, entity=entity, display_label=False,
             display_help=False, display_fields=[(rtype, role)], table_class='',
             button_bar_class='buttonbar', display_progress_div=False)
 
@@ -142,8 +142,8 @@
         onsubmit %= event_data
         cancelclick = "hideInlineEdit(%s,\'%s\',\'%s\')" % (entity.eid, rtype,
                                                             divid)
-        form = self.vreg['forms'].select(
-            formid, self.req, entity=entity, domid='%s-form' % divid,
+        form = self._cw.vreg['forms'].select(
+            formid, self._cw, entity=entity, domid='%s-form' % divid,
             cssstyle='display: none', onsubmit=onsubmit, action='#',
             form_buttons=[SubmitButton(), Button(stdmsgs.BUTTON_CANCEL,
                                                  onclick=cancelclick)],
@@ -162,9 +162,10 @@
         assert rtype
         assert role in ('subject', 'object')
         if default is None:
-            default = xml_escape(self.req._('<no value>'))
-        entity = self.rset.get_entity(row, col)
-        rschema = entity.schema.rschema(rtype)
+            default = xml_escape(self._cw._('<no value>'))
+        schema = self._cw.vreg.schema
+        entity = self.cw_rset.get_entity(row, col)
+        rschema = schema.rschema(rtype)
         lzone = self._build_landing_zone(landing_zone)
         # compute value, checking perms, build form
         if rschema.is_final():
@@ -185,7 +186,7 @@
                 return
             rset = entity.related(rtype, role)
             if rset:
-                value = self.view(rvid, rset)
+                value = self._cw.view(rvid, rset)
             else:
                 value = default
             onsubmit = ("return inlineValidateRelationForm('%(rtype)s', '%(role)s', '%(eid)s', "
@@ -193,15 +194,15 @@
             form = self._build_form(
                 entity, rtype, role, 'base', default, onsubmit, reload,
                 dict(vid=rvid, role=role, lzone=lzone))
-            field = guess_field(entity.e_schema, entity.schema.rschema(rtype), role)
+            field = guess_field(entity.e_schema, schema.rschema(rtype), role)
             form.append_field(field)
             self.relation_form(lzone, value, form,
                                self._build_renderer(entity, rtype, role))
 
     def should_edit_attribute(self, entity, rschema, role, form):
         rtype = str(rschema)
-        ttype = rschema.targets(entity.id, role)[0]
-        afs = uicfg.autoform_section.etype_get(entity.id, rtype, role, ttype)
+        ttype = rschema.targets(entity.__regid__, role)[0]
+        afs = uicfg.autoform_section.etype_get(entity.__regid__, rtype, role, ttype)
         if not (afs in self.attrcategories and entity.has_perm('update')):
             self.w(entity.printable_value(rtype))
             return False
@@ -213,10 +214,10 @@
         return True
 
     def should_edit_relation(self, entity, rschema, role, rvid):
-        if ((role == 'subject' and not rschema.has_perm(self.req, 'add',
+        if ((role == 'subject' and not rschema.has_perm(self._cw, 'add',
                                                         fromeid=entity.eid))
             or
-            (role == 'object' and not rschema.has_perm(self.req, 'add',
+            (role == 'object' and not rschema.has_perm(self._cw, 'add',
                                                        toeid=entity.eid))):
             self.wview(rvid, entity.related(str(rschema), role), 'null')
             return False
@@ -296,7 +297,7 @@
     def render_form(self, entity):
         """fetch and render the form"""
         self.form_title(entity)
-        form = self.vreg['forms'].select('edition', self.req, rset=entity.rset,
+        form = self._cw.vreg['forms'].select('edition', self._cw, rset=entity.rset,
                                          row=entity.row, col=entity.col, entity=entity,
                                          submitmsg=self.submited_message())
         self.init_form(form, entity)
@@ -308,13 +309,13 @@
 
     def form_title(self, entity):
         """the form view title"""
-        ptitle = self.req._(self.title)
+        ptitle = self._cw._(self.title)
         self.w(u'<div class="formTitle"><span>%s %s</span></div>' % (
             entity.dc_type(), ptitle and '(%s)' % ptitle))
 
     def submited_message(self):
         """return the message that will be displayed on successful edition"""
-        return self.req._('entity edited')
+        return self._cw._('entity edited')
 
 
 class CreationFormView(EditionFormView):
@@ -328,41 +329,40 @@
         """creation view for an entity"""
         # at this point we know etype is a valid entity type, thanks to our
         # selector
-        etype = kwargs.pop('etype', self.req.form.get('etype'))
-        entity = self.vreg['etypes'].etype_class(etype)(self.req)
-        self.initialize_varmaker()
-        entity.eid = self.varmaker.next()
+        etype = kwargs.pop('etype', self._cw.form.get('etype'))
+        entity = self._cw.vreg['etypes'].etype_class(etype)(self._cw)
+        entity.eid = self._cw.varmaker.next()
         self.render_form(entity)
 
     def form_title(self, entity):
         """the form view title"""
-        if '__linkto' in self.req.form:
-            if isinstance(self.req.form['__linkto'], list):
+        if '__linkto' in self._cw.form:
+            if isinstance(self._cw.form['__linkto'], list):
                 # XXX which one should be considered (case: add a ticket to a
                 # version in jpl)
-                rtype, linkto_eid, role = self.req.form['__linkto'][0].split(':')
+                rtype, linkto_eid, role = self._cw.form['__linkto'][0].split(':')
             else:
-                rtype, linkto_eid, role = self.req.form['__linkto'].split(':')
-            linkto_rset = self.req.eid_rset(linkto_eid)
+                rtype, linkto_eid, role = self._cw.form['__linkto'].split(':')
+            linkto_rset = self._cw.eid_rset(linkto_eid)
             linkto_type = linkto_rset.description[0][0]
             if role == 'subject':
-                title = self.req.__('creating %s (%s %s %s %%(linkto)s)' % (
+                title = self._cw.__('creating %s (%s %s %s %%(linkto)s)' % (
                     entity.e_schema, entity.e_schema, rtype, linkto_type))
             else:
-                title = self.req.__('creating %s (%s %%(linkto)s %s %s)' % (
+                title = self._cw.__('creating %s (%s %%(linkto)s %s %s)' % (
                     entity.e_schema, linkto_type, rtype, entity.e_schema))
-            msg = title % {'linkto' : self.view('incontext', linkto_rset)}
+            msg = title % {'linkto' : self._cw.view('incontext', linkto_rset)}
             self.w(u'<div class="formTitle notransform"><span>%s</span></div>' % msg)
         else:
             super(CreationFormView, self).form_title(entity)
 
     def url(self):
         """return the url associated with this view"""
-        return self.create_url(self.req.form.get('etype'))
+        return self.create_url(self._cw.form.get('etype'))
 
     def submited_message(self):
         """return the message that will be displayed on successful edition"""
-        return self.req._('entity created')
+        return self._cw._('entity created')
 
 
 class CopyFormView(EditionFormView):
@@ -379,10 +379,9 @@
         entity.complete()
         self.newentity = copy(entity)
         self.copying = entity
-        self.initialize_varmaker()
-        self.newentity.eid = self.varmaker.next()
+        self.newentity.eid = self._cw.varmaker.next()
         self.w(u'<script type="text/javascript">updateMessage("%s");</script>\n'
-               % self.req._(self.warning_message))
+               % self._cw._(self.warning_message))
         super(CopyFormView, self).render_form(self.newentity)
         del self.newentity
 
@@ -401,7 +400,7 @@
 
     def submited_message(self):
         """return the message that will be displayed on successful edition"""
-        return self.req._('entity copied')
+        return self._cw._('entity copied')
 
 
 class TableEditForm(forms.CompositeForm):
@@ -414,9 +413,9 @@
     def __init__(self, req, rset, **kwargs):
         kwargs.setdefault('__redirectrql', rset.printable_rql())
         super(TableEditForm, self).__init__(req, rset=rset, **kwargs)
-        for row in xrange(len(self.rset)):
-            form = self.vreg['forms'].select('edition', self.req,
-                                             rset=self.rset, row=row,
+        for row in xrange(len(self.cw_rset)):
+            form = self._cw.vreg['forms'].select('edition', self._cw,
+                                             rset=self.cw_rset, row=row,
                                              attrcategories=('primary',),
                                              mainform=False)
             # XXX rely on the EntityCompositeFormRenderer to put the eid input
@@ -434,7 +433,7 @@
         should be the eid
         """
         #self.form_title(entity)
-        form = self.vreg['forms'].select(self.id, self.req, rset=self.rset)
+        form = self._cw.vreg['forms'].select(self.__regid__, self._cw, rset=self.cw_rset)
         self.w(form.form_render())
 
 
@@ -448,9 +447,9 @@
         insertions of <div class="section"> between each row of
         the resultset
         """
-        rset = self.rset
+        rset = self.cw_rset
         for i in xrange(len(rset)):
-            self.wview(self.id, rset, row=i, **kwargs)
+            self.wview(self.__regid__, rset, row=i, **kwargs)
 
     def cell_call(self, row, col, peid, rtype, role, i18nctx, **kwargs):
         """
@@ -458,7 +457,7 @@
         :param rtype: the relation bridging `etype` and `peid`
         :param role: the role played by the `peid` in the relation
         """
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % (peid, rtype,
                                                                  entity.eid)
         self.render_form(entity, peid, rtype, role, i18nctx,
@@ -466,21 +465,21 @@
 
     def render_form(self, entity, peid, rtype, role, i18nctx, **kwargs):
         """fetch and render the form"""
-        form = self.vreg['forms'].select('edition', self.req, entity=entity,
+        form = self._cw.vreg['forms'].select('edition', self._cw, entity=entity,
                                          form_renderer_id='inline',
                                          mainform=False, copy_nav_params=False)
         self.add_hiddens(form, entity, peid, rtype, role)
         divid = '%s-%s-%s' % (peid, rtype, entity.eid)
-        title = self.req.pgettext(i18nctx, 'This %s' % entity.e_schema)
+        title = self._cw.pgettext(i18nctx, 'This %s' % entity.e_schema)
         removejs = self.removejs % (peid, rtype, entity.eid)
         countkey = '%s_count' % rtype
         try:
-            self.req.data[countkey] += 1
+            self._cw.data[countkey] += 1
         except:
-            self.req.data[countkey] = 1
+            self._cw.data[countkey] = 1
         self.w(form.form_render(divid=divid, title=title, removejs=removejs,
                                 i18nctx=i18nctx,
-                                counter=self.req.data[countkey], **kwargs))
+                                counter=self._cw.data[countkey], **kwargs))
 
     def add_hiddens(self, form, entity, peid, rtype, role):
         # to ease overriding (see cubes.vcsfile.views.forms for instance)
@@ -492,7 +491,7 @@
             return True
         # are we regenerating form because of a validation error ?
         if form.form_previous_values:
-            cdvalues = self.req.list_form_param(eid_param(rtype, peid),
+            cdvalues = self._cw.list_form_param(eid_param(rtype, peid),
                                                 form.form_previous_values)
             if unicode(entity.eid) not in cdvalues:
                 return False
@@ -513,11 +512,10 @@
         :param role: the role played by the `peid` in the relation
         """
         try:
-            cls = self.vreg['etypes'].etype_class(etype)
+            cls = self._cw.vreg['etypes'].etype_class(etype)
         except:
-            self.w(self.req._('no such entity type %s') % etype)
+            self.w(self._cw._('no such entity type %s') % etype)
             return
-        self.initialize_varmaker()
-        entity = cls(self.req)
-        entity.eid = self.varmaker.next()
+        entity = cls(self._cw)
+        entity.eid = self._cw.varmaker.next()
         self.render_form(entity, peid, rtype, role, i18nctx, **kwargs)
--- a/web/views/editviews.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/editviews.py	Wed Sep 23 19:40:19 2009 +0200
@@ -35,7 +35,7 @@
 
     def cell_call(self, row, col):
         rset, vid, divid, paginate = self.filter_box_context_info()
-        self.rset = rset
+        self.cw_rset = rset
         self.w(u'<div id="%s">' % divid)
         self.paginate()
         self.wview(vid, rset, 'noresult')
@@ -43,8 +43,8 @@
 
     @cached
     def filter_box_context_info(self):
-        entity = self.rset.get_entity(0, 0)
-        role, eid, rtype, etype = self.req.search_state[1]
+        entity = self.cw_rset.get_entity(0, 0)
+        role, eid, rtype, etype = self._cw.search_state[1]
         assert entity.eid == typed_eid(eid)
         # the default behaviour is to fetch all unrelated entities and display
         # them. Use fetch_order and not fetch_unrelated_order as sort method
@@ -53,22 +53,22 @@
         rql, args = entity.unrelated_rql(rtype, etype, role,
                                    ordermethod='fetch_order',
                                    vocabconstraints=False)
-        rset = self.req.execute(rql, args, tuple(args))
+        rset = self._cw.execute(rql, args, tuple(args))
         return rset, 'list', "search-associate-content", True
 
 
 class OutOfContextSearch(EntityView):
     __regid__ = 'outofcontext-search'
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         erset = entity.as_rset()
-        if self.req.match_search_state(erset):
+        if self._cw.match_search_state(erset):
             self.w(u'<a href="%s" title="%s">%s</a>&#160;<a href="%s" title="%s">[...]</a>' % (
-                xml_escape(linksearch_select_url(self.req, erset)),
-                self.req._('select this entity'),
+                xml_escape(linksearch_select_url(self._cw, erset)),
+                self._cw._('select this entity'),
                 xml_escape(entity.view('textoutofcontext')),
                 xml_escape(entity.absolute_url(vid='primary')),
-                self.req._('view detail for this entity')))
+                self._cw._('view detail for this entity')))
         else:
             entity.view('outofcontext', w=self.w)
 
@@ -78,11 +78,11 @@
     __select__ = match_form_params('relation')
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
-        relname, target = self.req.form.get('relation').rsplit('_', 1)
-        rschema = self.schema.rschema(relname)
-        hidden = 'hidden' in self.req.form
-        is_cell = 'is_cell' in self.req.form
+        entity = self.cw_rset.get_entity(row, col)
+        relname, target = self._cw.form.get('relation').rsplit('_', 1)
+        rschema = self._cw.schema.rschema(relname)
+        hidden = 'hidden' in self._cw.form
+        is_cell = 'is_cell' in self._cw.form
         self.w(self.build_unrelated_select_div(entity, rschema, target,
                                                is_cell=is_cell, hidden=hidden))
 
@@ -93,17 +93,17 @@
         selectid = 'select%s_%s_%s' % (rschema.type, target, entity.eid)
         if rschema.symetric or target == 'subject':
             targettypes = rschema.objects(entity.e_schema)
-            etypes = '/'.join(sorted(etype.display_name(self.req) for etype in targettypes))
+            etypes = '/'.join(sorted(etype.display_name(self._cw) for etype in targettypes))
         else:
             targettypes = rschema.subjects(entity.e_schema)
-            etypes = '/'.join(sorted(etype.display_name(self.req) for etype in targettypes))
-        etypes = cut(etypes, self.req.property_value('navigation.short-line-size'))
-        options.append('<option>%s %s</option>' % (self.req._('select a'), etypes))
+            etypes = '/'.join(sorted(etype.display_name(self._cw) for etype in targettypes))
+        etypes = cut(etypes, self._cw.property_value('navigation.short-line-size'))
+        options.append('<option>%s %s</option>' % (self._cw._('select a'), etypes))
         options += self._get_select_options(entity, rschema, target)
         options += self._get_search_options(entity, rschema, target, targettypes)
-        if 'Basket' in self.schema: # XXX
+        if 'Basket' in self._cw.schema: # XXX
             options += self._get_basket_options(entity, rschema, target, targettypes)
-        relname, target = self.req.form.get('relation').rsplit('_', 1)
+        relname, target = self._cw.form.get('relation').rsplit('_', 1)
         return u"""\
 <div class="%s" id="%s">
   <select id="%s" onchange="javascript: addPendingInsert(this.options[this.selectedIndex], %s, %s, '%s');">
@@ -118,11 +118,11 @@
         """add options to search among all entities of each possible type"""
         options = []
         eid = entity.eid
-        pending_inserts = self.req.get_pending_inserts(eid)
+        pending_inserts = self._cw.get_pending_inserts(eid)
         rtype = rschema.type
-        form = self.vreg['forms'].select('edition', self.req, entity=entity)
+        form = self._cw.vreg['forms'].select('edition', self._cw, entity=entity)
         field = form.field_by_name(rschema, target, entity.e_schema)
-        limit = self.req.property_value('navigation.combobox-limit')
+        limit = self._cw.property_value('navigation.combobox-limit')
         for eview, reid in form.form_field_vocabulary(field, limit):
             if reid is None:
                 options.append('<option class="separator">-- %s --</option>'
@@ -138,21 +138,21 @@
     def _get_search_options(self, entity, rschema, target, targettypes):
         """add options to search among all entities of each possible type"""
         options = []
-        _ = self.req._
+        _ = self._cw._
         for eschema in targettypes:
             mode = '%s:%s:%s:%s' % (target, entity.eid, rschema.type, eschema)
             url = self.build_url(entity.rest_path(), vid='search-associate',
                                  __mode=mode)
-            options.append((eschema.display_name(self.req),
+            options.append((eschema.display_name(self._cw),
                             '<option value="%s">%s %s</option>' % (
-                xml_escape(url), _('Search for'), eschema.display_name(self.req))))
+                xml_escape(url), _('Search for'), eschema.display_name(self._cw))))
         return [o for l, o in sorted(options)]
 
     def _get_basket_options(self, entity, rschema, target, targettypes):
         options = []
         rtype = rschema.type
-        _ = self.req._
-        for basketeid, basketname in self._get_basket_links(self.req.user.eid,
+        _ = self._cw._
+        for basketeid, basketname in self._get_basket_links(self._cw.user.eid,
                                                             target, targettypes):
             optionid = relation_id(entity.eid, rtype, target, basketeid)
             options.append('<option id="%s" value="%s">%s %s</option>' % (
@@ -171,10 +171,10 @@
     def _get_basket_info(self, ueid):
         basketref = []
         basketrql = 'Any B,N WHERE B is Basket, B owned_by U, U eid %(x)s, B name N'
-        basketresultset = self.req.execute(basketrql, {'x': ueid}, 'x')
+        basketresultset = self._cw.execute(basketrql, {'x': ueid}, 'x')
         for result in basketresultset:
             basketitemsrql = 'Any X WHERE X in_basket B, B eid %(x)s'
-            rset = self.req.execute(basketitemsrql, {'x': result[0]}, 'x')
+            rset = self._cw.execute(basketitemsrql, {'x': result[0]}, 'x')
             basketref.append((result[0], result[1], rset))
         return basketref
 
@@ -191,7 +191,7 @@
         """the combo-box view for an entity: same as text out of context view
         by default
         """
-        self.wview('textoutofcontext', self.rset, row=row, col=col)
+        self.wview('textoutofcontext', self.cw_rset, row=row, col=col)
 
 
 class EditableFinalView(FinalView):
@@ -199,7 +199,7 @@
     __regid__ = 'editable-final'
 
     def cell_call(self, row, col, props=None):
-        entity, rtype = self.rset.related_entity(row, col)
+        entity, rtype = self.cw_rset.related_entity(row, col)
         if entity is not None:
             self.w(entity.view('reledit', rtype=rtype))
         else:
--- a/web/views/emailaddress.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/emailaddress.py	Wed Sep 23 19:40:19 2009 +0200
@@ -33,18 +33,18 @@
             persons = []
         if persons:
             emailof = persons[0]
-            self.field(display_name(self.req, 'primary_email', 'object'), emailof.view('oneline'))
+            self.field(display_name(self._cw, 'primary_email', 'object'), emailof.view('oneline'))
             pemaileid = emailof.eid
         else:
             pemaileid = None
         try:
-            emailof = 'use_email' in self.schema and entity.reverse_use_email or ()
+            emailof = 'use_email' in self._cw.schema and entity.reverse_use_email or ()
             emailof = [e for e in emailof if not e.eid == pemaileid]
         except Unauthorized:
             emailof = []
         if emailof:
             emailofstr = ', '.join(e.view('oneline') for e in emailof)
-            self.field(display_name(self.req, 'use_email', 'object'), emailofstr)
+            self.field(display_name(self._cw, 'use_email', 'object'), emailofstr)
 
     def render_entity_relations(self, entity):
         for i, email in enumerate(entity.related_emails(self.skipeids)):
@@ -68,7 +68,7 @@
     __select__ = implements('EmailAddress')
 
     def cell_call(self, row, col, **kwargs):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         if entity.reverse_primary_email:
             self.w(u'<b>')
         if entity.alias:
@@ -89,7 +89,7 @@
     __select__ = implements('EmailAddress')
 
     def cell_call(self, row, col, **kwargs):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         if entity.reverse_primary_email:
             self.w(u'<b>')
         if entity.alias:
@@ -112,4 +112,4 @@
     __select__ = implements('EmailAddress')
 
     def cell_call(self, row, col, **kwargs):
-        self.w(self.rset.get_entity(row, col).display_address())
+        self.w(self.cw_rset.get_entity(row, col).display_address())
--- a/web/views/embedding.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/embedding.py	Wed Sep 23 19:40:19 2009 +0200
@@ -34,8 +34,8 @@
     def call(self, body):
         # XXX fallback to HTML 4 mode when embeding ?
         self.set_request_content_type()
-        self.req.search_state = ('normal',)
-        self.template_header(self.content_type, None, self.req._('external page'),
+        self._cw.search_state = ('normal',)
+        self.template_header(self.content_type, None, self._cw._('external page'),
                              [NOINDEX, NOFOLLOW])
         self.content_header()
         self.w(body)
@@ -48,18 +48,18 @@
     template = 'external'
 
     def publish(self, rset=None):
-        req = self.req
+        req = self._cw
         if 'custom_css' in req.form:
             req.add_css(req.form['custom_css'])
         embedded_url = req.form['url']
-        allowed = self.config['embed-allowed']
+        allowed = self._cw.config['embed-allowed']
         _ = req._
         if allowed is None or not allowed.match(embedded_url):
             body = '<h2>%s</h2><h3>%s</h3>' % (
                 _('error while embedding page'),
                 _('embedding this url is forbidden'))
         else:
-            prefix = req.build_url(self.id, url='')
+            prefix = req.build_url(self.__regid__, url='')
             authorization = req.get_header('Authorization')
             if authorization:
                 headers = {'Authorization' : authorization}
@@ -68,13 +68,13 @@
             try:
                 body = embed_external_page(embedded_url, prefix,
                                            headers, req.form.get('custom_css'))
-                body = soup2xhtml(body, self.req.encoding)
+                body = soup2xhtml(body, self._cw.encoding)
             except HTTPError, err:
                 body = '<h2>%s</h2><h3>%s</h3>' % (
                     _('error while embedding page'), err)
         self.process_rql(req.form.get('rql'))
-        return self.vreg['views'].main_template(req, self.template,
-                                                rset=self.rset, body=body)
+        return self._cw.vreg['views'].main_template(req, self.template,
+                                                rset=self.cw_rset, body=body)
 
 
 def entity_has_embedable_url(entity):
@@ -100,10 +100,10 @@
     title = _('embed')
 
     def url(self, row=0):
-        entity = self.rset.get_entity(row, 0)
-        url = urljoin(self.req.base_url(), entity.embeded_url())
-        if self.req.form.has_key('rql'):
-            return self.build_url('embed', url=url, rql=self.req.form['rql'])
+        entity = self.cw_rset.get_entity(row, 0)
+        url = urljoin(self._cw.base_url(), entity.embeded_url())
+        if self._cw.form.has_key('rql'):
+            return self.build_url('embed', url=url, rql=self._cw.form['rql'])
         return self.build_url('embed', url=url)
 
 
--- a/web/views/error.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/error.py	Wed Sep 23 19:40:19 2009 +0200
@@ -14,7 +14,7 @@
     __regid__ = '404'
 
     def call(self):
-        _ = self.req._
+        _ = self._cw._
         self.w(u"<h1>%s</h1>" % _('this resource does not exist'))
 
 
@@ -22,6 +22,6 @@
     __regid__ = '500'
 
     def call(self):
-        _ = self.req._
+        _ = self._cw._
         self.w(u"<h1>%s</h1>" %
                _('an error occured, the request cannot be fulfilled'))
--- a/web/views/facets.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/facets.py	Wed Sep 23 19:40:19 2009 +0200
@@ -55,13 +55,13 @@
         if context:
             rset, vid, divid, paginate = context
         else:
-            rset = self.rset
+            rset = self.cw_rset
             vid, divid = None, 'pageContent'
             paginate = view and view.need_navigation
         return rset, vid, divid, paginate
 
     def call(self, view=None):
-        req = self.req
+        req = self._cw
         req.add_js( self.needs_js )
         req.add_css( self.needs_css)
         if self.roundcorners:
@@ -89,7 +89,7 @@
             w(u'<form method="post" id="%sForm" cubicweb:facetargs="%s" action="">'  % (
                 divid, xml_escape(dumps([divid, vid, paginate, self.facetargs()]))))
             w(u'<fieldset>')
-            hiddens = {'facets': ','.join(wdg.facet.id for wdg in widgets),
+            hiddens = {'facets': ','.join(wdg.facet.__regid__ for wdg in widgets),
                        'baserql': baserql}
             for param in ('subvid', 'vtitle'):
                 if param in req.form:
@@ -104,21 +104,21 @@
             cubicweb.info('after facets with rql: %s' % repr(rqlst))
 
     def display_bookmark_link(self, rset):
-        eschema = self.schema.eschema('Bookmark')
-        if eschema.has_perm(self.req, 'add'):
+        eschema = self._cw.schema.eschema('Bookmark')
+        if eschema.has_perm(self._cw, 'add'):
             bk_path = 'view?rql=%s' % rset.printable_rql()
-            bk_title = self.req._('my custom search')
-            linkto = 'bookmarked_by:%s:subject' % self.req.user.eid
+            bk_title = self._cw._('my custom search')
+            linkto = 'bookmarked_by:%s:subject' % self._cw.user.eid
             bk_add_url = self.build_url('add/Bookmark', path=bk_path, title=bk_title, __linkto=linkto)
             bk_base_url = self.build_url('add/Bookmark', title=bk_title, __linkto=linkto)
             bk_link = u'<a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a>' % (
                     xml_escape(bk_base_url),
                     xml_escape(bk_add_url),
-                    self.req._('bookmark this search'))
+                    self._cw._('bookmark this search'))
             self.w(self.bk_linkbox_template % bk_link)
 
     def get_facets(self, rset, mainvar):
-        return self.vreg['facets'].poss_visible_objects(self.req, rset=rset,
+        return self._cw.vreg['facets'].poss_visible_objects(self._cw, rset=rset,
                                                         context='facetbox',
                                                         filtered_variable=mainvar)
 
@@ -149,17 +149,17 @@
 
     @property
     def title(self):
-        return self.req._('entity type')
+        return self._cw._('entity type')
 
     def vocabulary(self):
         """return vocabulary for this facet, eg a list of 2-uple (label, value)
         """
-        etypes = self.rset.column_types(0)
-        return sorted((self.req._(etype), etype) for etype in etypes)
+        etypes = self.cw_rset.column_types(0)
+        return sorted((self._cw._(etype), etype) for etype in etypes)
 
     def add_rql_restrictions(self):
         """add restriction for this facet into the rql syntax tree"""
-        value = self.req.form.get(self.id)
+        value = self._cw.form.get(self.__regid__)
         if not value:
             return
         self.rqlst.add_type_restriction(self.filtered_variable, value)
@@ -188,7 +188,7 @@
     order = 0
     @property
     def title(self):
-        return self.req._('has_text')
+        return self._cw._('has_text')
 
     def get_widget(self):
         """return the widget instance to use to display this facet
@@ -200,7 +200,7 @@
 
     def add_rql_restrictions(self):
         """add restriction for this facet into the rql syntax tree"""
-        value = self.req.form.get(self.id)
+        value = self._cw.form.get(self.__regid__)
         if not value:
             return
         self.rqlst.add_constant_restriction(self.filtered_variable, 'has_text', value, 'String')
--- a/web/views/formrenderers.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/formrenderers.py	Wed Sep 23 19:40:19 2009 +0200
@@ -73,10 +73,10 @@
         w = data.append
         w(self.open_form(form, values))
         if self.display_progress_div:
-            w(u'<div id="progress">%s</div>' % self.req._('validating...'))
+            w(u'<div id="progress">%s</div>' % self._cw._('validating...'))
         w(u'<fieldset>')
         w(tags.input(type=u'hidden', name=u'__form_id',
-                     value=values.get('formvid', form.id)))
+                     value=values.get('formvid', form.__regid__)))
         if form.redirect_path:
             w(tags.input(type='hidden', name='__redirectpath', value=form.redirect_path))
         self.render_fields(w, form, values)
@@ -92,9 +92,9 @@
         if field.label is None:
             return u''
         if isinstance(field.label, tuple): # i.e. needs contextual translation
-            label = self.req.pgettext(*field.label)
+            label = self._cw.pgettext(*field.label)
         else:
-            label = self.req._(field.label)
+            label = self._cw._(field.label)
         attrs = {'for': form.context[field]['id']}
         if field.required:
             attrs['class'] = 'required'
@@ -106,11 +106,11 @@
         if callable(descr):
             descr = descr(form)
         if descr:
-            help.append('<div class="helper">%s</div>' % self.req._(descr))
-        example = field.example_format(self.req)
+            help.append('<div class="helper">%s</div>' % self._cw._(descr))
+        example = field.example_format(self._cw)
         if example:
             help.append('<div class="helper">(%s: %s)</div>'
-                        % (self.req._('sample format'), example))
+                        % (self._cw._('sample format'), example))
         return u'&#160;'.join(help)
 
     # specific methods (mostly to ease overriding) #############################
@@ -120,7 +120,7 @@
 
         This method should be called once inlined field errors has been consumed
         """
-        req = self.req
+        req = self._cw
         errex = form.form_valerror
         # get extra errors
         if errex is not None:
@@ -149,7 +149,7 @@
         else:
             enctype = 'application/x-www-form-urlencoded'
         if form.action is None:
-            action = self.req.build_url('edit')
+            action = self._cw.build_url('edit')
         else:
             action = form.action
         tag = ('<form action="%s" method="post" enctype="%s"' % (
@@ -210,7 +210,7 @@
                 continue
             w(u'<fieldset class="%s">' % (fieldset or u'default'))
             if fieldset:
-                w(u'<legend>%s</legend>' % self.req._(fieldset))
+                w(u'<legend>%s</legend>' % self._cw._(fieldset))
             w(u'<table class="%s">' % self.table_class)
             for field in fields:
                 w(u'<tr class="%s_%s_row">' % (field.name, field.role))
@@ -322,10 +322,10 @@
                 w(u'<tr class="header">')
                 w(u'<th align="left">%s</th>' %
                   tags.input(type='checkbox',
-                             title=self.req._('toggle check boxes'),
+                             title=self._cw._('toggle check boxes'),
                              onclick="setCheckboxesState('eid', this.checked)"))
                 for field in subfields:
-                    w(u'<th>%s</th>' % self.req._(field.label))
+                    w(u'<th>%s</th>' % self._cw._(field.label))
                 w(u'</tr>')
         super(EntityCompositeFormRenderer, self).render_fields(w, form, values)
         if not form.is_subform:
@@ -380,7 +380,7 @@
 
     def open_form(self, form, values):
         attrs_fs_label = ('<div class="iformTitle"><span>%s</span></div>'
-                          % self.req._('main informations'))
+                          % self._cw._('main informations'))
         attrs_fs_label += '<div class="formBody">'
         return attrs_fs_label + super(EntityFormRenderer, self).open_form(form, values)
 
@@ -413,7 +413,7 @@
         srels_by_cat = form.srelations_by_category('generic', 'add', strict=True)
         if not srels_by_cat:
             return u''
-        req = self.req
+        req = self._cw
         _ = req._
         __ = _
         label = u'%s :' % __('This %s' % form.edited_entity.e_schema).capitalize()
@@ -433,7 +433,7 @@
                 if not form.force_display and form.maxrelitems < len(related):
                     link = (u'<span class="invisible">'
                             '[<a href="javascript: window.location.href+=\'&amp;__force_display=1\'">%s</a>]'
-                            '</span>' % self.req._('view all'))
+                            '</span>' % self._cw._('view all'))
                     w(u'<li class="invisible">%s</li>' % link)
                 w(u'</ul>')
                 w(u'</td>')
@@ -491,7 +491,7 @@
 
     def inline_relation_form(self, w, form, rschema, targettype, role):
         entity = form.edited_entity
-        __ = self.req.pgettext
+        __ = self._cw.pgettext
         i18nctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role)
         w(u'<div id="inline%sslot">' % rschema)
         existant = form.display_inline_edition_form(w, rschema, targettype,
@@ -539,11 +539,11 @@
             w(u'<div id="div-%(divid)s">' % values)
         else:
             w(u'<div id="notice-%s" class="notice">%s</div>' % (
-                values['divid'], self.req._('click on the box to cancel the deletion')))
+                values['divid'], self._cw._('click on the box to cancel the deletion')))
         w(u'<div class="iformBody">')
         eschema = form.edited_entity.e_schema
         ctx = values.pop('i18nctx')
-        values['removemsg'] = self.req.pgettext(ctx, 'remove this %s' % eschema)
+        values['removemsg'] = self._cw.pgettext(ctx, 'remove this %s' % eschema)
         w(u'<div class="iformTitle"><span>%(title)s</span> '
           '#<span class="icounter">%(counter)s</span> '
           '[<a href="javascript: %(removejs)s;noop();">%(removemsg)s</a>]</div>'
--- a/web/views/forms.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/forms.py	Wed Sep 23 19:40:19 2009 +0200
@@ -166,9 +166,9 @@
     def add_media(self):
         """adds media (CSS & JS) required by this widget"""
         if self.needs_js:
-            self.req.add_js(self.needs_js)
+            self._cw.add_js(self.needs_js)
         if self.needs_css:
-            self.req.add_css(self.needs_css)
+            self._cw.add_css(self.needs_css)
 
     def form_render(self, **values):
         """render this form, using the renderer given in args or the default
@@ -180,9 +180,9 @@
         return renderer.render(self, values)
 
     def form_default_renderer(self):
-        return self.vreg['formrenderers'].select(self.form_renderer_id,
-                                                self.req, rset=self.rset,
-                                                row=self.row, col=self.col)
+        return self._cw.vreg['formrenderers'].select(self.form_renderer_id,
+                                                self._cw, rset=self.cw_rset,
+                                                row=self.cw_row, col=self.cw_col)
 
     def form_build_context(self, rendervalues=None):
         """build form context values (the .context attribute which is a
@@ -229,17 +229,17 @@
                 if callable(value):
                     value = value(self)
             if value != INTERNAL_FIELD_VALUE:
-                value = field.format_value(self.req, value)
+                value = field.format_value(self._cw, value)
         return value
 
     def _req_display_value(self, field):
         qname = self.form_field_name(field)
         if qname in self.form_previous_values:
             return self.form_previous_values[qname]
-        if qname in self.req.form:
-            return self.req.form[qname]
-        if field.name in self.req.form:
-            return self.req.form[field.name]
+        if qname in self._cw.form:
+            return self._cw.form[qname]
+        if field.name in self._cw.form:
+            return self._cw.form[field.name]
         return None
 
     def form_field_value(self, field, load_bytes=False):
@@ -261,11 +261,11 @@
 
     def form_field_format(self, field):
         """return MIME type used for the given (text or bytes) field"""
-        return self.req.property_value('ui.default-text-format')
+        return self._cw.property_value('ui.default-text-format')
 
     def form_field_encoding(self, field):
         """return encoding used for the given (text) field"""
-        return self.req.encoding
+        return self._cw.encoding
 
     def form_field_name(self, field):
         """return qualified name for the given field"""
@@ -303,19 +303,19 @@
         msg = kwargs.pop('submitmsg', None)
         super(EntityFieldsForm, self).__init__(*args, **kwargs)
         if self.edited_entity is None:
-            self.edited_entity = self.complete_entity(self.row or 0, self.col or 0)
+            self.edited_entity = self.complete_entity(self.cw_row or 0, self.cw_col or 0)
         self.form_add_hidden('__type', eidparam=True)
         self.form_add_hidden('eid')
         if kwargs.get('mainform', True): # mainform default to true in parent
             self.form_add_hidden(u'__maineid', self.edited_entity.eid)
             # If we need to directly attach the new object to another one
-            if self.req.list_form_param('__linkto'):
-                for linkto in self.req.list_form_param('__linkto'):
+            if self._cw.list_form_param('__linkto'):
+                for linkto in self._cw.list_form_param('__linkto'):
                     self.form_add_hidden('__linkto', linkto)
                 if msg:
-                    msg = '%s %s' % (msg, self.req._('and linked'))
+                    msg = '%s %s' % (msg, self._cw._('and linked'))
                 else:
-                    msg = self.req._('entity linked')
+                    msg = self._cw._('entity linked')
         if msg:
             self.form_add_hidden('__message', msg)
 
@@ -361,7 +361,7 @@
         if hasattr(self.edited_entity, defaultattr):
             # XXX bw compat, default_<field name> on the entity
             warn('found %s on %s, should be set on a specific form'
-                 % (defaultattr, self.edited_entity.id), DeprecationWarning)
+                 % (defaultattr, self.edited_entity.__regid__), DeprecationWarning)
             value = getattr(self.edited_entity, defaultattr)
             if callable(value):
                 value = value()
@@ -371,9 +371,9 @@
         return value
 
     def form_default_renderer(self):
-        return self.vreg['formrenderers'].select(
-            self.form_renderer_id, self.req, rset=self.rset, row=self.row,
-            col=self.col, entity=self.edited_entity)
+        return self._cw.vreg['formrenderers'].select(
+            self.form_renderer_id, self._cw, rset=self.cw_rset, row=self.cw_row,
+            col=self.cw_col, entity=self.edited_entity)
 
 ##    def form_build_context(self, values=None):
 ##        """overriden to add edit[s|o] hidden fields and to ensure schema fields
@@ -404,8 +404,8 @@
         if not field.eidparam:
             return super(EntityFieldsForm, self).form_field_value(field, load_bytes)
         if attr == '__type':
-            return entity.id
-        if self.schema.rschema(attr).is_final():
+            return entity.__regid__
+        if self._cw.schema.rschema(attr).is_final():
             attrtype = entity.e_schema.destination(attr)
             if attrtype == 'Password':
                 return entity.has_eid() and INTERNAL_FIELD_VALUE or ''
@@ -434,7 +434,7 @@
         if field.eidparam and entity.e_schema.has_metadata(field.name, 'format') and (
             entity.has_eid() or '%s_format' % field.name in entity):
             return self.edited_entity.attr_metadata(field.name, 'format')
-        return self.req.property_value('ui.default-text-format')
+        return self._cw.property_value('ui.default-text-format')
 
     def form_field_encoding(self, field):
         """return encoding used for the given (text) field"""
@@ -470,7 +470,7 @@
                 vocabfunc = getattr(self, '%s_relation_vocabulary' % role)
             else:
                 warn('found %s on %s, should be set on a specific form'
-                     % (method, self.edited_entity.id), DeprecationWarning)
+                     % (method, self.edited_entity.__regid__), DeprecationWarning)
         # NOTE: it is the responsibility of `vocabfunc` to sort the result
         #       (direclty through RQL or via a python sort). This is also
         #       important because `vocabfunc` might return a list with
@@ -510,7 +510,7 @@
         """
         entity = self.edited_entity
         if isinstance(rtype, basestring):
-            rtype = entity.schema.rschema(rtype)
+            rtype = self._cw.vreg.schema.rschema(rtype)
         done = None
         assert not rtype.is_final(), rtype
         if entity.has_eid():
@@ -532,7 +532,7 @@
         """
         entity = self.edited_entity
         if isinstance(rtype, basestring):
-            rtype = entity.schema.rschema(rtype)
+            rtype = self._cw.vreg.schema.rschema(rtype)
         done = None
         if entity.has_eid():
             done = set(e.eid for e in getattr(entity, 'reverse_%s' % rtype))
--- a/web/views/ibreadcrumbs.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/ibreadcrumbs.py	Wed Sep 23 19:40:19 2009 +0200
@@ -32,7 +32,7 @@
     separator = u'&#160;&gt;&#160;'
 
     def call(self, view=None, first_separator=True):
-        entity = self.rset.get_entity(0, 0)
+        entity = self.cw_rset.get_entity(0, 0)
         path = entity.breadcrumbs(view)
         if path:
             self.w(u'<span id="breadcrumbs" class="pathbar">')
@@ -44,7 +44,7 @@
     def render_breadcrumbs(self, contextentity, path):
         root = path.pop(0)
         if isinstance(root, Entity):
-            self.w(u'<a href="%s">%s</a>' % (self.req.build_url(root.id),
+            self.w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.id),
                                              root.dc_type('plural')))
             self.w(self.separator)
         self.wpath_part(root, contextentity, not path)
@@ -61,11 +61,11 @@
                 self.w(part.view('breadcrumbs'))
         elif isinstance(part, tuple):
             url, title = part
-            textsize = self.req.property_value('navigation.short-line-size')
+            textsize = self._cw.property_value('navigation.short-line-size')
             self.w(u'<a href="%s">%s</a>' % (
                 xml_escape(url), xml_escape(uilib.cut(title, textsize))))
         else:
-            textsize = self.req.property_value('navigation.short-line-size')
+            textsize = self._cw.property_value('navigation.short-line-size')
             self.w(uilib.cut(unicode(part), textsize))
 
 
@@ -76,7 +76,7 @@
         # XXX hack: only display etype name or first non entity path part
         root = path.pop(0)
         if isinstance(root, Entity):
-            self.w(u'<a href="%s">%s</a>' % (self.req.build_url(root.id),
+            self.w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.id),
                                              root.dc_type('plural')))
         else:
             self.wpath_part(root, contextentity, not path)
@@ -89,7 +89,7 @@
         self.w(u'<span id="breadcrumbs" class="pathbar">')
         if first_separator:
             self.w(self.separator)
-        self.w(self.req._('search'))
+        self.w(self._cw._('search'))
         self.w(u'</span>')
 
 
@@ -97,7 +97,7 @@
     __regid__ = 'breadcrumbs'
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         desc = xml_escape(uilib.cut(entity.dc_description(), 50))
         # XXX remember camember : tags.a autoescapes !
         self.w(tags.a(entity.view('breadcrumbtext'),
@@ -108,6 +108,6 @@
     __regid__ = 'breadcrumbtext'
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
-        textsize = self.req.property_value('navigation.short-line-size')
+        entity = self.cw_rset.get_entity(row, col)
+        textsize = self._cw.property_value('navigation.short-line-size')
         self.w(uilib.cut(entity.dc_title(), textsize))
--- a/web/views/idownloadable.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/idownloadable.py	Wed Sep 23 19:40:19 2009 +0200
@@ -50,7 +50,7 @@
     order = 10
 
     def cell_call(self, row, col, title=None, label=None, **kwargs):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         download_box(self.w, entity, title, label)
 
 
@@ -75,7 +75,7 @@
             encoding = None
         else:
             contenttype = entity.download_content_type()
-        self.req.set_content_type(contenttype or self.content_type,
+        self._cw.set_content_type(contenttype or self.content_type,
                                   filename=entity.download_file_name(),
                                   encoding=encoding)
 
@@ -91,7 +91,7 @@
 
 
     def cell_call(self, row, col, title=None, **kwargs):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         url = xml_escape(entity.download_url())
         self.w(u'<a href="%s">%s</a>' % (url, xml_escape(title or entity.dc_title())))
 
@@ -106,14 +106,14 @@
         if contenttype.startswith('image/'):
             self.wview('image', entity.rset, row=entity.row)
         else:
-            self.wview('downloadlink', entity.rset, title=self.req._('download'), row=entity.row)
+            self.wview('downloadlink', entity.rset, title=self._cw._('download'), row=entity.row)
             try:
                 if ENGINE.has_input(contenttype):
                     self.w(entity.printable_value('data'))
             except TransformError:
                 pass
             except Exception, ex:
-                msg = self.req._("can't display data, unexpected error: %s") % ex
+                msg = self._cw._("can't display data, unexpected error: %s") % ex
                 self.w('<div class="error">%s</div>' % msg)
         self.w(u'</div>')
 
@@ -123,12 +123,12 @@
 
     def cell_call(self, row, col, title=None, **kwargs):
         """the oneline view is a link to download the file"""
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         url = xml_escape(entity.absolute_url())
         name = xml_escape(title or entity.download_file_name())
         durl = xml_escape(entity.download_url())
         self.w(u'<a href="%s">%s</a> [<a href="%s">%s</a>]' %
-               (url, name, durl, self.req._('download')))
+               (url, name, durl, self._cw._('download')))
 
 
 class ImageView(EntityView):
@@ -138,18 +138,18 @@
     title = _('image')
 
     def call(self):
-        rset = self.rset
+        rset = self.cw_rset
         for i in xrange(len(rset)):
             self.w(u'<div class="efile">')
-            self.wview(self.id, rset, row=i, col=0)
+            self.wview(self.__regid__, rset, row=i, col=0)
             self.w(u'</div>')
 
     def cell_call(self, row, col, width=None, height=None, link=False):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         #if entity.data_format.startswith('image/'):
         imgtag = u'<img src="%s" alt="%s" ' % (
             xml_escape(entity.download_url()),
-            (self.req._('download %s')  % xml_escape(entity.download_file_name())))
+            (self._cw._('download %s')  % xml_escape(entity.download_file_name())))
         if width:
             imgtag += u'width="%i" ' % width
         if height:
--- a/web/views/igeocodable.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/igeocodable.py	Wed Sep 23 19:40:19 2009 +0200
@@ -23,13 +23,13 @@
 
     def call(self):
         # remove entities that don't define latitude and longitude
-        self.rset = self.rset.filtered_rset(lambda e: e.latitude and e.longitude)
-        zoomlevel = self.req.form.pop('zoomlevel', 8)
-        extraparams = self.req.form.copy()
+        self.cw_rset = self.cw_rset.filtered_rset(lambda e: e.latitude and e.longitude)
+        zoomlevel = self._cw.form.pop('zoomlevel', 8)
+        extraparams = self._cw.form.copy()
         extraparams.pop('vid', None)
         extraparams.pop('rql', None)
         markers = [self.build_marker_data(rowidx, extraparams)
-                   for rowidx in xrange(len(self.rset))]
+                   for rowidx in xrange(len(self.cw_rset))]
         center = {
             'latitude': sum(marker['latitude'] for marker in markers) / len(markers),
             'longitude': sum(marker['longitude'] for marker in markers) / len(markers),
@@ -42,12 +42,12 @@
         self.w(simplejson.dumps(geodata))
 
     def build_marker_data(self, row, extraparams):
-        entity = self.rset.get_entity(row, 0)
+        entity = self.cw_rset.get_entity(row, 0)
         icon = None
         if hasattr(entity, 'marker_icon'):
             icon = entity.marker_icon()
         else:
-            icon = (self.req.external_resource('GMARKER_ICON'), (20, 34), (4, 34), None)
+            icon = (self._cw.external_resource('GMARKER_ICON'), (20, 34), (4, 34), None)
         return {'latitude': entity.latitude, 'longitude': entity.longitude,
                 'title': entity.dc_long_title(),
                 #icon defines : (icon._url, icon.size,  icon.iconAncho', icon.shadow)
@@ -61,7 +61,7 @@
     __select__ = implements(IGeocodable)
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(u'<div>%s</div>' % entity.view('oneline'))
         # FIXME: we should call something like address-view if available
 
@@ -73,13 +73,13 @@
     need_navigation = False
 
     def call(self, gmap_key, width=400, height=400, uselabel=True, urlparams=None):
-        self.req.demote_to_html()
+        self._cw.demote_to_html()
         # remove entities that don't define latitude and longitude
-        self.rset = self.rset.filtered_rset(lambda e: e.latitude and e.longitude)
-        self.req.add_js('http://maps.google.com/maps?sensor=false&file=api&amp;v=2&amp;key=%s' % gmap_key,
+        self.cw_rset = self.cw_rset.filtered_rset(lambda e: e.latitude and e.longitude)
+        self._cw.add_js('http://maps.google.com/maps?sensor=false&file=api&amp;v=2&amp;key=%s' % gmap_key,
                         localfile=False)
-        self.req.add_js( ('cubicweb.widgets.js', 'cubicweb.gmap.js', 'gmap.utility.labeledmarker.js') )
-        rql = self.rset.printable_rql()
+        self._cw.add_js( ('cubicweb.widgets.js', 'cubicweb.gmap.js', 'gmap.utility.labeledmarker.js') )
+        rql = self.cw_rset.printable_rql()
         if urlparams is None:
             loadurl = self.build_url(rql=rql, vid='geocoding-json')
         else:
@@ -94,8 +94,8 @@
 
     def call(self):
         self.w(u'<ol>')
-        for rowidx in xrange(len(self.rset)):
+        for rowidx in xrange(len(self.cw_rset)):
             self.w(u'<li>')
-            self.wview('listitem', self.rset, row=rowidx, col=0)
+            self.wview('listitem', self.cw_rset, row=rowidx, col=0)
             self.w(u'</li>')
         self.w(u'</ol>')
--- a/web/views/iprogress.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/iprogress.py	Wed Sep 23 19:40:19 2009 +0200
@@ -45,21 +45,21 @@
 
     def call(self, columns=None):
         """displays all versions in a table"""
-        self.req.add_css('cubicweb.iprogress.css')
-        _ = self.req._
+        self._cw.add_css('cubicweb.iprogress.css')
+        _ = self._cw._
         self.columns = columns or self.columns
-        ecls = self.vreg['etypes'].etype_class(self.rset.description[0][0])
+        ecls = self._cw.vreg['etypes'].etype_class(self.cw_rset.description[0][0])
         self.w(u'<table class="progress">')
         self.table_header(ecls)
         self.w(u'<tbody>')
-        for row in xrange(self.rset.rowcount):
+        for row in xrange(self.cw_rset.rowcount):
             self.cell_call(row=row, col=0)
         self.w(u'</tbody>')
         self.w(u'</table>')
 
     def cell_call(self, row, col):
-        _ = self.req._
-        entity = self.rset.get_entity(row, col)
+        _ = self._cw._
+        entity = self.cw_rset.get_entity(row, col)
         infos = {}
         for col in self.columns:
             meth = getattr(self, 'build_%s_cell' % col, None)
@@ -83,16 +83,16 @@
 
     def header_for_project(self, ecls):
         """use entity's parent type as label"""
-        return display_name(self.req, ecls.parent_type)
+        return display_name(self._cw, ecls.parent_type)
 
     def header_for_milestone(self, ecls):
         """use entity's type as label"""
-        return display_name(self.req, ecls.id)
+        return display_name(self._cw, ecls.id)
 
     def table_header(self, ecls):
         """builds the table's header"""
         self.w(u'<thead><tr>')
-        _ = self.req._
+        _ = self._cw._
         for column in self.columns:
             meth = getattr(self, 'header_for_%s' % column, None)
             if meth:
@@ -109,7 +109,7 @@
         project = entity.get_main_task()
         if project:
             return project.view('incontext')
-        return self.req._('no related project')
+        return self._cw._('no related project')
 
     def build_milestone_cell(self, entity):
         """``milestone`` column cell renderer"""
@@ -117,7 +117,7 @@
 
     def build_state_cell(self, entity):
         """``state`` column cell renderer"""
-        return xml_escape(self.req._(entity.state))
+        return xml_escape(self._cw._(entity.state))
 
     def build_eta_date_cell(self, entity):
         """``eta_date`` column cell renderer"""
@@ -126,7 +126,7 @@
         formated_date = self.format_date(entity.initial_prevision_date())
         if entity.in_progress():
             eta_date = self.format_date(entity.eta_date())
-            _ = self.req._
+            _ = self._cw._
             if formated_date:
                 formated_date += u' (%s %s)' % (_('expected:'), eta_date)
             else:
@@ -139,7 +139,7 @@
 
     def build_cost_cell(self, entity):
         """``cost`` column cell renderer"""
-        _ = self.req._
+        _ = self._cw._
         pinfo = entity.progress_info()
         totalcost = pinfo.get('estimatedcorrected', pinfo['estimated'])
         missing = pinfo.get('notestimatedcorrected', pinfo.get('notestimated', 0))
@@ -168,8 +168,8 @@
     __regid__ = 'ic_progress_table_view'
 
     def call(self, columns=None):
-        view = self.vreg['views'].select('progress_table_view', self.req,
-                                         rset=self.rset)
+        view = self._cw.vreg['views'].select('progress_table_view', self._cw,
+                                         rset=self.cw_rset)
         columns = list(columns or view.columns)
         try:
             columns.remove('project')
@@ -185,8 +185,8 @@
     __select__ = implements(IProgress)
 
     def cell_call(self, row, col):
-        self.req.add_css('cubicweb.iprogress.css')
-        entity = self.rset.get_entity(row, col)
+        self._cw.add_css('cubicweb.iprogress.css')
+        entity = self.cw_rset.get_entity(row, col)
         widget = ProgressBarWidget(entity.done, entity.todo,
                                    entity.revised_cost)
         self.w(widget.render())
--- a/web/views/isioc.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/isioc.py	Wed Sep 23 19:40:19 2009 +0200
@@ -21,7 +21,7 @@
     content_type = 'text/xml'
 
     def call(self):
-        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
+        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
         self.w(u'''<rdf:RDF
              xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
              xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
@@ -30,12 +30,12 @@
              xmlns:sioc="http://rdfs.org/sioc/ns#"
              xmlns:sioctype="http://rdfs.org/sioc/types#"
              xmlns:dcterms="http://purl.org/dc/terms/">\n''')
-        for i in xrange(self.rset.rowcount):
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self.w(u'</rdf:RDF>\n')
 
     def cell_call(self, row, col):
-        self.wview('sioc_element', self.rset, row=row, col=col)
+        self.wview('sioc_element', self.cw_rset, row=row, col=col)
 
 class SIOCContainerView(EntityView):
     __regid__ = 'sioc_element'
@@ -44,7 +44,7 @@
     content_type = 'text/xml'
 
     def cell_call(self, row, col):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         sioct = xml_escape(entity.isioc_type())
         self.w(u'<sioc:%s rdf:about="%s">\n'
                % (sioct, xml_escape(entity.absolute_url())))
@@ -65,7 +65,7 @@
     content_type = 'text/xml'
 
     def cell_call(self, row, col):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         sioct = xml_escape(entity.isioc_type())
         self.w(u'<sioc:%s rdf:about="%s">\n'
                %  (sioct, xml_escape(entity.absolute_url())))
--- a/web/views/magicsearch.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/magicsearch.py	Wed Sep 23 19:40:19 2009 +0200
@@ -171,9 +171,9 @@
     priority = 2
     def preprocess_query(self, uquery, req):
         rqlst = parse(uquery, print_errors=False)
-        schema = self.vreg.schema
+        schema = self._cw.vreg.schema
         # rql syntax tree will be modified in place if necessary
-        translate_rql_tree(rqlst, trmap(self.config, schema, req.lang), schema)
+        translate_rql_tree(rqlst, trmap(self._cw.config, schema, req.lang), schema)
         return rqlst.as_string(),
 
 
@@ -187,7 +187,7 @@
     def preprocess_query(self, uquery, req):
         """try to get rql from an unicode query string"""
         args = None
-        self.req = req
+        self._cw = req
         try:
             # Process as if there was a quoted part
             args = self._quoted_words_query(uquery)
@@ -210,7 +210,7 @@
         """
         etype = word.capitalize()
         try:
-            return trmap(self.config, self.vreg.schema, self.req.lang)[etype]
+            return trmap(self._cw.config, self._cw.vreg.schema, self._cw.lang)[etype]
         except KeyError:
             raise BadRQLQuery('%s is not a valid entity name' % etype)
 
@@ -222,7 +222,7 @@
         # Need to convert from unicode to string (could be whatever)
         rtype = word.lower()
         # Find the entity name as stored in the DB
-        translations = trmap(self.config, self.vreg.schema, self.req.lang)
+        translations = trmap(self._cw.config, self._cw.vreg.schema, self._cw.lang)
         try:
             translations = translations[rtype]
         except KeyError:
@@ -249,9 +249,9 @@
         searchop = ''
         if '%' in searchstr:
             if rtype:
-                possible_etypes = self.schema.rschema(rtype).objects(etype)
+                possible_etypes = self._cw.schema.rschema(rtype).objects(etype)
             else:
-                possible_etypes = [self.schema.eschema(etype)]
+                possible_etypes = [self._cw.schema.eschema(etype)]
             if searchattr or len(possible_etypes) == 1:
                 searchattr = searchattr or possible_etypes[0].main_attribute()
                 searchop = 'LIKE '
@@ -275,10 +275,10 @@
         """Specific process for three words query (case (3) of preprocess_rql)
         """
         etype = self._get_entity_type(word1)
-        eschema = self.schema.eschema(etype)
+        eschema = self._cw.schema.eschema(etype)
         rtype = self._get_attribute_name(word2, eschema)
         # expand shortcut if rtype is a non final relation
-        if not self.schema.rschema(rtype).is_final():
+        if not self._cw.schema.rschema(rtype).is_final():
             return self._expand_shortcut(etype, rtype, word3)
         if '%' in word3:
             searchop = 'LIKE '
@@ -348,7 +348,7 @@
         super(MagicSearchComponent, self).__init__(req, rset=rset)
         processors = []
         self.by_name = {}
-        for processorcls in self.vreg['components']['magicsearch_processor']:
+        for processorcls in self._cw.vreg['components']['magicsearch_processor']:
             # instantiation needed
             processor = processorcls()
             processors.append(processor)
--- a/web/views/management.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/management.py	Wed Sep 23 19:40:19 2009 +0200
@@ -26,7 +26,7 @@
 
     def schema_definition(self, eschema, link=True,  access_types=None):
         w = self.w
-        _ = self.req._
+        _ = self._cw._
         if not access_types:
             access_types = eschema.ACTIONS
         w(u'<table class="schemaInfo">')
@@ -34,7 +34,7 @@
             _("permission"), _('granted to groups'), _('rql expressions')))
         for access_type in access_types:
             w(u'<tr>')
-            w(u'<td>%s</td>' % self.req.__('%s_perm' % access_type))
+            w(u'<td>%s</td>' % self._cw.__('%s_perm' % access_type))
             groups = eschema.get_groups(access_type)
             l = []
             groups = [(_(group), group) for group in groups]
@@ -43,7 +43,7 @@
                     # XXX we should get a group entity and call its absolute_url
                     # method
                     l.append(u'<a href="%s" class="%s">%s</a><br/>' % (
-                    self.build_url('cwgroup/%s' % group), group, trad))
+                    self._cw.build_url('cwgroup/%s' % group), group, trad))
                 else:
                     l.append(u'<div class="%s">%s</div>' % (group, trad))
             w(u'<td>%s</td>' % u''.join(l))
@@ -73,15 +73,15 @@
     title = _('security')
 
     def call(self):
-        self.w(u'<div id="progress">%s</div>' % self.req._('validating...'))
+        self.w(u'<div id="progress">%s</div>' % self._cw._('validating...'))
         super(SecurityManagementView, self).call()
 
     def cell_call(self, row, col):
-        self.req.add_js('cubicweb.edition.js')
-        self.req.add_css('cubicweb.acl.css')
-        entity = self.rset.get_entity(row, col)
+        self._cw.add_js('cubicweb.edition.js')
+        self._cw.add_css('cubicweb.acl.css')
+        entity = self.cw_rset.get_entity(row, col)
         w = self.w
-        _ = self.req._
+        _ = self._cw._
         w(u'<h1><span class="etype">%s</span> <a href="%s">%s</a></h1>'
           % (entity.dc_type().capitalize(),
              xml_escape(entity.absolute_url()),
@@ -91,7 +91,7 @@
         self.schema_definition(entity.e_schema)
         self.w('<h2>%s</h2>' % _('manage security'))
         # ownership information
-        if self.schema.rschema('owned_by').has_perm(self.req, 'add',
+        if self._cw.schema.rschema('owned_by').has_perm(self._cw, 'add',
                                                     fromeid=entity.eid):
             self.owned_by_edit_form(entity)
         else:
@@ -99,30 +99,30 @@
         # cwpermissions
         if 'require_permission' in entity.e_schema.subject_relations():
             w('<h3>%s</h3>' % _('permissions for this entity'))
-            reqpermschema = self.schema.rschema('require_permission')
+            reqpermschema = self._cw.schema.rschema('require_permission')
             self.require_permission_information(entity, reqpermschema)
-            if reqpermschema.has_perm(self.req, 'add', fromeid=entity.eid):
+            if reqpermschema.has_perm(self._cw, 'add', fromeid=entity.eid):
                 self.require_permission_edit_form(entity)
 
     def owned_by_edit_form(self, entity):
-        self.w('<h3>%s</h3>' % self.req._('ownership'))
-        msg = self.req._('ownerships have been changed')
-        form = self.vreg['forms'].select('base', self.req, entity=entity,
+        self.w('<h3>%s</h3>' % self._cw._('ownership'))
+        msg = self._cw._('ownerships have been changed')
+        form = self._cw.vreg['forms'].select('base', self._cw, entity=entity,
                                          form_renderer_id='base', submitmsg=msg,
                                          form_buttons=[wdgs.SubmitButton()],
                                          domid='ownership%s' % entity.eid,
                                          __redirectvid='security',
                                          __redirectpath=entity.rest_path())
-        field = guess_field(entity.e_schema, self.schema.rschema('owned_by'))
+        field = guess_field(entity.e_schema, self._cw.schema.rschema('owned_by'))
         form.append_field(field)
         self.w(form.form_render(display_progress_div=False))
 
     def owned_by_information(self, entity):
         ownersrset = entity.related('owned_by')
         if ownersrset:
-            self.w('<h3>%s</h3>' % self.req._('ownership'))
+            self.w('<h3>%s</h3>' % self._cw._('ownership'))
             self.w(u'<div class="ownerInfo">')
-            self.w(self.req._('this entity is currently owned by') + ' ')
+            self.w(self._cw._('this entity is currently owned by') + ' ')
             self.wview('csv', entity.related('owned_by'), 'null')
             self.w(u'</div>')
         # else we don't know if this is because entity has no owner or becayse
@@ -131,10 +131,10 @@
     def require_permission_information(self, entity, reqpermschema):
         if entity.require_permission:
             w = self.w
-            _ = self.req._
-            if reqpermschema.has_perm(self.req, 'delete', fromeid=entity.eid):
-                delurl = self.build_url('edit', __redirectvid='security',
-                                        __redirectpath=entity.rest_path())
+            _ = self._cw._
+            if reqpermschema.has_perm(self._cw, 'delete', fromeid=entity.eid):
+                delurl = self._cw.build_url('edit', __redirectvid='security',
+                                            __redirectpath=entity.rest_path())
                 delurl = delurl.replace('%', '%%')
                 # don't give __delete value to build_url else it will be urlquoted
                 # and this will replace %s by %25s
@@ -157,13 +157,13 @@
                 w(u'</tr>\n')
             w(u'</table>')
         else:
-            self.w(self.req._('no associated permissions'))
+            self.w(self._cw._('no associated permissions'))
 
     def require_permission_edit_form(self, entity):
-        newperm = self.vreg['etypes'].etype_class('CWPermission')(self.req)
-        newperm.eid = self.req.varmaker.next()
-        self.w(u'<p>%s</p>' % self.req._('add a new permission'))
-        form = self.vreg['forms'].select('base', self.req, entity=newperm,
+        newperm = self._cw.vreg['etypes'].etype_class('CWPermission')(self._cw)
+        newperm.eid = self._cw.varmaker.next()
+        self.w(u'<p>%s</p>' % self._cw._('add a new permission'))
+        form = self._cw.vreg['forms'].select('base', self._cw, entity=newperm,
                                          form_buttons=[wdgs.SubmitButton()],
                                          domid='reqperm%s' % entity.eid,
                                          __redirectvid='security',
@@ -173,18 +173,18 @@
         permnames = getattr(entity, '__permissions__', None)
         cwpermschema = newperm.e_schema
         if permnames is not None:
-            field = guess_field(cwpermschema, self.schema.rschema('name'),
+            field = guess_field(cwpermschema, self._cw.schema.rschema('name'),
                                 widget=wdgs.Select({'size': 1}),
                                 choices=permnames)
         else:
-            field = guess_field(cwpermschema, self.schema.rschema('name'))
+            field = guess_field(cwpermschema, self._cw.schema.rschema('name'))
         form.append_field(field)
-        field = guess_field(cwpermschema, self.schema.rschema('label'))
+        field = guess_field(cwpermschema, self._cw.schema.rschema('label'))
         form.append_field(field)
-        field = guess_field(cwpermschema, self.schema.rschema('require_group'))
+        field = guess_field(cwpermschema, self._cw.schema.rschema('require_group'))
         form.append_field(field)
-        renderer = self.vreg['formrenderers'].select(
-            'htable', self.req, rset=None, display_progress_div=False)
+        renderer = self._cw.vreg['formrenderers'].select(
+            'htable', self._cw, rset=None, display_progress_div=False)
         self.w(form.form_render(renderer=renderer))
 
 
@@ -197,14 +197,14 @@
         """returns a title according to the result set - used for the
         title in the HTML header
         """
-        return self.req._('an error occured')
+        return self._cw._('an error occured')
 
     def call(self):
-        req = self.req.reset_headers()
+        req = self._cw.reset_headers()
         w = self.w
         ex = req.data.get('ex')#_("unable to find exception information"))
         excinfo = req.data.get('excinfo')
-        title = self.req._('an error occured')
+        title = self._cw._('an error occured')
         w(u'<h2>%s</h2>' % title)
         if 'errmsg' in req.data:
             ex = req.data['errmsg']
@@ -212,7 +212,7 @@
         else:
             exclass = ex.__class__.__name__
             ex = exc_message(ex, req.encoding)
-        if excinfo is not None and self.config['print-traceback']:
+        if excinfo is not None and self._cw.config['print-traceback']:
             if exclass is None:
                 w(u'<div class="tb">%s</div>'
                        % xml_escape(ex).replace("\n","<br />"))
@@ -226,20 +226,20 @@
         # if excinfo is not None, it's probably not a bug
         if excinfo is None:
             return
-        vcconf = self.config.vc_config()
+        vcconf = self._cw.config.vc_config()
         w(u"<div>")
-        eversion = vcconf.get('cubicweb', self.req._('no version information'))
+        eversion = vcconf.get('cubicweb', self._cw._('no version information'))
         # NOTE: tuple wrapping needed since eversion is itself a tuple
         w(u"<b>CubicWeb version:</b> %s<br/>\n" % (eversion,))
         cversions = []
-        for cube in self.config.cubes():
-            cubeversion = vcconf.get(cube, self.req._('no version information'))
+        for cube in self._cw.config.cubes():
+            cubeversion = vcconf.get(cube, self._cw._('no version information'))
             w(u"<b>Package %s version:</b> %s<br/>\n" % (cube, cubeversion))
             cversions.append((cube, cubeversion))
         w(u"</div>")
         # creates a bug submission link if submit-mail is set
-        if self.config['submit-mail']:
-            form = self.vreg['forms'].select('base', self.req, rset=None,
+        if self._cw.config['submit-mail']:
+            form = self._cw.vreg['forms'].select('base', self._cw, rset=None,
                                              mainform=False)
             binfo = text_error_description(ex, excinfo, req, eversion, cversions)
             form.form_add_hidden('description', binfo,
@@ -281,20 +281,20 @@
 
     def call(self, **kwargs):
         """display server information"""
-        vcconf = self.config.vc_config()
-        req = self.req
+        vcconf = self._cw.config.vc_config()
+        req = self._cw
         _ = req._
         # display main information
         self.w(u'<h3>%s</h3>' % _('Application'))
         self.w(u'<table border="1">')
         self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % (
             'CubicWeb', vcconf.get('cubicweb', _('no version information'))))
-        for pkg in self.config.cubes():
+        for pkg in self._cw.config.cubes():
             pkgversion = vcconf.get(pkg, _('no version information'))
             self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % (
                 pkg, pkgversion))
         self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % (
-            _('home'), self.config.apphome))
+            _('home'), self._cw.config.apphome))
         self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % (
             _('base url'), req.base_url()))
         self.w(u'<tr><th align="left">%s</th><td>%s</td></tr>' % (
--- a/web/views/massmailing.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/massmailing.py	Wed Sep 23 19:40:19 2009 +0200
@@ -31,9 +31,9 @@
 
     def url(self):
         params = {'vid': 'massmailing', '__force_display': 1}
-        if self.req.form.has_key('rql'):
-            params['rql'] = self.req.form['rql']
-        return self.build_url(self.req.relative_path(includeparams=False),
+        if self._cw.form.has_key('rql'):
+            params['rql'] = self._cw.form['rql']
+        return self.build_url(self._cw.relative_path(includeparams=False),
                               **params)
 
 
@@ -54,21 +54,21 @@
 
     def form_field_vocabulary(self, field):
         if field.name == 'recipient':
-            vocab = [(entity.get_email(), entity.eid) for entity in self.rset.entities()]
+            vocab = [(entity.get_email(), entity.eid) for entity in self.cw_rset.entities()]
             return [(label, value) for label, value in vocab if label]
         return super(MassMailingForm, self).form_field_vocabulary(field)
 
     def form_field_value(self, field, values):
         if field.name == 'recipient':
-            return [entity.eid for entity in self.rset.entities() if entity.get_email()]
+            return [entity.eid for entity in self.cw_rset.entities() if entity.get_email()]
         elif field.name == 'mailbody':
             field.widget.attrs['cubicweb:variables'] = ','.join(self.get_allowed_substitutions())
         return super(MassMailingForm, self).form_field_value(field, values)
 
     def get_allowed_substitutions(self):
         attrs = []
-        for coltype in self.rset.column_types(0):
-            eclass = self.vreg['etypes'].etype_class(coltype)
+        for coltype in self.cw_rset.column_types(0):
+            eclass = self._cw.vreg['etypes'].etype_class(coltype)
             attrs.append(eclass.allowed_massmail_keys())
         return sorted(reduce(operator.and_, attrs))
 
@@ -76,7 +76,7 @@
         insertLink = u'<a href="javascript: insertText(\'%%(%s)s\', \'emailarea\');">%%(%s)s</a>'
         substs = (u'<div class="substitution">%s</div>' % (insertLink % (subst, subst))
                   for subst in self.get_allowed_substitutions())
-        helpmsg = self.req._('You can use any of the following substitutions in your text')
+        helpmsg = self._cw._('You can use any of the following substitutions in your text')
         return u'<div id="substitutions"><span>%s</span>%s</div>' % (
             helpmsg, u'\n'.join(substs))
 
@@ -122,10 +122,10 @@
     __select__ = implements(IEmailable) & match_user_groups('managers', 'users')
 
     def call(self):
-        req = self.req
+        req = self._cw
         req.add_js('cubicweb.widgets.js', 'cubicweb.massmailing.js')
         req.add_css('cubicweb.mailform.css')
         from_addr = '%s <%s>' % (req.user.dc_title(), req.user.get_email())
-        form = self.vreg['forms'].select('massmailing', self.req, rset=self.rset,
+        form = self._cw.vreg['forms'].select('massmailing', self._cw, rset=self.cw_rset,
                                 action='sendmail', domid='sendmail')
         self.w(form.form_render(sender=from_addr))
--- a/web/views/navigation.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/navigation.py	Wed Sep 23 19:40:19 2009 +0200
@@ -26,8 +26,8 @@
     def call(self):
         """displays a resultset by page"""
         w = self.w
-        req = self.req
-        rset = self.rset
+        req = self._cw
+        rset = self.cw_rset
         page_size = self.page_size
         start = 0
         blocklist = []
@@ -59,12 +59,12 @@
     nb_chars = 5
 
     def display_func(self, rset, col, attrname):
-        req = self.req
+        req = self._cw
         if attrname is not None:
             def index_display(row):
                 entity = rset.get_entity(row, col)
                 return entity.printable_value(attrname, format='text/plain')
-        elif self.schema.eschema(rset.description[0][col]).is_final():
+        elif self._cw.schema.eschema(rset.description[0][col]).is_final():
             def index_display(row):
                 return unicode(rset[row][col])
         else:
@@ -80,9 +80,9 @@
         [ana - cro] | [cro - ghe] | ... | [tim - zou]
         """
         w = self.w
-        rset = self.rset
+        rset = self.cw_rset
         page_size = self.page_size
-        rschema = self.schema.rschema
+        rschema = self._cw.schema.rschema
         # attrname = the name of attribute according to which the sort
         # is done if any
         for sorterm in rset.syntax_tree().children[0].orderby:
@@ -122,10 +122,10 @@
             # nothing usable found, use the first column
             index_display = self.display_func(rset, 0, None)
         blocklist = []
-        params = dict(self.req.form)
+        params = dict(self._cw.form)
         self.clean_params(params)
         start = 0
-        basepath = self.req.relative_path(includeparams=False)
+        basepath = self._cw.relative_path(includeparams=False)
         while start < rset.rowcount:
             stop = min(start + page_size - 1, rset.rowcount - 1)
             cell = self.format_link_content(index_display(start), index_display(stop))
@@ -149,7 +149,7 @@
 def limit_rset_using_paged_nav(self, req, rset, w, forcedisplay=False,
                                show_all_option=True, page_size=None):
     if not (forcedisplay or req.form.get('__force_display') is not None):
-        nav = self.vreg['components'].select_or_none('navigation', req,
+        nav = self._cw.vreg['components'].select_or_none('navigation', req,
                                                      rset=rset, page_size=page_size)
         if nav:
             # get boundaries before component rendering
@@ -170,8 +170,9 @@
 from cubicweb.view import View
 View.pagination = deprecated('.pagination is deprecated, use paginate')(limit_rset_using_paged_nav)
 
-def paginate(view, show_all_option=True, w=None, page_size=None):
-    limit_rset_using_paged_nav(view, view.req, view.rset, w or view.w,
+def paginate(view, show_all_option=True, w=None, page_size=None, rset=None):
+    rset = rset or view.cw_rset
+    limit_rset_using_paged_nav(view, view._cw, view.cw_rset, w or view.w,
                                not view.need_navigation, show_all_option,
                                page_size=page_size)
 View.paginate = paginate
@@ -187,23 +188,23 @@
     context = 'navbottom'
     order = 10
     def call(self, view=None):
-        entity = self.rset.get_entity(0,0)
+        entity = self.cw_rset.get_entity(0,0)
         previous = entity.previous_entity()
         next = entity.next_entity()
         if previous or next:
-            textsize = self.req.property_value('navigation.short-line-size')
+            textsize = self._cw.property_value('navigation.short-line-size')
             self.w(u'<div class="prevnext">')
             if previous:
                 self.w(u'<div class="previousEntity left">')
                 self.w(self.previous_link(previous, textsize))
                 self.w(u'</div>')
-                self.req.html_headers.add_raw('<link rel="prev" href="%s" />'
+                self._cw.html_headers.add_raw('<link rel="prev" href="%s" />'
                                               % xml_escape(previous.absolute_url()))
             if next:
                 self.w(u'<div class="nextEntity right">')
                 self.w(self.next_link(next, textsize))
                 self.w(u'</div>')
-                self.req.html_headers.add_raw('<link rel="next" href="%s" />'
+                self._cw.html_headers.add_raw('<link rel="next" href="%s" />'
                                               % xml_escape(next.absolute_url()))
             self.w(u'</div>')
             self.w(u'<div class="clear"></div>')
@@ -211,11 +212,11 @@
     def previous_link(self, previous, textsize):
         return u'<a href="%s" title="%s">&lt;&lt; %s</a>' % (
             xml_escape(previous.absolute_url()),
-            self.req._('i18nprevnext_previous'),
+            self._cw._('i18nprevnext_previous'),
             xml_escape(cut(previous.dc_title(), textsize)))
 
     def next_link(self, next, textsize):
         return u'<a href="%s" title="%s">%s &gt;&gt;</a>' % (
             xml_escape(next.absolute_url()),
-            self.req._('i18nprevnext_next'),
+            self._cw._('i18nprevnext_next'),
             xml_escape(cut(next.dc_title(), textsize)))
--- a/web/views/old_calendar.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/old_calendar.py	Wed Sep 23 19:40:19 2009 +0200
@@ -44,15 +44,15 @@
         next1 = next_month(date, smallshift)
         prev2 = previous_month(date, bigshift)
         next2 = next_month(date, bigshift)
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         return self.NAV_HEADER % (
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=prev2.year,
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev2.year,
                                        month=prev2.month)),
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=prev1.year,
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev1.year,
                                        month=prev1.month)),
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=next1.year,
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next1.year,
                                        month=next1.month)),
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=next2.year,
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next2.year,
                                        month=next2.month)))
 
 
@@ -86,13 +86,13 @@
                 rows.append(u'<tr>%s%s</tr>' % (WEEKNUM_CELL % day.isocalendar()[1], ''.join(current_row)))
                 current_row = []
         current_row.extend([NO_CELL] * (6-day.weekday()))
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         if day.weekday() != 6:
             rows.append(u'<tr>%s%s</tr>' % (WEEKNUM_CELL % day.isocalendar()[1], ''.join(current_row)))
         url = self.build_url(rql=rql, vid='calendarmonth',
                              year=first_day.year, month=first_day.month)
         monthlink = u'<a href="%s">%s</a>' % (xml_escape(url), umonth)
-        return CALENDAR(self.req) % (monthlink, '\n'.join(rows))
+        return CALENDAR(self._cw) % (monthlink, '\n'.join(rows))
 
     def _mk_schedule(self, begin, end, itemvid='calendaritem'):
         """private method that gathers information from resultset
@@ -106,12 +106,12 @@
                   day2 : { hour : [views] } ... }
         """
         # put this here since all sub views are calling this method
-        self.req.add_css('cubicweb.calendar.css')
+        self._cw.add_css('cubicweb.calendar.css')
         schedule = {}
-        for row in xrange(len(self.rset.rows)):
-            entity = self.rset.get_entity(row,0)
+        for row in xrange(len(self.cw_rset.rows)):
+            entity = self.cw_rset.get_entity(row,0)
             infos = u'<div class="event">'
-            infos += self.view(itemvid, self.rset, row=row)
+            infos += self.view(itemvid, self.cw_rset, row=row)
             infos += u'</div>'
             for date_ in entity.matching_dates(begin, end):
                 day = date(date_.year, date_.month, date_.day)
@@ -167,8 +167,8 @@
 
     def call(self, year=None, month=None):
         """this view renders a 3x3 calendars' table"""
-        year = year or int(self.req.form.get('year', date.today().year))
-        month = month or int(self.req.form.get('month', date.today().month))
+        year = year or int(self._cw.form.get('year', date.today().year))
+        month = month or int(self._cw.form.get('month', date.today().month))
         center_date = date(year, month, 1)
         begin, end = self.get_date_range(day=center_date)
         schedule = self._mk_schedule(begin, end)
@@ -185,8 +185,8 @@
     title = _('calendar (semester)')
 
     def call(self, year=None, month=None):
-        year = year or int(self.req.form.get('year', date.today().year))
-        month = month or int(self.req.form.get('month', date.today().month))
+        year = year or int(self._cw.form.get('year', date.today().year))
+        month = month or int(self._cw.form.get('month', date.today().month))
         begin = previous_month(date(year, month, 1), 2)
         end = next_month(date(year, month, 1), 3)
         schedule = self._mk_schedule(begin, end)
@@ -198,15 +198,15 @@
 
     def build_calendars(self, schedule, begin, end):
         self.w(u'<tr>')
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         for cur_month in date_range(begin, end, incmonth=1):
             umonth = u'%s&#160;%s' % (self.format_date(cur_month, '%B'), cur_month.year)
-            url = self.build_url(rql=rql, vid=self.id,
+            url = self.build_url(rql=rql, vid=self.__regid__,
                                  year=cur_month.year, month=cur_month.month)
             self.w(u'<th colspan="2"><a href="%s">%s</a></th>' % (xml_escape(url),
                                                                   umonth))
         self.w(u'</tr>')
-        _ = self.req._
+        _ = self._cw._
         for day_num in xrange(31):
             self.w(u'<tr>')
             for cur_month in date_range(begin, end, incmonth=1):
@@ -233,8 +233,8 @@
     title = _('calendar (month)')
 
     def call(self, year=None, month=None):
-        year = year or int(self.req.form.get('year', date.today().year))
-        month = month or int(self.req.form.get('month', date.today().month))
+        year = year or int(self._cw.form.get('year', date.today().year))
+        month = month or int(self._cw.form.get('month', date.today().month))
         center_date = date(year, month, 1)
         begin, end = self.get_date_range(day=center_date, shift=1)
         schedule = self._mk_schedule(begin, end)
@@ -250,8 +250,8 @@
     title = _('calendar (week)')
 
     def call(self, year=None, week=None):
-        year = year or int(self.req.form.get('year', date.today().year))
-        week = week or int(self.req.form.get('week', date.today().isocalendar()[1]))
+        year = year or int(self._cw.form.get('year', date.today().year))
+        week = week or int(self._cw.form.get('week', date.today().isocalendar()[1]))
         day0 = date(year, 1, 1)
         first_day_of_week = day0 - day0.weekday()*ONEDAY + ONEWEEK
         begin, end = first_day_of_week- ONEWEEK, first_day_of_week + 2*ONEWEEK
@@ -266,8 +266,8 @@
         self.w(self.nav_header(first_day_of_week))
 
     def build_calendar(self, schedule, weeks):
-        rql = self.rset.printable_rql()
-        _ = self.req._
+        rql = self.cw_rset.printable_rql()
+        _ = self._cw._
         for monday, sunday in weeks:
             umonth = self.format_date(monday, '%B %Y')
             url = self.build_url(rql=rql, vid='calendarmonth',
@@ -293,12 +293,12 @@
         prev2 = date - ONEWEEK * bigshift
         next1 = date + ONEWEEK * smallshift
         next2 = date + ONEWEEK * bigshift
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         return self.NAV_HEADER % (
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=prev2.year, week=prev2.isocalendar()[1])),
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=prev1.year, week=prev1.isocalendar()[1])),
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=next1.year, week=next1.isocalendar()[1])),
-            xml_escape(self.build_url(rql=rql, vid=self.id, year=next2.year, week=next2.isocalendar()[1])))
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev2.year, week=prev2.isocalendar()[1])),
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=prev1.year, week=prev1.isocalendar()[1])),
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next1.year, week=next1.isocalendar()[1])),
+            xml_escape(self.build_url(rql=rql, vid=self.__regid__, year=next2.year, week=next2.isocalendar()[1])))
 
 
 
@@ -311,7 +311,7 @@
         umonth = self.format_date(first_day, '%B %Y') # localized month name
         rows = [] # each row is: (am,pm), (am,pm) ... week_title
         current_row = [(NO_CELL, NO_CELL, NO_CELL)] * first_day.weekday()
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         for daynum in xrange(0, days_in_month(first_day)):
             # build cells day
             day = first_day + timedelta(daynum)
@@ -351,7 +351,7 @@
         url = self.build_url(rql=rql, vid='ampmcalendarmonth',
                              year=first_day.year, month=first_day.month)
         monthlink = '<a href="%s">%s</a>' % (xml_escape(url), umonth)
-        return CALENDAR(self.req) % (monthlink, '\n'.join(formatted_rows))
+        return CALENDAR(self._cw) % (monthlink, '\n'.join(formatted_rows))
 
 
 
@@ -362,15 +362,15 @@
 
     def build_calendars(self, schedule, begin, end):
         self.w(u'<tr>')
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         for cur_month in date_range(begin, end, incmonth=1):
             umonth = u'%s&#160;%s' % (self.format_date(cur_month, '%B'), cur_month.year)
-            url = self.build_url(rql=rql, vid=self.id,
+            url = self.build_url(rql=rql, vid=self.__regid__,
                                  year=cur_month.year, month=cur_month.month)
             self.w(u'<th colspan="3"><a href="%s">%s</a></th>' % (xml_escape(url),
                                                                   umonth))
         self.w(u'</tr>')
-        _ = self.req._
+        _ = self._cw._
         for day_num in xrange(31):
             self.w(u'<tr>')
             for cur_month in date_range(begin, end, incmonth=1):
@@ -402,7 +402,7 @@
         umonth = self.format_date(first_day, '%B %Y') # localized month name
         rows = [] # each row is: (am,pm), (am,pm) ... week_title
         current_row = [(NO_CELL, NO_CELL, NO_CELL)] * first_day.weekday()
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         for daynum in xrange(0, days_in_month(first_day)):
             # build cells day
             day = first_day + timedelta(daynum)
@@ -444,7 +444,7 @@
                              year=first_day.year, month=first_day.month)
         monthlink = '<a href="%s">%s</a>' % (xml_escape(url),
                                              umonth)
-        return CALENDAR(self.req) % (monthlink, '\n'.join(formatted_rows))
+        return CALENDAR(self._cw) % (monthlink, '\n'.join(formatted_rows))
 
 
 
@@ -454,9 +454,9 @@
     title = _('am/pm calendar (week)')
 
     def build_calendar(self, schedule, weeks):
-        rql = self.rset.printable_rql()
+        rql = self.cw_rset.printable_rql()
         w = self.w
-        _ = self.req._
+        _ = self._cw._
         for monday, sunday in weeks:
             umonth = self.format_date(monday, '%B %Y')
             url = self.build_url(rql=rql, vid='ampmcalendarmonth',
--- a/web/views/owl.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/owl.py	Wed Sep 23 19:40:19 2009 +0200
@@ -64,9 +64,9 @@
     content_type = 'application/xml' # 'text/xml'
 
     def call(self, writeprefix=True):
-        skipmeta = int(self.req.form.get('skipmeta', True))
+        skipmeta = int(self._cw.form.get('skipmeta', True))
         if writeprefix:
-            self.w(OWL_OPENING_ROOT % {'appid': self.schema.name})
+            self.w(OWL_OPENING_ROOT % {'appid': self._cw.schema.name})
         self.visit_schema(skiptypes=skipmeta and schema.SKIP_TYPES or ())
         if writeprefix:
             self.w(OWL_CLOSING_ROOT)
@@ -74,12 +74,12 @@
     def should_display_rschema(self, rschema):
         return not rschema in self.skiptypes and (
             rschema.has_local_role('read') or
-            rschema.has_perm(self.req, 'read'))
+            rschema.has_perm(self._cw, 'read'))
 
     def visit_schema(self, skiptypes):
         """get a layout for a whole schema"""
         self.skiptypes = skiptypes
-        entities = sorted(eschema for eschema in self.schema.entities()
+        entities = sorted(eschema for eschema in self._cw.schema.entities()
                           if not eschema.is_final() or eschema in skiptypes)
         self.w(u'<!-- classes definition -->')
         for eschema in entities:
@@ -151,13 +151,13 @@
     content_type = 'application/xml' # 'text/xml'
 
     def call(self):
-        self.w(OWL_OPENING_ROOT % {'appid': self.schema.name})
-        for i in xrange(self.rset.rowcount):
+        self.w(OWL_OPENING_ROOT % {'appid': self._cw.schema.name})
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self.w(OWL_CLOSING_ROOT)
 
     def cell_call(self, row, col):
-        self.wview('owlaboxitem', self.rset, row=row, col=col)
+        self.wview('owlaboxitem', self.cw_rset, row=row, col=col)
 
 
 class OWLABOXItemView(EntityView):
@@ -167,14 +167,14 @@
     content_type = 'application/xml' # 'text/xml'
 
     def cell_call(self, row, col):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         eschema = entity.e_schema
         self.w(u'<%s rdf:ID="%s">' % (eschema, entity.eid))
         self.w(u'<!--attributes-->')
         for rschema, aschema in eschema.attribute_definitions():
             if rschema.meta:
                 continue
-            if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
+            if not (rschema.has_local_role('read') or rschema.has_perm(self._cw, 'read')):
                 continue
             aname = rschema.type
             if aname == 'eid':
@@ -189,14 +189,14 @@
         for rschema, targetschemas, role in eschema.relation_definitions():
             if rschema.meta:
                 continue
-            if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
+            if not (rschema.has_local_role('read') or rschema.has_perm(self._cw, 'read')):
                 continue
             if role == 'object':
                 attr = 'reverse_%s' % rschema.type
             else:
                 attr = rschema.type
             for x in getattr(entity, attr):
-                self.w(u'<%s>%s %s</%s>' % (attr, x.id, x.eid, attr))
+                self.w(u'<%s>%s %s</%s>' % (attr, x.__regid__, x.eid, attr))
         self.w(u'</%s>'% eschema)
 
 
--- a/web/views/plots.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/plots.py	Wed Sep 23 19:40:19 2009 +0200
@@ -128,17 +128,17 @@
 
     def call(self, width=500, height=400):
         # prepare data
-        rqlst = self.rset.syntax_tree()
+        rqlst = self.cw_rset.syntax_tree()
         # XXX try to make it work with unions
         varnames = [var.name for var in rqlst.children[0].get_selected_variables()][1:]
-        abscissa = [row[0] for row in self.rset]
+        abscissa = [row[0] for row in self.cw_rset]
         plots = []
-        nbcols = len(self.rset.rows[0])
+        nbcols = len(self.cw_rset.rows[0])
         for col in xrange(1, nbcols):
-            data = [row[col] for row in self.rset]
+            data = [row[col] for row in self.cw_rset]
             plots.append(filterout_nulls(abscissa, data))
         plotwidget = FlotPlotWidget(varnames, plots, timemode=self.timemode)
-        plotwidget.render(self.req, width, height, w=self.w)
+        plotwidget.render(self._cw, width, height, w=self.w)
 
 
 class TimeSeriePlotView(PlotView):
@@ -176,20 +176,20 @@
         __select__ = at_least_two_columns() & second_column_is_number()
 
         def _guess_vid(self, row):
-            etype = self.rset.description[row][0]
-            if self.schema.eschema(etype).is_final():
+            etype = self.cw_rset.description[row][0]
+            if self._cw.schema.eschema(etype).is_final():
                 return 'final'
             return 'textincontext'
 
         def call(self, title=None, width=None, height=None):
             labels = []
             values = []
-            for rowidx, (_, value) in enumerate(self.rset):
+            for rowidx, (_, value) in enumerate(self.cw_rset):
                 if value is not None:
                     vid = self._guess_vid(rowidx)
-                    label = '%s: %s' % (self.view(vid, self.rset, row=rowidx, col=0),
+                    label = '%s: %s' % (self.view(vid, self.cw_rset, row=rowidx, col=0),
                                         value)
-                    labels.append(label.encode(self.req.encoding))
+                    labels.append(label.encode(self._cw.encoding))
                     values.append(value)
             pie = PieChartWidget(labels, values, pieclass=self.pieclass,
                                  title=title)
--- a/web/views/primary.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/primary.py	Wed Sep 23 19:40:19 2009 +0200
@@ -40,8 +40,8 @@
     def cell_call(self, row, col):
         self.cw_row = row
         self.cw_col = col
-        self.maxrelated = self.req.property_value('navigation.related-limit')
-        entity = self.complete_entity(row, col)
+        self.maxrelated = self._cw.property_value('navigation.related-limit')
+        entity = self.cw_rset.complete_entity(row, col)
         self.render_entity(entity)
 
     def render_entity(self, entity):
@@ -73,10 +73,10 @@
 
     def content_navigation_components(self, context):
         self.w(u'<div class="%s">' % context)
-        for comp in self.vreg['contentnavigation'].poss_visible_objects(
-            self.req, rset=self.rset, row=self.row, view=self, context=context):
+        for comp in self._cw.vreg['contentnavigation'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, row=self.cw_row, view=self, context=context):
             try:
-                comp.render(w=self.w, row=self.row, view=self)
+                comp.render(w=self.w, row=self.cw_row, view=self)
             except NotImplementedError:
                 warn('component %s doesnt implement cell_call, please update'
                      % comp.__class__, DeprecationWarning)
@@ -136,7 +136,7 @@
                 self.w(u'</div>')
             else:
                 try:
-                    box.render(w=self.w, row=self.row)
+                    box.render(w=self.w, row=self.cw_row)
                 except NotImplementedError:
                     # much probably a context insensitive box, which only implements
                     # .call() and not cell_call()
@@ -148,11 +148,11 @@
             rset = self._relation_rset(entity, rschema, role, dispctrl)
             if not rset:
                 continue
-            label = display_name(self.req, rschema.type, role)
+            label = display_name(self._cw, rschema.type, role)
             vid = dispctrl.get('vid', 'sidebox')
             sideboxes.append( (label, rset, vid) )
-        sideboxes += self.vreg['boxes'].poss_visible_objects(
-            self.req, rset=self.rset, row=self.row, view=self,
+        sideboxes += self._cw.vreg['boxes'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, row=self.cw_row, view=self,
             context='incontext')
         return sideboxes
 
@@ -190,7 +190,7 @@
     def _render_relation(self, rset, dispctrl, defaultvid, showlabel):
         self.w(u'<div class="section">')
         if showlabel:
-            self.w(u'<h4>%s</h4>' % self.req._(dispctrl['label']))
+            self.w(u'<h4>%s</h4>' % self._cw._(dispctrl['label']))
         self.wview(dispctrl.get('vid', defaultvid), rset)
         self.w(u'</div>')
 
@@ -199,7 +199,7 @@
             show_label = self.show_attr_label
         else:
             show_label = self.show_rel_label
-        label = display_name(self.req, rschema.type, role)
+        label = display_name(self._cw, rschema.type, role)
         self.field(label, value, show_label=show_label, tr=False)
 
 
@@ -207,26 +207,26 @@
     __regid__ = 'autolimited'
     def call(self, title=None, **kwargs):
         # if not too many entities, show them all in a list
-        maxrelated = self.req.property_value('navigation.related-limit')
+        maxrelated = self._cw.property_value('navigation.related-limit')
         if title:
             self.w(u'<div class="title"><span>%s</span></div>' % title)
-        if self.rset.rowcount <= maxrelated:
-            if self.rset.rowcount == 1:
-                self.wview('incontext', self.rset, row=0)
-            elif 1 < self.rset.rowcount <= 5:
-                self.wview('csv', self.rset)
+        if self.cw_rset.rowcount <= maxrelated:
+            if self.cw_rset.rowcount == 1:
+                self.wview('incontext', self.cw_rset, row=0)
+            elif 1 < self.cw_rset.rowcount <= 5:
+                self.wview('csv', self.cw_rset)
             else:
                 self.w(u'<div>')
-                self.wview('simplelist', self.rset)
+                self.wview('simplelist', self.cw_rset)
                 self.w(u'</div>')
         # else show links to display related entities
         else:
-            rql = self.rset.printable_rql()
-            self.rset.limit(maxrelated)
+            rql = self.cw_rset.printable_rql()
+            self.cw_rset.limit(maxrelated)
             self.w(u'<div>')
-            self.wview('simplelist', self.rset)
-            self.w(u'[<a href="%s">%s</a>]' % (self.build_url(rql=rql),
-                                               self.req._('see them all')))
+            self.wview('simplelist', self.cw_rset)
+            self.w(u'[<a href="%s">%s</a>]' % (self._cw.build_url(rql=rql),
+                                               self._cw._('see them all')))
             self.w(u'</div>')
 
 ## default primary ui configuration ###########################################
--- a/web/views/pyviews.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/pyviews.py	Wed Sep 23 19:40:19 2009 +0200
@@ -16,7 +16,7 @@
 
     def call(self, pyvalue, headers=None):
         if headers is None:
-            headers = self.req.form.get('headers')
+            headers = self._cw.form.get('headers')
         self.w(u'<table class="listing">\n')
         if headers:
             self.w(u'<tr>')
--- a/web/views/schema.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/schema.py	Wed Sep 23 19:40:19 2009 +0200
@@ -44,8 +44,8 @@
 
     def call(self):
         """display schema information"""
-        self.req.add_js('cubicweb.ajax.js')
-        self.req.add_css(('cubicweb.schema.css','cubicweb.acl.css'))
+        self._cw.add_js('cubicweb.ajax.js')
+        self._cw.add_css(('cubicweb.schema.css','cubicweb.acl.css'))
         self.w(u'<h1>%s</h1>' % _('Schema of the data model'))
         self.render_tabs(self.tabs, self.default_tab)
 
@@ -57,17 +57,17 @@
         self.w(_(u'<div>This schema of the data model <em>excludes</em> the '
                  u'meta-data, but you can also display a <a href="%s">complete '
                  u'schema with meta-data</a>.</div>')
-               % xml_escape(self.build_url('view', vid='schemagraph', skipmeta=0)))
+               % xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=0)))
         self.w(u'<img src="%s" alt="%s"/>\n' % (
-            xml_escape(self.req.build_url('view', vid='schemagraph', skipmeta=1)),
-            self.req._("graphical representation of the instance'schema")))
+            xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=1)),
+            self._cw._("graphical representation of the instance'schema")))
 
 
 class SchemaTabTextView(StartupView):
     __regid__ = 'schema-text'
 
     def call(self):
-        rset = self.req.execute('Any X ORDERBY N WHERE X is CWEType, X name N, '
+        rset = self._cw.execute('Any X ORDERBY N WHERE X is CWEType, X name N, '
                                 'X final FALSE')
         self.wview('table', rset, displayfilter=True)
 
@@ -77,13 +77,13 @@
     __select__ = StartupView.__select__ & match_user_groups('managers')
 
     def call(self, display_relations=True):
-        self.req.add_css('cubicweb.acl.css')
-        skiptypes = skip_types(self.req)
+        self._cw.add_css('cubicweb.acl.css')
+        skiptypes = skip_types(self._cw)
         formparams = {}
-        formparams['sec'] = self.id
+        formparams['sec'] = self.__regid__
         if not skiptypes:
             formparams['skipmeta'] = u'0'
-        schema = self.schema
+        schema = self._cw.schema
         # compute entities
         entities = sorted(eschema for eschema in schema.entities()
                           if not (eschema.is_final() or eschema in skiptypes))
@@ -96,20 +96,20 @@
         else:
             relations = []
         # index
-        _ = self.req._
+        _ = self._cw._
         self.w(u'<div id="schema_security"><a id="index" href="index"/>')
         self.w(u'<h2 class="schema">%s</h2>' % _('index').capitalize())
         self.w(u'<h4>%s</h4>' %   _('Entities').capitalize())
         ents = []
         for eschema in sorted(entities):
-            url = xml_escape(self.build_url('schema', **formparams))
+            url = xml_escape(self._cw.build_url('schema', **formparams))
             ents.append(u'<a class="grey" href="%s#%s">%s</a> (%s)' % (
                 url,  eschema.type, eschema.type, _(eschema.type)))
         self.w(u', '.join(ents))
         self.w(u'<h4>%s</h4>' % (_('relations').capitalize()))
         rels = []
         for rschema in sorted(relations):
-            url = xml_escape(self.build_url('schema', **formparams))
+            url = xml_escape(self._cw.build_url('schema', **formparams))
             rels.append(u'<a class="grey" href="%s#%s">%s</a> (%s), ' %  (
                 url , rschema.type, rschema.type, _(rschema.type)))
         self.w(u', '.join(ents))
@@ -121,18 +121,18 @@
         self.w(u'</div>')
 
     def display_entities(self, entities, formparams):
-        _ = self.req._
+        _ = self._cw._
         self.w(u'<a id="entities" href="entities"/>')
         self.w(u'<h2 class="schema">%s</h2>' % _('permissions for entities').capitalize())
         for eschema in entities:
             self.w(u'<a id="%s" href="%s"/>' %  (eschema.type, eschema.type))
             self.w(u'<h3 class="schema">%s (%s) ' % (eschema.type, _(eschema.type)))
-            url = xml_escape(self.build_url('schema', **formparams) + '#index')
+            url = xml_escape(self._cw.build_url('schema', **formparams) + '#index')
             self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % (
-                url,  self.req.external_resource('UP_ICON'), _('up')))
+                url,  self._cw.external_resource('UP_ICON'), _('up')))
             self.w(u'</h3>')
             self.w(u'<div style="margin: 0px 1.5em">')
-            self.schema_definition(eschema, link=False)
+            self._cw.schema_definition(eschema, link=False)
             # display entity attributes only if they have some permissions modified
             modified_attrs = []
             for attr, etype in  eschema.attribute_definitions():
@@ -144,19 +144,19 @@
                 self.w(u'<div style="margin: 0px 6em">')
                 for attr in  modified_attrs:
                     self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attr.type, _(attr.type)))
-                    self.schema_definition(attr, link=False)
+                    self._cw.schema_definition(attr, link=False)
             self.w(u'</div>')
 
     def display_relations(self, relations, formparams):
-        _ = self.req._
+        _ = self._cw._
         self.w(u'<a id="relations" href="relations"/>')
         self.w(u'<h2 class="schema">%s </h2>' % _('permissions for relations').capitalize())
         for rschema in relations:
             self.w(u'<a id="%s" href="%s"/>' %  (rschema.type, rschema.type))
             self.w(u'<h3 class="schema">%s (%s) ' % (rschema.type, _(rschema.type)))
-            url = xml_escape(self.build_url('schema', **formparams) + '#index')
+            url = xml_escape(self._cw.build_url('schema', **formparams) + '#index')
             self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % (
-                url,  self.req.external_resource('UP_ICON'), _('up')))
+                url,  self._cw.external_resource('UP_ICON'), _('up')))
             self.w(u'</h3>')
             self.w(u'<div style="margin: 0px 1.5em">')
             subjects = [str(subj) for subj in rschema.subjects()]
@@ -168,7 +168,7 @@
                 _('object_plural:'),
                 ', '.join(str(obj) for obj in rschema.objects()),
                 ', '.join(_(str(obj)) for obj in rschema.objects())))
-            self.schema_definition(rschema, link=False)
+            self._cw.schema_definition(rschema, link=False)
             self.w(u'</div>')
 
 
@@ -176,9 +176,9 @@
     __regid__ = 'schema-block'
 
     def call(self):
-        viewer = SchemaViewer(self.req)
-        layout = viewer.visit_schema(self.schema, display_relations=True,
-                                     skiptypes=skip_types(self.req))
+        viewer = SchemaViewer(self._cw)
+        layout = viewer.visit_schema(self._cw.schema, display_relations=True,
+                                     skiptypes=skip_types(self._cw))
         self.w(uilib.ureport_as_html(layout))
 
 
@@ -200,7 +200,7 @@
     __select__ = implements('CWEType')
 
     def cell_call(self, row, col, **kwargs):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         final = entity.final
         if final:
             self.w(u'<em class="finalentity">')
@@ -228,9 +228,9 @@
     __select__ = EntityView.__select__ & implements('CWEType')
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(u'<h2>%s</h2>' % _('Attributes'))
-        rset = self.req.execute('Any N,F,D,I,J,DE,A '
+        rset = self._cw.execute('Any N,F,D,I,J,DE,A '
                                 'ORDERBY AA WHERE A is CWAttribute, '
                                 'A ordernum AA, A defaultval D, '
                                 'A description DE, '
@@ -241,7 +241,7 @@
                                 {'x': entity.eid})
         self.wview('editable-table', rset, 'null', displayfilter=True)
         self.w(u'<h2>%s</h2>' % _('Relations'))
-        rset = self.req.execute(
+        rset = self._cw.execute(
             'Any R,C,TT,K,D,A,RN,TTN ORDERBY RN '
             'WHERE A is CWRelation, A description D, A composite K?, '
             'A relation_type R, R name RN, A to_entity TT, TT name TTN, '
@@ -249,7 +249,7 @@
             {'x': entity.eid})
         self.wview('editable-table', rset, 'null', displayfilter=True,
                    displaycols=range(6), mainindex=5)
-        rset = self.req.execute(
+        rset = self._cw.execute(
             'Any R,C,TT,K,D,A,RN,TTN ORDERBY RN '
             'WHERE A is CWRelation, A description D, A composite K?, '
             'A relation_type R, R name RN, A from_entity TT, TT name TTN, '
@@ -264,11 +264,11 @@
     __select__ = EntityView.__select__ & implements('CWEType')
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         url = entity.absolute_url(vid='schemagraph')
         self.w(u'<img src="%s" alt="%s"/>' % (
             xml_escape(url),
-            xml_escape(self.req._('graphical schema for %s') % entity.name)))
+            xml_escape(self._cw._('graphical schema for %s') % entity.name)))
 
 
 class CWETypeSPermView(EntityView):
@@ -276,24 +276,24 @@
     __select__ = EntityView.__select__ & implements('CWEType')
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(u'<h2>%s</h2>' % _('Add permissions'))
-        rset = self.req.execute('Any P WHERE X add_permission P, '
+        rset = self._cw.execute('Any P WHERE X add_permission P, '
                                 'X eid %(x)s',
                                 {'x': entity.eid})
         self.wview('outofcontext', rset, 'null')
         self.w(u'<h2>%s</h2>' % _('Read permissions'))
-        rset = self.req.execute('Any P WHERE X read_permission P, '
+        rset = self._cw.execute('Any P WHERE X read_permission P, '
                                 'X eid %(x)s',
                                 {'x': entity.eid})
         self.wview('outofcontext', rset, 'null')
         self.w(u'<h2>%s</h2>' % _('Update permissions'))
-        rset = self.req.execute('Any P WHERE X update_permission P, '
+        rset = self._cw.execute('Any P WHERE X update_permission P, '
                                 'X eid %(x)s',
                                 {'x': entity.eid})
         self.wview('outofcontext', rset, 'null')
         self.w(u'<h2>%s</h2>' % _('Delete permissions'))
-        rset = self.req.execute('Any P WHERE X delete_permission P, '
+        rset = self._cw.execute('Any P WHERE X delete_permission P, '
                                 'X eid %(x)s',
                                 {'x': entity.eid})
         self.wview('outofcontext', rset, 'null')
@@ -305,10 +305,10 @@
                   has_related_entities('workflow_of', 'object'))
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         if entity.default_workflow:
             wf = entity.default_workflow[0]
-            self.w(u'<h1>%s (%s)</h1>' % (wf.name, self.req._('default')))
+            self.w(u'<h1>%s (%s)</h1>' % (wf.name, self._cw._('default')))
             self.wf_image(wf)
         for altwf in entity.reverse_workflow_of:
             if altwf.eid == wf.eid:
@@ -319,7 +319,7 @@
     def wf_image(self, wf):
         self.w(u'<img src="%s" alt="%s"/>' % (
             xml_escape(wf.absolute_url(vid='wfgraph')),
-            xml_escape(self.req._('graphical representation of %s') % wf.name)))
+            xml_escape(self._cw._('graphical representation of %s') % wf.name)))
 
 
 # CWRType ######################################################################
@@ -331,12 +331,12 @@
 
     def render_entity_attributes(self, entity):
         super(CWRTypeSchemaView, self).render_entity_attributes(entity)
-        rschema = self.vreg.schema.rschema(entity.name)
-        viewer = SchemaViewer(self.req)
+        rschema = self._cw.vreg.schema.rschema(entity.name)
+        viewer = SchemaViewer(self._cw)
         layout = viewer.visit_relationschema(rschema)
         self.w(uilib.ureport_as_html(layout))
         if not rschema.is_final():
-            msg = self.req._('graphical schema for %s') % entity.name
+            msg = self._cw._('graphical schema for %s') % entity.name
             self.w(tags.img(src=entity.absolute_url(vid='schemagraph'),
                             alt=msg))
 
@@ -345,18 +345,18 @@
 
 class RestrictedSchemaVisitorMixIn(object):
     def __init__(self, req, *args, **kwargs):
-        self.req = req
+        self._cw = req
         super(RestrictedSchemaVisitorMixIn, self).__init__(*args, **kwargs)
 
     def should_display_schema(self, rschema):
         return (super(RestrictedSchemaVisitorMixIn, self).should_display_schema(rschema)
                 and (rschema.has_local_role('read')
-                     or rschema.has_perm(self.req, 'read')))
+                     or rschema.has_perm(self._cw, 'read')))
 
     def should_display_attr(self, rschema):
         return (super(RestrictedSchemaVisitorMixIn, self).should_display_attr(rschema)
                 and (rschema.has_local_role('read')
-                     or rschema.has_perm(self.req, 'read')))
+                     or rschema.has_perm(self._cw, 'read')))
 
 
 class FullSchemaVisitor(RestrictedSchemaVisitorMixIn, s2d.FullSchemaVisitor):
@@ -377,9 +377,9 @@
 
     def _generate(self, tmpfile):
         """display global schema information"""
-        print 'skipedtypes', skip_types(self.req)
-        visitor = FullSchemaVisitor(self.req, self.schema,
-                                    skiptypes=skip_types(self.req))
+        print 'skipedtypes', skip_types(self._cw)
+        visitor = FullSchemaVisitor(self._cw, self._cw.schema,
+                                    skiptypes=skip_types(self._cw))
         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
 
 
@@ -390,10 +390,10 @@
 
     def _generate(self, tmpfile):
         """display schema information for an entity"""
-        entity = self.rset.get_entity(self.row, self.col)
-        eschema = self.vreg.schema.eschema(entity.name)
-        visitor = OneHopESchemaVisitor(self.req, eschema,
-                                       skiptypes=skip_types(self.req))
+        entity = self.cw_rset.get_entity(self.cw_row, self.cw_col)
+        eschema = self._cw.vreg.schema.eschema(entity.name)
+        visitor = OneHopESchemaVisitor(self._cw, eschema,
+                                       skiptypes=skip_types(self._cw))
         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
 
 
@@ -402,9 +402,9 @@
 
     def _generate(self, tmpfile):
         """display schema information for an entity"""
-        entity = self.rset.get_entity(self.row, self.col)
-        rschema = self.vreg.schema.rschema(entity.name)
-        visitor = OneHopRSchemaVisitor(self.req, rschema)
+        entity = self.cw_rset.get_entity(self.cw_row, self.cw_col)
+        rschema = self._cw.vreg.schema.rschema(entity.name)
+        visitor = OneHopRSchemaVisitor(self._cw, rschema)
         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
 
 
@@ -424,4 +424,4 @@
     order = 30
 
     def url(self):
-        return self.build_url(self.id)
+        return self._cw.build_url(self.__regid__)
--- a/web/views/sparql.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/sparql.py	Wed Sep 23 19:40:19 2009 +0200
@@ -32,29 +32,29 @@
     form_buttons = [fwdgs.SubmitButton()]
     @property
     def action(self):
-        return self.req.url()
+        return self._cw.url()
 
 
 class SparqlFormView(form.FormViewMixIn, StartupView):
     __regid__ = 'sparql'
     def call(self):
-        form = self.vreg.select('forms', 'sparql', self.req)
+        form = self._cw.vreg.select('forms', 'sparql', self._cw)
         self.w(form.form_render())
-        sparql = self.req.form.get('sparql')
-        vid = self.req.form.get('resultvid', 'table')
+        sparql = self._cw.form.get('sparql')
+        vid = self._cw.form.get('resultvid', 'table')
         if sparql:
             try:
-                qinfo = Sparql2rqlTranslator(self.schema).translate(sparql)
+                qinfo = Sparql2rqlTranslator(self._cw.schema).translate(sparql)
             except rql.TypeResolverException, ex:
-                self.w(self.req._('can not resolve entity types:') + u' ' + unicode('ex'))
+                self.w(self._cw._('can not resolve entity types:') + u' ' + unicode('ex'))
             except UnsupportedQuery:
-                self.w(self.req._('we are not yet ready to handle this query'))
+                self.w(self._cw._('we are not yet ready to handle this query'))
             except xy.UnsupportedVocabulary, ex:
-                self.w(self.req._('unknown vocabulary:') + u' ' + unicode('ex'))
+                self.w(self._cw._('unknown vocabulary:') + u' ' + unicode('ex'))
             if vid == 'sparqlxml':
                 url = self.build_url('view', rql=qinfo.finalize(), vid=vid)
                 raise Redirect(url)
-            rset = self.req.execute(qinfo.finalize())
+            rset = self._cw.execute(qinfo.finalize())
             self.wview(vid, rset, 'null')
 
 
@@ -87,10 +87,10 @@
 
     def call(self):
         # XXX handle UNION
-        rqlst = self.rset.syntax_tree().children[0]
+        rqlst = self.cw_rset.syntax_tree().children[0]
         varnames = [var.name for var in rqlst.selection]
         results = E.results()
-        for rowidx in xrange(len(self.rset)):
+        for rowidx in xrange(len(self.cw_rset)):
             result = E.result()
             for colidx, varname in enumerate(varnames):
                 result.append(self.cell_binding(rowidx, colidx, varname))
@@ -101,21 +101,21 @@
         self.w(etree.tostring(sparql, encoding=unicode, pretty_print=True))
 
     def cell_binding(self, row, col, varname):
-        celltype = self.rset.description[row][col]
-        if self.schema.eschema(celltype).is_final():
-            cellcontent = self.view('cell', self.rset, row=row, col=col)
+        celltype = self.cw_rset.description[row][col]
+        if self._cw.schema.eschema(celltype).is_final():
+            cellcontent = self.view('cell', self.cw_rset, row=row, col=col)
             return E.binding(E.literal(cellcontent,
                                        datatype=xmlschema(celltype)),
                              name=varname)
         else:
-            entity = self.rset.get_entity(row, col)
+            entity = self.cw_rset.get_entity(row, col)
             return E.binding(E.uri(entity.absolute_url()), name=varname)
 
     def set_request_content_type(self):
         """overriden to set the correct filetype and filename"""
-        self.req.set_content_type(self.content_type,
+        self._cw.set_content_type(self.content_type,
                                   filename='sparql.xml',
-                                  encoding=self.req.encoding)
+                                  encoding=self._cw.encoding)
 
 def registration_callback(vreg):
     if Sparql2rqlTranslator is not None:
--- a/web/views/startup.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/startup.py	Wed Sep 23 19:40:19 2009 +0200
@@ -27,7 +27,7 @@
 
     def call(self, **kwargs):
         """The default view representing the instance's management"""
-        self.req.add_css('cubicweb.manageview.css')
+        self._cw.add_css('cubicweb.manageview.css')
         self.w(u'<div>\n')
         if not self.display_folders():
             self._main_index()
@@ -42,10 +42,10 @@
         self.w(u'</div>\n')
 
     def _main_index(self):
-        req = self.req
+        req = self._cw
         manager = req.user.matching_groups('managers')
-        if not manager and 'Card' in self.schema:
-            rset = self.req.execute('Card X WHERE X wikiid "index"')
+        if not manager and 'Card' in self._cw.schema:
+            rset = self._cw.execute('Card X WHERE X wikiid "index"')
         else:
             rset = None
         if rset:
@@ -54,46 +54,46 @@
             self.entities()
             self.w(u'<div class="hr">&#160;</div>')
             self.startup_views()
-        if manager and 'Card' in self.schema:
+        if manager and 'Card' in self._cw.schema:
             self.w(u'<div class="hr">&#160;</div>')
             if rset:
                 href = rset.get_entity(0, 0).absolute_url(vid='edition')
-                label = self.req._('edit the index page')
+                label = self._cw._('edit the index page')
             else:
                 href = req.build_url('view', vid='creation', etype='Card', wikiid='index')
-                label = self.req._('create an index page')
+                label = self._cw._('create an index page')
             self.w(u'<br/><a href="%s">%s</a>\n' % (xml_escape(href), label))
 
     def folders(self):
-        self.w(u'<h4>%s</h4>\n' % self.req._('Browse by category'))
-        self.vreg['views'].select('tree', self.req).render(w=self.w)
+        self.w(u'<h4>%s</h4>\n' % self._cw._('Browse by category'))
+        self._cw.vreg['views'].select('tree', self._cw).render(w=self.w)
 
     def startup_views(self):
-        self.w(u'<h4>%s</h4>\n' % self.req._('Startup views'))
+        self.w(u'<h4>%s</h4>\n' % self._cw._('Startup views'))
         self.startupviews_table()
 
     def startupviews_table(self):
-        for v in self.vreg['views'].possible_views(self.req, None):
+        for v in self._cw.vreg['views'].possible_views(self._cw, None):
             if v.category != 'startupview' or v.id in ('index', 'tree', 'manage'):
                 continue
             self.w('<p><a href="%s">%s</a></p>' % (
-                xml_escape(v.url()), xml_escape(self.req._(v.title).capitalize())))
+                xml_escape(v.url()), xml_escape(self._cw._(v.title).capitalize())))
 
     def entities(self):
-        schema = self.schema
-        self.w(u'<h4>%s</h4>\n' % self.req._('The repository holds the following entities'))
-        manager = self.req.user.matching_groups('managers')
+        schema = self._cw.schema
+        self.w(u'<h4>%s</h4>\n' % self._cw._('The repository holds the following entities'))
+        manager = self._cw.user.matching_groups('managers')
         self.w(u'<table class="startup">')
         if manager:
-            self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('application entities'))
+            self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self._cw._('application entities'))
         self.entity_types_table(eschema for eschema in schema.entities()
                                 if uicfg.indexview_etype_section.get(eschema) == 'application')
         if manager:
-            self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('system entities'))
+            self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self._cw._('system entities'))
             self.entity_types_table(eschema for eschema in schema.entities()
                                 if uicfg.indexview_etype_section.get(eschema) == 'system')
             if 'CWAttribute' in schema: # check schema support
-                self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('schema entities'))
+                self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self._cw._('schema entities'))
                 self.entity_types_table(eschema for eschema in schema.entities()
                                         if uicfg.indexview_etype_section.get(eschema) == 'schema')
         self.w(u'</table>')
@@ -117,7 +117,7 @@
         """return a list of formatted links to get a list of entities of
         a each entity's types
         """
-        req = self.req
+        req = self._cw
         for eschema in eschemas:
             if eschema.is_final() or (not eschema.has_perm(req, 'read') and
                                       not eschema.has_local_role('read')):
@@ -136,7 +136,7 @@
             return u''
         return u'[<a href="%s" title="%s">+</a>]' % (
             xml_escape(self.create_url(eschema.type)),
-            self.req.__('add a %s' % eschema))
+            self._cw.__('add a %s' % eschema))
 
 
 class IndexView(ManageView):
@@ -144,5 +144,5 @@
     title = _('view_index')
 
     def display_folders(self):
-        return 'Folder' in self.schema and self.req.execute('Any COUNT(X) WHERE X is Folder')[0][0]
+        return 'Folder' in self._cw.schema and self._cw.execute('Any COUNT(X) WHERE X is Folder')[0][0]
 
--- a/web/views/tableview.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/tableview.py	Wed Sep 23 19:40:19 2009 +0200
@@ -28,14 +28,14 @@
 
     def form_filter(self, divid, displaycols, displayactions, displayfilter,
                     hidden=True):
-        rqlst = self.rset.syntax_tree()
+        rqlst = self.cw_rset.syntax_tree()
         # union not yet supported
         if len(rqlst.children) != 1:
             return ()
         rqlst.save_state()
-        mainvar, baserql = prepare_facets_rqlst(rqlst, self.rset.args)
-        wdgs = [facet.get_widget() for facet in self.vreg['facets'].poss_visible_objects(
-            self.req, rset=self.rset, context='tablefilter',
+        mainvar, baserql = prepare_facets_rqlst(rqlst, self.cw_rset.args)
+        wdgs = [facet.get_widget() for facet in self._cw.vreg['facets'].poss_visible_objects(
+            self._cw, rset=self.cw_rset, context='tablefilter',
             filtered_variable=mainvar)]
         wdgs = [wdg for wdg in wdgs if wdg is not None]
         rqlst.recover()
@@ -51,8 +51,8 @@
         """display a form to filter table's content. This should only
         occurs when a context eid is given
         """
-        self.req.add_css('cubicweb.facets.css')
-        self.req.add_js( ('cubicweb.ajax.js', 'cubicweb.facets.js'))
+        self._cw.add_css('cubicweb.facets.css')
+        self._cw.add_js( ('cubicweb.ajax.js', 'cubicweb.facets.js'))
         # drop False / None values from vidargs
         vidargs = dict((k, v) for k, v in vidargs.iteritems() if v)
         self.w(u'<form method="post" cubicweb:facetargs="%s" action="">' %
@@ -77,8 +77,8 @@
         """returns the index of the first non-attribute variable among the RQL
         selected variables
         """
-        eschema = self.vreg.schema.eschema
-        for i, etype in enumerate(self.rset.description[0]):
+        eschema = self._cw.vreg.schema.eschema
+        for i, etype in enumerate(self.cw_rset.description[0]):
             try:
                 if not eschema(etype).is_final():
                     return i
@@ -88,10 +88,10 @@
 
     def displaycols(self, displaycols):
         if displaycols is None:
-            if 'displaycols' in self.req.form:
-                displaycols = [int(idx) for idx in self.req.form['displaycols']]
+            if 'displaycols' in self._cw.form:
+                displaycols = [int(idx) for idx in self._cw.form['displaycols']]
             else:
-                displaycols = range(len(self.rset.syntax_tree().children[0].selection))
+                displaycols = range(len(self.cw_rset.syntax_tree().children[0].selection))
         return displaycols
 
     def call(self, title=None, subvid=None, displayfilter=None, headers=None,
@@ -104,7 +104,7 @@
         :param displayfilter: filter that selects rows to display
         :param headers: columns' titles
         """
-        req = self.req
+        req = self._cw
         req.add_js('jquery.tablesorter.js')
         req.add_css(('cubicweb.tablesorter.css', 'cubicweb.tableview.css'))
         # compute label first  since the filter form may remove some necessary
@@ -115,7 +115,7 @@
         hidden = True
         if not subvid and 'subvid' in req.form:
             subvid = req.form.pop('subvid')
-        divid = divid or req.form.get('divid') or 'rs%s' % make_uid(id(self.rset))
+        divid = divid or req.form.get('divid') or 'rs%s' % make_uid(id(self.cw_rset))
         actions = list(actions)
         if mainindex is None:
             displayfilter, displayactions = False, False
@@ -144,7 +144,7 @@
             actions += self.show_hide_actions(divid, True)
         self.w(u'<div id="%s"' % divid)
         if displayactions:
-            actionsbycat = self.vreg['actions'].possible_actions(req, self.rset)
+            actionsbycat = self._cw.vreg['actions'].possible_actions(req, self.cw_rset)
             for action in actionsbycat.get('mainactions', ()):
                 for action in action.actual_actions():
                     actions.append( (action.url(), req._(action.title),
@@ -170,8 +170,8 @@
         showhide = u';'.join(toggle_action('%s%s' % (divid, what))[11:]
                              for what in ('Form', 'Show', 'Hide', 'Actions'))
         showhide = 'javascript:' + showhide
-        showlabel = self.req._('show filter form')
-        hidelabel = self.req._('hide filter form')
+        showlabel = self._cw._('show filter form')
+        hidelabel = self._cw._('hide filter form')
         if currentlydisplayed:
             return [(showhide, showlabel, 'hidden', '%sShow' % divid),
                     (showhide, hidelabel, None, '%sHide' % divid)]
@@ -181,8 +181,8 @@
     def render_actions(self, divid, actions):
         box = MenuWidget('', 'tableActionsBox', _class='', islist=False)
         label = '<img src="%s" alt="%s"/>' % (
-            self.req.datadir_url + 'liveclipboard-icon.png',
-            xml_escape(self.req._('action(s) on this selection')))
+            self._cw.datadir_url + 'liveclipboard-icon.png',
+            xml_escape(self._cw._('action(s) on this selection')))
         menu = PopupBoxMenu(label, isitem=False, link_class='actionsBox',
                             ident='%sActions' % divid)
         box.append(menu)
@@ -201,14 +201,14 @@
             if headers is not None:
                 label = headers[displaycols.index(colindex)]
             if colindex == mainindex:
-                label += ' (%s)' % self.rset.rowcount
+                label += ' (%s)' % self.cw_rset.rowcount
             column = TableColumn(label, colindex)
-            coltype = self.rset.description[0][colindex]
+            coltype = self.cw_rset.description[0][colindex]
             # compute column cell view (if coltype is None, it's a left outer
             # join, use the default non final subvid)
             if cellvids and colindex in cellvids:
                 column.append_renderer(cellvids[colindex], colindex)
-            elif coltype is not None and self.schema.eschema(coltype).is_final():
+            elif coltype is not None and self._cw.schema.eschema(coltype).is_final():
                 column.append_renderer(self.finalview, colindex)
             else:
                 column.append_renderer(subvid or 'incontext', colindex)
@@ -221,10 +221,10 @@
 
 
     def render_cell(self, cellvid, row, col, w):
-        self.view('cell', self.rset, row=row, col=col, cellvid=cellvid, w=w)
+        self._cw.view('cell', self.cw_rset, row=row, col=col, cellvid=cellvid, w=w)
 
     def get_rows(self):
-        return self.rset
+        return self.cw_rset
 
     @htmlescape
     @jsonize
@@ -233,16 +233,16 @@
         # XXX it might be interesting to try to limit value's
         #     length as much as possible (e.g. by returning the 10
         #     first characters of a string)
-        val = self.rset[row][col]
+        val = self.cw_rset[row][col]
         if val is None:
             return u''
-        etype = self.rset.description[row][col]
-        if self.schema.eschema(etype).is_final():
-            entity, rtype = self.rset.related_entity(row, col)
+        etype = self.cw_rset.description[row][col]
+        if self._cw.schema.eschema(etype).is_final():
+            entity, rtype = self.cw_rset.related_entity(row, col)
             if entity is None:
                 return val # remove_html_tags() ?
             return entity.sortvalue(rtype)
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         return entity.sortvalue()
 
 
@@ -261,17 +261,17 @@
         :param row, col: indexes locating the cell value in view's result set
         :param cellvid: cell view (defaults to 'outofcontext')
         """
-        etype, val = self.rset.description[row][col], self.rset[row][col]
-        if val is not None and not self.schema.eschema(etype).is_final():
-            e = self.rset.get_entity(row, col)
+        etype, val = self.cw_rset.description[row][col], self.cw_rset[row][col]
+        if val is not None and not self._cw.schema.eschema(etype).is_final():
+            e = self.cw_rset.get_entity(row, col)
             e.view(cellvid or 'outofcontext', w=self.w)
         elif val is None:
             # This is usually caused by a left outer join and in that case,
             # regular views will most certainly fail if they don't have
             # a real eid
-            self.wview('final', self.rset, row=row, col=col)
+            self.wview('final', self.cw_rset, row=row, col=col)
         else:
-            self.wview(cellvid or 'final', self.rset, 'null', row=row, col=col)
+            self.wview(cellvid or 'final', self.cw_rset, 'null', row=row, col=col)
 
 
 class InitialTableView(TableView):
@@ -295,17 +295,17 @@
     def call(self, title=None, subvid=None, headers=None, divid=None,
              displaycols=None, displayactions=None, mainindex=None):
         """Dumps a table displaying a composite query"""
-        actrql = self.req.form['actualrql']
-        self.req.ensure_ro_rql(actrql)
+        actrql = self._cw.form['actualrql']
+        self._cw.ensure_ro_rql(actrql)
         displaycols = self.displaycols(displaycols)
-        if displayactions is None and 'displayactions' in self.req.form:
+        if displayactions is None and 'displayactions' in self._cw.form:
             displayactions = True
-        if divid is None and 'divid' in self.req.form:
-            divid = self.req.form['divid']
+        if divid is None and 'divid' in self._cw.form:
+            divid = self._cw.form['divid']
         self.w(u'<div class="section">')
-        if not title and 'title' in self.req.form:
+        if not title and 'title' in self._cw.form:
             # pop title so it's not displayed by the table view as well
-            title = self.req.form.pop('title')
+            title = self._cw.form.pop('title')
         if title:
             self.w(u'<h2>%s</h2>\n' % title)
         if mainindex is None:
@@ -314,12 +314,12 @@
             actions = self.form_filter(divid, displaycols, displayactions, True)
         else:
             actions = ()
-        if not subvid and 'subvid' in self.req.form:
-            subvid = self.req.form.pop('subvid')
-        self.view('table', self.req.execute(actrql),
-                  'noresult', w=self.w, displayfilter=False, subvid=subvid,
-                  displayactions=displayactions, displaycols=displaycols,
-                  actions=actions, headers=headers, divid=divid)
+        if not subvid and 'subvid' in self._cw.form:
+            subvid = self._cw.form.pop('subvid')
+        self._cw.view('table', self._cw.execute(actrql),
+                      'noresult', w=self.w, displayfilter=False, subvid=subvid,
+                      displayactions=displayactions, displaycols=displaycols,
+                      actions=actions, headers=headers, divid=divid)
         self.w(u'</div>\n')
 
 
--- a/web/views/tabs.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/tabs.py	Wed Sep 23 19:40:19 2009 +0200
@@ -24,7 +24,7 @@
     """
 
     def _prepare_bindings(self, vid, reloadable):
-        self.req.add_onload(u"""
+        self._cw.add_onload(u"""
   jQuery('#lazy-%(vid)s').bind('%(event)s', function(event) {
      load_now('#lazy-%(vid)s', '#%(vid)s-hole', %(reloadable)s);
   });""" % {'event': 'load_%s' % vid, 'vid': vid,
@@ -38,7 +38,7 @@
         assert rql or eid or rset or static, \
             'lazyview wants at least : rql, or an eid, or an rset -- or call it with static=True'
         w = w or self.w
-        self.req.add_js('cubicweb.lazy.js')
+        self._cw.add_js('cubicweb.lazy.js')
         urlparams = {'vid' : vid, 'fname' : 'view'}
         if rql:
             urlparams['rql'] = rql
@@ -50,7 +50,7 @@
             vid, xml_escape(self.build_url('json', **urlparams))))
         if show_spinbox:
             w(u'<img src="data/loading.gif" id="%s-hole" alt="%s"/>'
-              % (vid, self.req._('loading')))
+              % (vid, self._cw._('loading')))
         w(u'</div>')
         self._prepare_bindings(vid, reloadable)
 
@@ -58,8 +58,8 @@
         """trigger an event that will force immediate loading of the view
         on dom readyness
         """
-        self.req.add_js('cubicweb.lazy.js')
-        self.req.add_onload("trigger_load('%s');" % vid)
+        self._cw.add_js('cubicweb.lazy.js')
+        self._cw.add_onload("trigger_load('%s');" % vid)
 
 
 class TabsMixin(LazyViewMixin):
@@ -68,18 +68,18 @@
 
     @property
     def cookie_name(self):
-        return str('%s_active_tab' % self.config.appid)
+        return str('%s_active_tab' % self._cw.config.appid)
 
     def active_tab(self, tabs, default):
-        formtab = self.req.form.get('tab')
+        formtab = self._cw.form.get('tab')
         if formtab in tabs:
             return formtab
-        cookies = self.req.get_cookie()
+        cookies = self._cw.get_cookie()
         cookiename = self.cookie_name
         activetab = cookies.get(cookiename)
         if activetab is None:
             cookies[cookiename] = default
-            self.req.set_cookie(cookies, cookiename)
+            self._cw.set_cookie(cookies, cookiename)
             tab = default
         else:
             tab = activetab.value
@@ -89,7 +89,7 @@
         selected_tabs = []
         for tab in tabs:
             try:
-                self.vreg['views'].select(tab, self.req, rset=self.rset)
+                self._cw.vreg['views'].select(tab, self._cw, rset=self.cw_rset)
                 selected_tabs.append(tab)
             except NoSelectableObject:
                 continue
@@ -98,11 +98,11 @@
     def render_tabs(self, tabs, default, entity=None):
         # delegate to the default tab if there is more than one entity
         # in the result set (tabs are pretty useless there)
-        if entity and len(self.rset) > 1:
+        if entity and len(self.cw_rset) > 1:
             entity.view(default, w=self.w)
             return
-        self.req.add_css('ui.tabs.css')
-        self.req.add_js(('ui.core.js', 'ui.tabs.js',
+        self._cw.add_css('ui.tabs.css')
+        self._cw.add_js(('ui.core.js', 'ui.tabs.js',
                          'cubicweb.ajax.js', 'cubicweb.tabs.js', 'cubicweb.lazy.js'))
         # prune tabs : not all are to be shown
         tabs = self.prune_tabs(tabs)
@@ -117,7 +117,7 @@
             w(u'<li>')
             w(u'<a href="#%s">' % tab)
             w(u'<span onclick="set_tab(\'%s\', \'%s\')">' % (tab, self.cookie_name))
-            w(self.req._(tab))
+            w(self._cw._(tab))
             w(u'</span>')
             w(u'</a>')
             w(u'</li>')
@@ -133,7 +133,7 @@
         # call the set_tab() JS function *after* each tab is generated
         # because the callback binding needs to be done before
         # XXX make work history: true
-        self.req.add_onload(u"""
+        self._cw.add_onload(u"""
   jQuery('#entity-tabs-%(eeid)s > ul').tabs( { selected: %(tabindex)s });
   set_tab('%(vid)s', '%(cookiename)s');
 """ % {'tabindex'   : tabs.index(active_tab),
@@ -164,9 +164,9 @@
     vid = 'list'
 
     def cell_call(self, row, col):
-        rset = self.rset.get_entity(row, col).related(self.rtype, role(self))
+        rset = self.cw_rset.get_entity(row, col).related(self.rtype, role(self))
         self.w(u'<div class="mainInfo">')
         if self.title:
-            self.w(tags.h1(self.req._(self.title)))
+            self.w(tags.h1(self._cw._(self.title)))
         self.wview(self.vid, rset, 'noresult')
         self.w(u'</div>')
--- a/web/views/timeline.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/timeline.py	Wed Sep 23 19:40:19 2009 +0200
@@ -34,7 +34,7 @@
 
     def call(self):
         events = []
-        for entity in self.rset.entities():
+        for entity in self.cw_rset.entities():
             event = self.build_event(entity)
             if event is not None:
                 events.append(event)
@@ -86,9 +86,9 @@
                'cubicweb.timeline-ext.js', 'cubicweb.ajax.js')
 
     def render_url(self, loadurl, tlunit=None):
-        tlunit = tlunit or self.req.form.get('tlunit')
-        self.req.add_js(self.jsfiles)
-        self.req.add_css('timeline-bundle.css')
+        tlunit = tlunit or self._cw.form.get('tlunit')
+        self._cw.add_js(self.jsfiles)
+        self._cw.add_css('timeline-bundle.css')
         if tlunit:
             additional = u' cubicweb:tlunit="%s"' % tlunit
         else:
@@ -107,8 +107,8 @@
     __select__ = implements(ICalendarable)
     need_navigation = False
     def call(self, tlunit=None):
-        self.req.html_headers.define_var('Timeline_urlPrefix', self.req.datadir_url)
-        rql = self.rset.printable_rql()
+        self._cw.html_headers.define_var('Timeline_urlPrefix', self._cw.datadir_url)
+        rql = self.cw_rset.printable_rql()
         loadurl = self.build_url(rql=rql, vid='timeline-json')
         self.render_url(loadurl, tlunit)
 
--- a/web/views/timetable.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/timetable.py	Wed Sep 23 19:40:19 2009 +0200
@@ -32,16 +32,16 @@
     def call(self, title=None):
         """Dumps a timetable from a resultset composed of a note (anything
         with start/stop) and a user (anything)"""
-        self.req.add_css('cubicweb.timetable.css')
+        self._cw.add_css('cubicweb.timetable.css')
         dates = {}
         users = []
         users_max = {}
 
         # XXX: try refactoring with calendar.py:OneMonthCal
-        for row in xrange(self.rset.rowcount):
-            task = self.rset.get_entity(row, 0)
-            if len(self.rset[row])>1:
-                user = self.rset.get_entity(row, 1)
+        for row in xrange(self.cw_rset.rowcount):
+            task = self.cw_rset.get_entity(row, 0)
+            if len(self.cw_rset[row])>1:
+                user = self.cw_rset.get_entity(row, 1)
             else:
                 user = u"*"
             the_dates = []
--- a/web/views/treeview.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/treeview.py	Wed Sep 23 19:40:19 2009 +0200
@@ -27,14 +27,14 @@
     title = _('tree view')
 
     def _init_params(self, subvid, treeid, initial_load, initial_thru_ajax, morekwargs):
-        form = self.req.form
+        form = self._cw.form
         if subvid is None:
             subvid = form.pop('treesubvid', self.subvid) # consume it
         if treeid is None:
             treeid = form.pop('treeid', None)
             if treeid is None:
                 treeid = 'throw_away' + make_uid('uid')
-        if 'morekwargs' in self.req.form:
+        if 'morekwargs' in self._cw.form:
             ajaxargs = json.loads(form.pop('morekwargs'))
             # got unicode & python keywords must be strings
             morekwargs.update(dict((str(k), v)
@@ -44,9 +44,9 @@
         return subvid, treeid, toplevel_thru_ajax, toplevel
 
     def _init_headers(self, treeid, toplevel_thru_ajax):
-        self.req.add_css('jquery.treeview.css')
-        self.req.add_js(('cubicweb.ajax.js', 'cubicweb.widgets.js', 'jquery.treeview.js'))
-        self.req.html_headers.add_onload(u"""
+        self._cw.add_css('jquery.treeview.css')
+        self._cw.add_js(('cubicweb.ajax.js', 'cubicweb.widgets.js', 'jquery.treeview.js'))
+        self._cw.html_headers.add_onload(u"""
 jQuery("#tree-%s").treeview({toggle: toggleTree, prerendered: true});""" % treeid,
                                          jsoncall=toplevel_thru_ajax)
 
@@ -59,9 +59,9 @@
             self._init_headers(treeid, toplevel_thru_ajax)
             ulid = ' id="tree-%s"' % treeid
         self.w(u'<ul%s class="%s">' % (ulid, self.css_classes))
-        for rowidx in xrange(len(self.rset)):
-            self.wview(self.itemvid, self.rset, row=rowidx, col=0,
-                       vid=subvid, parentvid=self.id, treeid=treeid, **morekwargs)
+        for rowidx in xrange(len(self.cw_rset)):
+            self.wview(self.itemvid, self.cw_rset, row=rowidx, col=0,
+                       vid=subvid, parentvid=self.__regid__, treeid=treeid, **morekwargs)
         self.w(u'</ul>')
 
     def cell_call(self, *args, **allargs):
@@ -91,7 +91,7 @@
     __regid__ = 'filetree-oneline'
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         if ITree.is_implemented_by(entity.__class__) and not entity.is_leaf():
             self.w(u'<div class="folder">%s</div>\n' % entity.view('oneline'))
         else:
@@ -105,9 +105,9 @@
 
     def cell_call(self, row, col, vid='oneline', parentvid='treeview', treeid=None):
         assert treeid is not None
-        entity = self.rset.get_entity(row, col)
-        itemview = self.view(vid, self.rset, row=row, col=col)
-        if row == len(self.rset) - 1:
+        entity = self.cw_rset.get_entity(row, col)
+        itemview = self._cw.view(vid, self.cw_rset, row=row, col=col)
+        if row == len(self.cw_rset) - 1:
             self.w(u'<li class="last">%s</li>' % itemview)
         else:
             self.w(u'<li>%s</li>' % itemview)
@@ -123,7 +123,7 @@
     default_branch_state_is_open = False
 
     def open_state(self, eeid, treeid):
-        cookies = self.req.get_cookie()
+        cookies = self._cw.get_cookie()
         treestate = cookies.get(treecookiename(treeid))
         if treestate:
             return str(eeid) in treestate.value.split(';')
@@ -131,9 +131,9 @@
 
     def cell_call(self, row, col, treeid, vid='oneline', parentvid='treeview', **morekwargs):
         w = self.w
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         liclasses = []
-        is_last = row == len(self.rset) - 1
+        is_last = row == len(self.cw_rset) - 1
         is_open = self.open_state(entity.eid, treeid)
         is_leaf = not hasattr(entity, 'is_leaf') or entity.is_leaf()
         if is_leaf:
@@ -143,7 +143,7 @@
         else:
             rql = entity.children_rql() % {'x': entity.eid}
             url = xml_escape(self.build_url('json', rql=rql, vid=parentvid,
-                                            pageid=self.req.pageid,
+                                            pageid=self._cw.pageid,
                                             treeid=treeid,
                                             fname='view',
                                             treesubvid=vid,
@@ -178,8 +178,8 @@
             if not is_open:
                 w(u'<ul class="placeholder"><li>place holder</li></ul>')
         # the local node info
-        self.wview(vid, self.rset, row=row, col=col, **morekwargs)
+        self.wview(vid, self.cw_rset, row=row, col=col, **morekwargs)
         if is_open and not is_leaf: #  => rql is defined
-            self.wview(parentvid, self.req.execute(rql), treeid=treeid, initial_load=False, **morekwargs)
+            self.wview(parentvid, self._cw.execute(rql), treeid=treeid, initial_load=False, **morekwargs)
         w(u'</li>')
 
--- a/web/views/urlrewrite.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/urlrewrite.py	Wed Sep 23 19:40:19 2009 +0200
@@ -198,9 +198,9 @@
                 continue
             if isinstance(inputurl, basestring):
                 if inputurl == uri:
-                    return callback(inputurl, uri, req, self.schema)
+                    return callback(inputurl, uri, req, self._cw.schema)
             elif inputurl.match(uri): # it's a regexp
-                return callback(inputurl, uri, req, self.schema)
+                return callback(inputurl, uri, req, self._cw.schema)
         else:
             self.debug("no schemabased rewrite rule found for %s", uri)
             raise KeyError(uri)
--- a/web/views/vcard.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/vcard.py	Wed Sep 23 19:40:19 2009 +0200
@@ -24,7 +24,7 @@
 
     def set_request_content_type(self):
         """overriden to set a .vcf filename"""
-        self.req.set_content_type(self.content_type, filename='vcard.vcf')
+        self._cw.set_content_type(self.content_type, filename='vcard.vcf')
 
     def cell_call(self, row, col):
         self.vcard_header()
--- a/web/views/wdoc.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/wdoc.py	Wed Sep 23 19:40:19 2009 +0200
@@ -91,16 +91,16 @@
     title = _('site documentation')
 
     def call(self):
-        fid = self.req.form['fid']
-        for lang in chain((self.req.lang, self.vreg.property_value('ui.language')),
-                          self.config.available_languages()):
+        fid = self._cw.form['fid']
+        for lang in chain((self._cw.lang, self._cw.vreg.property_value('ui.language')),
+                          self._cw.config.available_languages()):
             rid = '%s_%s.rst' % (fid, lang)
-            resourcedir = self.config.locate_doc_file(rid)
+            resourcedir = self._cw.config.locate_doc_file(rid)
             if resourcedir:
                 break
         else:
             raise NotFound
-        self.tocindex = build_toc(self.config)
+        self.tocindex = build_toc(self._cw.config)
         try:
             node = self.tocindex[fid]
         except KeyError:
@@ -108,7 +108,7 @@
         else:
             self.navigation_links(node)
             self.w(u'<div class="hr"></div>')
-            self.w(u'<h1>%s</h1>' % (title_for_lang(node, self.req.lang)))
+            self.w(u'<h1>%s</h1>' % (title_for_lang(node, self._cw.lang)))
         data = open(join(resourcedir, rid)).read()
         self.w(rest_publish(self, data))
         if node is not None:
@@ -117,7 +117,7 @@
             self.navigation_links(node)
 
     def navigation_links(self, node):
-        req = self.req
+        req = self._cw
         parent = node.parent
         if parent is None:
             return
@@ -139,10 +139,10 @@
     def navsection(self, node, navtype):
         htmlclass, imgpath, msgid = self.navinfo[navtype]
         self.w(u'<span class="%s">' % htmlclass)
-        self.w(u'%s : ' % self.req._(msgid))
+        self.w(u'%s : ' % self._cw._(msgid))
         self.w(u'<a href="%s">%s</a>' % (
-            self.req.build_url('doc/'+node.attrib['resource']),
-            title_for_lang(node, self.req.lang)))
+            self._cw.build_url('doc/'+node.attrib['resource']),
+            title_for_lang(node, self._cw.lang)))
         self.w(u'</span>\n')
 
     def subsections_links(self, node, first=True):
@@ -154,8 +154,8 @@
         self.w(u'<ul class="docsum">')
         for child in sub:
             self.w(u'<li><a href="%s">%s</a>' % (
-                self.req.build_url('doc/'+child.attrib['resource']),
-                title_for_lang(child, self.req.lang)))
+                self._cw.build_url('doc/'+child.attrib['resource']),
+                title_for_lang(child, self._cw.lang)))
             self.subsections_links(child, False)
             self.w(u'</li>')
         self.w(u'</ul>\n')
@@ -170,11 +170,11 @@
     content_type = 'image/png'
 
     def call(self):
-        fid = self.req.form['fid']
-        for lang in chain((self.req.lang, self.vreg.property_value('ui.language')),
-                          self.config.available_languages()):
+        fid = self._cw.form['fid']
+        for lang in chain((self._cw.lang, self._cw.vreg.property_value('ui.language')),
+                          self._cw.config.available_languages()):
             rid = join('images', '%s_%s.png' % (fid, lang))
-            resourcedir = self.config.locate_doc_file(rid)
+            resourcedir = self._cw.config.locate_doc_file(rid)
             if resourcedir:
                 break
         else:
@@ -188,13 +188,13 @@
     maxentries = 25
 
     def call(self):
-        rid = 'ChangeLog_%s' % (self.req.lang)
+        rid = 'ChangeLog_%s' % (self._cw.lang)
         allentries = []
-        title = self.req._(self.title)
+        title = self._cw._(self.title)
         restdata = ['.. -*- coding: utf-8 -*-', '', title, '='*len(title), '']
         w = restdata.append
         today = date.today()
-        for fpath in self.config.locate_all_files(rid):
+        for fpath in self._cw.config.locate_all_files(rid):
             cl = ChangeLog(fpath)
             encoding = 'utf-8'
             # additional content may be found in title
--- a/web/views/workflow.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/workflow.py	Wed Sep 23 19:40:19 2009 +0200
@@ -56,14 +56,14 @@
                   & match_form_params('treid'))
 
     def cell_call(self, row, col):
-        entity = self.rset.get_entity(row, col)
-        transition = self.req.entity_from_eid(self.req.form['treid'])
+        entity = self.cw_rset.get_entity(row, col)
+        transition = self._cw.entity_from_eid(self._cw.form['treid'])
         dest = transition.destination()
-        _ = self.req._
+        _ = self._cw._
         # specify both rset/row/col and entity in case implements selector (and
         # not entity_implements) is used on custom form
-        form = self.vreg['forms'].select(
-            'changestate', self.req, rset=self.rset, row=row, col=col,
+        form = self._cw.vreg['forms'].select(
+            'changestate', self._cw, rset=self.cw_rset, row=row, col=col,
             entity=entity, transition=transition,
             redirect_path=self.redirectpath(entity))
         self.w(form.error_message())
@@ -73,10 +73,9 @@
             'st1': _(entity.current_state.name),
             'st2': _(dest.name)}
         self.w(u'<p>%s</p>\n' % msg)
-        trinfo = self.vreg['etypes'].etype_class('TrInfo')(self.req)
-        self.initialize_varmaker()
-        trinfo.eid = self.varmaker.next()
-        subform = self.vreg['forms'].select('edition', self.req, entity=trinfo,
+        trinfo = self._cw.vreg['etypes'].etype_class('TrInfo')(self._cw)
+        trinfo.eid = self._cw.varmaker.next()
+        subform = self._cw.vreg['forms'].select('edition', self._cw, entity=trinfo,
                                             mainform=False)
         subform.field_by_name('by_transition').widget = fwdgs.HiddenInput()
         form.form_add_subform(subform)
@@ -93,13 +92,13 @@
     title = _('Workflow history')
 
     def cell_call(self, row, col, view=None):
-        _ = self.req._
-        eid = self.rset[row][col]
+        _ = self._cw._
+        eid = self.cw_rset[row][col]
         sel = 'Any FS,TS,WF,D'
         rql = ' ORDERBY D DESC WHERE WF wf_info_for X,'\
               'WF from_state FS, WF to_state TS, WF comment C,'\
               'WF creation_date D'
-        if self.vreg.schema.eschema('CWUser').has_perm(self.req, 'read'):
+        if self._cw.vreg.schema.eschema('CWUser').has_perm(self._cw, 'read'):
             sel += ',U,C'
             rql += ', WF owned_by U?'
             displaycols = range(5)
@@ -111,7 +110,7 @@
             headers = (_('from_state'), _('to_state'), _('comment'), _('date'))
         rql = '%s %s, X eid %%(x)s' % (sel, rql)
         try:
-            rset = self.req.execute(rql, {'x': eid}, 'x')
+            rset = self._cw.execute(rql, {'x': eid}, 'x')
         except Unauthorized:
             return
         if rset:
@@ -127,7 +126,7 @@
     title = _('Workflow history')
 
     def cell_call(self, row, col, view=None):
-        self.wview('wfhistory', self.rset, row=row, col=col, view=view)
+        self.wview('wfhistory', self.cw_rset, row=row, col=col, view=view)
 
 
 # workflow actions #############################################################
@@ -142,25 +141,25 @@
     order = 10
 
     def fill_menu(self, box, menu):
-        entity = self.rset.get_entity(self.row or 0, self.col or 0)
-        menu.label = u'%s: %s' % (self.req._('state'), entity.printable_state)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
+        menu.label = u'%s: %s' % (self._cw._('state'), entity.printable_state)
         menu.append_anyway = True
         super(WorkflowActions, self).fill_menu(box, menu)
 
     def actual_actions(self):
-        entity = self.rset.get_entity(self.row or 0, self.col or 0)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         hastr = False
         for tr in entity.possible_transitions():
             url = entity.absolute_url(vid='statuschange', treid=tr.eid)
-            yield self.build_action(self.req._(tr.name), url)
+            yield self.build_action(self._cw._(tr.name), url)
             hastr = True
         # don't propose to see wf if user can't pass any transition
         if hastr:
             wfurl = entity.current_workflow.absolute_url()
-            yield self.build_action(self.req._('view workflow'), wfurl)
+            yield self.build_action(self._cw._('view workflow'), wfurl)
         if entity.workflow_history:
             wfurl = entity.absolute_url(vid='wfhistory')
-            yield self.build_action(self.req._('view history'), wfurl)
+            yield self.build_action(self._cw._('view history'), wfurl)
 
 
 # workflow entity types views ##################################################
@@ -170,7 +169,7 @@
     __select__ = implements('TrInfo')
 
     def cell_call(self, row, col, cellvid=None):
-        self.w(self.rset.get_entity(row, col).view('reledit', rtype='comment'))
+        self.w(self.cw_rset.get_entity(row, col).view('reledit', rtype='comment'))
 
 
 class StateInContextView(view.EntityView):
@@ -179,7 +178,7 @@
     __select__ = implements('State')
 
     def cell_call(self, row, col):
-        self.w(xml_escape(self.view('textincontext', self.rset,
+        self.w(xml_escape(self.view('textincontext', self.cw_rset,
                                      row=row, col=col)))
 
 
@@ -190,7 +189,7 @@
         self.w(entity.view('reledit', rtype='description'))
         self.w(u'<img src="%s" alt="%s"/>' % (
             xml_escape(entity.absolute_url(vid='wfgraph')),
-            xml_escape(self.req._('graphical workflow for %s') % entity.name)))
+            xml_escape(self._cw._('graphical workflow for %s') % entity.name)))
 
 
 # workflow images ##############################################################
@@ -256,9 +255,9 @@
 
     def _generate(self, tmpfile):
         """display schema information for an entity"""
-        entity = self.rset.get_entity(self.row, self.col)
+        entity = self.cw_rset.get_entity(self.cw_row, self.cw_col)
         visitor = WorkflowVisitor(entity)
-        prophdlr = WorkflowDotPropsHandler(self.req)
+        prophdlr = WorkflowDotPropsHandler(self._cw)
         generator = GraphGenerator(DotBackend('workflow', 'LR',
                                               ratio='compress', size='30,12'))
         return generator.generate(visitor, prophdlr, tmpfile)
--- a/web/views/xbel.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/xbel.py	Wed Sep 23 19:40:19 2009 +0200
@@ -22,17 +22,17 @@
     content_type = 'text/xml' #application/xbel+xml
 
     def cell_call(self, row, col):
-        self.wview('xbelitem', self.rset, row=row, col=col)
+        self.wview('xbelitem', self.cw_rset, row=row, col=col)
 
     def call(self):
         """display a list of entities by calling their <item_vid> view"""
         title = self.page_title()
-        url = self.build_url(rql=self.req.form.get('rql', ''))
-        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
+        url = self._cw.build_url(rql=self._cw.form.get('rql', ''))
+        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
         self.w(u'<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd">')
         self.w(u'<xbel version="1.0">')
-        self.w(u'<title>%s</title>' % self.req._('bookmarks'))
-        for i in xrange(self.rset.rowcount):
+        self.w(u'<title>%s</title>' % self._cw._('bookmarks'))
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self.w(u"</xbel>")
 
@@ -41,7 +41,7 @@
     __regid__ = 'xbelitem'
 
     def cell_call(self, row, col):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         self.w(u'<bookmark href="%s">' % xml_escape(self.url(entity)))
         self.w(u'  <title>%s</title>' % xml_escape(entity.dc_title()))
         self.w(u'</bookmark>')
--- a/web/views/xmlrss.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/xmlrss.py	Wed Sep 23 19:40:19 2009 +0200
@@ -30,13 +30,13 @@
     item_vid = 'xmlitem'
 
     def cell_call(self, row, col):
-        self.wview(self.item_vid, self.rset, row=row, col=col)
+        self.wview(self.item_vid, self.cw_rset, row=row, col=col)
 
     def call(self):
         """display a list of entities by calling their <item_vid> view"""
-        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
-        self.w(u'<%s size="%s">\n' % (self.xml_root, len(self.rset)))
-        for i in xrange(self.rset.rowcount):
+        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
+        self.w(u'<%s size="%s">\n' % (self.xml_root, len(self.cw_rset)))
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self.w(u'</%s>\n' % self.xml_root)
 
@@ -46,7 +46,7 @@
 
     def cell_call(self, row, col):
         """ element as an item for an xml feed """
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         self.w(u'<%s>\n' % (entity.e_schema))
         for rschema, attrschema in entity.e_schema.attribute_definitions():
             attr = rschema.type
@@ -75,12 +75,12 @@
 
     def call(self):
         w = self.w
-        rset, descr = self.rset, self.rset.description
-        eschema = self.schema.eschema
+        rset, descr = self.cw_rset, self.cw_rset.description
+        eschema = self._cw.schema.eschema
         labels = self.columns_labels(tr=False)
-        w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
+        w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
         w(u'<%s query="%s">\n' % (self.xml_root, xml_escape(rset.printable_rql())))
-        for rowindex, row in enumerate(self.rset):
+        for rowindex, row in enumerate(self.cw_rset):
             w(u' <row>\n')
             for colindex, val in enumerate(row):
                 etype = descr[rowindex][colindex]
@@ -92,11 +92,11 @@
                 if val is not None and not eschema(etype).is_final():
                     attrs['eid'] = val
                     # csvrow.append(val) # val is eid in that case
-                    val = self.view('textincontext', rset,
-                                    row=rowindex, col=colindex)
+                    val = self._cw.view('textincontext', rset,
+                                        row=rowindex, col=colindex)
                 else:
-                    val = self.view('final', rset, row=rowindex,
-                                    col=colindex, format='text/plain')
+                    val = self._cw.view('final', rset, row=rowindex,
+                                        col=colindex, format='text/plain')
                 w(simple_sgml_tag(tag, val, **attrs))
             w(u' </row>\n')
         w(u'</%s>\n' % self.xml_root)
@@ -109,7 +109,7 @@
     __select__ = non_final_entity()
 
     def feed_url(self):
-        return self.build_url(rql=self.limited_rql(), vid='rss')
+        return self._cw.build_url(rql=self.limited_rql(), vid='rss')
 
 
 class RSSEntityFeedURL(Component):
@@ -117,7 +117,7 @@
     __select__ = non_final_entity() & one_line_rset()
 
     def feed_url(self):
-        return self.rset.get_entity(0, 0).rss_feed_url()
+        return self.cw_rset.get_entity(0, 0).rss_feed_url()
 
 
 class RSSIconBox(box.BoxTemplate):
@@ -131,12 +131,12 @@
 
     def call(self, **kwargs):
         try:
-            rss = self.req.external_resource('RSS_LOGO')
+            rss = self._cw.external_resource('RSS_LOGO')
         except KeyError:
             self.error('missing RSS_LOGO external resource')
             return
-        urlgetter = self.vreg['components'].select('rss_feed_url', self.req,
-                                                   rset=self.rset)
+        urlgetter = self._cw.vreg['components'].select('rss_feed_url', self._cw,
+                                                   rset=self.cw_rset)
         url = urlgetter.feed_url()
         self.w(u'<a href="%s"><img src="%s" alt="rss"/></a>\n' % (xml_escape(url), rss))
 
@@ -150,7 +150,7 @@
     cache_max_age = 60*60*2 # stay in http cache for 2 hours by default
 
     def _open(self):
-        req = self.req
+        req = self._cw
         self.w(u'<?xml version="1.0" encoding="%s"?>\n' % req.encoding)
         self.w(u'<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">\n')
         self.w(u'  <channel>\n')
@@ -160,7 +160,7 @@
                % xml_escape(req.form.get('vtitle', '')))
         params = req.form.copy()
         params.pop('vid', None)
-        self.w(u'    <link>%s</link>\n' % xml_escape(self.build_url(**params)))
+        self.w(u'    <link>%s</link>\n' % xml_escape(self._cw.build_url(**params)))
 
     def _close(self):
         self.w(u'  </channel>\n')
@@ -169,12 +169,12 @@
     def call(self):
         """display a list of entities by calling their <item_vid> view"""
         self._open()
-        for i in xrange(self.rset.rowcount):
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self._close()
 
     def cell_call(self, row, col):
-        self.wview('rssitem', self.rset, row=row, col=col)
+        self.wview('rssitem', self.cw_rset, row=row, col=col)
 
 
 class RSSItemView(EntityView):
@@ -183,7 +183,7 @@
     add_div_section = False
 
     def cell_call(self, row, col):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         self.w(u'<item>\n')
         self.w(u'<guid isPermaLink="true">%s</guid>\n'
                % xml_escape(entity.absolute_url()))