[api] use _cw, cw_row, cw_col, cw_rset etc.
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 23 Sep 2009 12:28:28 +0200
changeset 3418 7b49fa7e942d
parent 3412 368c68ffb99e
child 3419 32cfd0844243
[api] use _cw, cw_row, cw_col, cw_rset etc.
appobject.py
common/mail.py
common/mttransforms.py
common/uilib.py
devtools/testlib.py
entities/__init__.py
entities/lib.py
entity.py
ext/rest.py
hooks/notification.py
server/hook.py
sobjects/notification.py
test/unittest_rset.py
test/unittest_selectors.py
web/views/autoform.py
web/views/baseviews.py
--- a/appobject.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/appobject.py	Wed Sep 23 12:28:28 2009 +0200
@@ -305,7 +305,7 @@
 
         <cls.__registry__>.<cls.id>.<propid>
         """
-        return self.req.property_value(self._cwpropkey(propid))
+        return self._cw.property_value(self._cwpropkey(propid))
 
     # deprecated ###############################################################
 
--- a/common/mail.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/common/mail.py	Wed Sep 23 12:28:28 2009 +0200
@@ -155,7 +155,7 @@
                 self.send_now(recipients, msg)
 
     def cell_call(self, row, col=0, **kwargs):
-        self.w(self.req._(self.content) % self.context(**kwargs))
+        self.w(self._cw._(self.content) % self.context(**kwargs))
 
     def render_emails(self, **kwargs):
         """generate and send emails for this view (one per recipient)"""
@@ -164,8 +164,8 @@
         if not recipients:
             self.info('skipping %s notification, no recipients', self.id)
             return
-        if self.rset is not None:
-            entity = self.entity(self.row or 0, self.col or 0)
+        if self.cw_rset is not None:
+            entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
             # if the view is using timestamp in message ids, no way to reference
             # previous email
             if not self.msgid_timestamp:
@@ -177,17 +177,17 @@
         else:
             refs = ()
             msgid = None
-        req = self.req
+        req = self._cw
         self.user_data = req.user_data()
         origlang = req.lang
         for something in recipients:
             if isinstance(something, Entity):
-                # hi-jack self.req to get a session for the returned user
-                self.req = self.req.hijack_user(something)
+                # hi-jack self._cw to get a session for the returned user
+                self._cw = self._cw.hijack_user(something)
                 emailaddr = something.get_email()
             else:
                 emailaddr, lang = something
-                self.req.set_language(lang)
+                self._cw.set_language(lang)
             # since the same view (eg self) may be called multiple time and we
             # need a fresh stream at each iteration, reset it explicitly
             self.w = None
@@ -199,7 +199,7 @@
             except SkipEmail:
                 continue
             msg = format_mail(self.user_data, [emailaddr], content, subject,
-                              config=self.config, msgid=msgid, references=refs)
+                              config=self._cw.vreg.config, msgid=msgid, references=refs)
             yield [emailaddr], msg
         # restore language
         req.set_language(origlang)
@@ -213,17 +213,17 @@
         # use super_session when available, we don't want to consider security
         # when selecting recipients_finder
         try:
-            req = self.req.super_session
+            req = self._cw.super_session
         except AttributeError:
-            req = self.req
-        finder = self.vreg['components'].select('recipients_finder', req,
-                                                rset=self.rset,
-                                                row=self.row or 0,
-                                                col=self.col or 0)
+            req = self._cw
+        finder = self._cw.vreg['components'].select('recipients_finder', req,
+                                                    rset=self.cw_rset,
+                                                    row=self.cw_row or 0,
+                                                    col=self.cw_col or 0)
         return finder.recipients()
 
     def send_now(self, recipients, msg):
-        self.config.sendmails([(msg, recipients)])
+        self._cw.vreg.config.sendmails([(msg, recipients)])
 
     def send_on_commit(self, recipients, msg):
         raise NotImplementedError
@@ -233,7 +233,7 @@
     # email generation helpers #################################################
 
     def construct_message_id(self, eid):
-        return construct_message_id(self.config.appid, eid, self.msgid_timestamp)
+        return construct_message_id(self._cw.vreg.config.appid, eid, self.msgid_timestamp)
 
     def format_field(self, attr, value):
         return ':%(attr)s: %(value)s' % {'attr': attr, 'value': value}
@@ -243,18 +243,18 @@
             'attr': attr, 'ul': '-'*len(attr), 'value': value}
 
     def subject(self):
-        entity = self.entity(self.row or 0, self.col or 0)
-        subject = self.req._(self.message)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
+        subject = self._cw._(self.message)
         etype = entity.dc_type()
         eid = entity.eid
         login = self.user_data['login']
-        return self.req._('%(subject)s %(etype)s #%(eid)s (%(login)s)') % locals()
+        return self._cw._('%(subject)s %(etype)s #%(eid)s (%(login)s)') % locals()
 
     def context(self, **kwargs):
-        entity = self.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)
         for key, val in kwargs.iteritems():
             if val and isinstance(val, unicode) and val.strip():
-               kwargs[key] = self.req._(val)
+               kwargs[key] = self._cw._(val)
         kwargs.update({'user': self.user_data['login'],
                        'eid': entity.eid,
                        'etype': entity.dc_type(),
--- a/common/mttransforms.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/common/mttransforms.py	Wed Sep 23 12:28:28 2009 +0200
@@ -60,10 +60,10 @@
         def _convert(self, trdata):
             context = CubicWebContext()
             appobject = trdata.appobject
-            context.update({'self': appobject, 'rset': appobject.rset,
-                            'req': appobject.req,
-                            '_' : appobject.req._,
-                            'user': appobject.req.user})
+            context.update({'self': appobject, 'rset': appobject.cw_rset,
+                            'req': appobject._cw,
+                            '_' : appobject._cw._,
+                            'user': appobject._cw.user})
             output = UStringIO()
             template = compile_template(trdata.encode(self.output_encoding))
             template.expand(context, output)
@@ -88,7 +88,7 @@
     def patch_convert(cls):
         def _convert(self, trdata, origconvert=cls._convert):
             try:
-                trdata.appobject.req.add_css('pygments.css')
+                trdata.appobject._cw.add_css('pygments.css')
             except AttributeError: # session has no add_css, only http request
                 pass
             return origconvert(self, trdata)
--- a/common/uilib.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/common/uilib.py	Wed Sep 23 12:28:28 2009 +0200
@@ -81,7 +81,7 @@
 REF_PROG = re.compile(r"<ref\s+rql=([\'\"])([^\1]*?)\1\s*>([^<]*)</ref>", re.U)
 def _subst_rql(view, obj):
     delim, rql, descr = obj.groups()
-    return u'<a href="%s">%s</a>' % (view.build_url(rql=rql), descr)
+    return u'<a href="%s">%s</a>' % (view._cw.build_url(rql=rql), descr)
 
 def html_publish(view, text):
     """replace <ref rql=''> links by <a href="...">"""
--- a/devtools/testlib.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/devtools/testlib.py	Wed Sep 23 12:28:28 2009 +0200
@@ -391,12 +391,12 @@
 
     def pactions(self, req, rset,
                  skipcategories=('addrelated', 'siteactions', 'useractions')):
-        return [(a.id, a.__class__)
+        return [(a.__regid__, a.__class__)
                 for a in self.vreg['actions'].poss_visible_objects(req, rset=rset)
                 if a.category not in skipcategories]
 
     def pactions_by_cats(self, req, rset, categories=('addrelated',)):
-        return [(a.id, a.__class__)
+        return [(a.__regid__, a.__class__)
                 for a in self.vreg['actions'].poss_visible_objects(req, rset=rset)
                 if a.category in categories]
 
@@ -468,7 +468,7 @@
         req = self.request()
         for view in self.vreg['views'].possible_views(req, None):
             if view.category == 'startupview':
-                yield view.id
+                yield view.__regid__
             else:
                 not_selected(self.vreg, view)
 
@@ -605,9 +605,9 @@
             # is not an AssertionError
             klass, exc, tcbk = sys.exc_info()
             try:
-                msg = '[%s in %s] %s' % (klass, view.id, exc)
+                msg = '[%s in %s] %s' % (klass, view.__regid__, exc)
             except:
-                msg = '[%s in %s] undisplayable exception' % (klass, view.id)
+                msg = '[%s in %s] undisplayable exception' % (klass, view.__regid__)
             if output is not None:
                 position = getattr(exc, "position", (0,))[0]
                 if position:
@@ -628,7 +628,7 @@
     def _check_html(self, output, view, template='main-template'):
         """raises an exception if the HTML is invalid"""
         try:
-            validatorclass = self.vid_validators[view.id]
+            validatorclass = self.vid_validators[view.__regid__]
         except KeyError:
             if template is None:
                 default_validator = htmlparser.HTMLValidator
@@ -794,16 +794,16 @@
                 propdefs[k]['default'] = True
         for view in self.list_views_for(rset):
             backup_rset = rset._prepare_copy(rset.rows, rset.description)
-            yield InnerTest(self._testname(rset, view.id, 'view'),
-                            self.view, view.id, rset,
+            yield InnerTest(self._testname(rset, view.__regid__, 'view'),
+                            self.view, view.__regid__, rset,
                             rset.req.reset_headers(), 'main-template')
             # We have to do this because some views modify the
             # resultset's syntax tree
             rset = backup_rset
         for action in self.list_actions_for(rset):
-            yield InnerTest(self._testname(rset, action.id, 'action'), self._test_action, action)
+            yield InnerTest(self._testname(rset, action.__regid__, 'action'), self._test_action, action)
         for box in self.list_boxes_for(rset):
-            yield InnerTest(self._testname(rset, box.id, 'box'), box.render)
+            yield InnerTest(self._testname(rset, box.__regid__, 'box'), box.render)
 
     @staticmethod
     def _testname(rset, objid, objtype):
--- a/entities/__init__.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/entities/__init__.py	Wed Sep 23 12:28:28 2009 +0200
@@ -86,7 +86,7 @@
 
     def dc_type(self, form=''):
         """return the display name for the type of this entity (translated)"""
-        return self.e_schema.display_name(self.req, form)
+        return self.e_schema.display_name(self._cw, form)
 
     def dc_language(self):
         """return language used by this entity (translated)"""
@@ -95,8 +95,8 @@
         for rschema, attrschema in self.e_schema.attribute_definitions():
             if rschema.rproperty(self.e_schema, attrschema,
                                  'internationalizable'):
-                return self.req._(self.req.user.property_value('ui.language'))
-        return self.req._(self.vreg.property_value('ui.language'))
+                return self._cw._(self.req.user.property_value('ui.language'))
+        return self._cw._(self._cw.vreg.property_value('ui.language'))
 
     @property
     def creator(self):
@@ -122,11 +122,11 @@
                     path = parent.breadcrumbs(view) + [self]
         if not recurs:
             if view is None:
-                if 'vtitle' in self.req.form:
+                if 'vtitle' in self._cw.form:
                     # embeding for instance
-                    path.append( self.req.form['vtitle'] )
+                    path.append( self._cw.form['vtitle'] )
             elif view.id != 'primary' and hasattr(view, 'title'):
-                path.append( self.req._(view.title) )
+                path.append( self._cw._(view.title) )
         return path
 
     ## IFeed interface ########################################################
@@ -163,7 +163,7 @@
             self.__linkto = {}
         except KeyError:
             pass
-        linktos = list(self.req.list_form_param('__linkto'))
+        linktos = list(self._cw.list_form_param('__linkto'))
         linkedto = []
         for linkto in linktos[:]:
             ltrtype, eid, ltrole = linkto.split(':')
@@ -172,7 +172,7 @@
                 # hidden input
                 if remove:
                     linktos.remove(linkto)
-                    self.req.form['__linkto'] = linktos
+                    self._cw.form['__linkto'] = linktos
                 linkedto.append(typed_eid(eid))
         self.__linkto[(rtype, role)] = linkedto
         return linkedto
--- a/entities/lib.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/entities/lib.py	Wed Sep 23 12:28:28 2009 +0200
@@ -62,7 +62,7 @@
             yield rset.get_entity(i, 0)
 
     def display_address(self):
-        if self.vreg.config['mangle-emails']:
+        if self._cw.vreg.config['mangle-emails']:
             return mangle_email(self.address)
         return self.address
 
--- a/entity.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/entity.py	Wed Sep 23 12:28:28 2009 +0200
@@ -263,8 +263,8 @@
 
     def view(self, vid, __registry='views', **kwargs):
         """shortcut to apply a view on this entity"""
-        return self._cw.vreg[__registry].render(
-            vid, self._cw, rset=self.rset, row=self.row, col=self.col, **kwargs)
+        view = self._cw.vreg[__registry].select(vid, self._cw, rset=self.cw_rset)
+        return view.render(row=self.cw_row, col=self.cw_col, **kwargs)
 
     def absolute_url(self, *args, **kwargs):
         """return an absolute url to view this entity"""
--- a/ext/rest.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/ext/rest.py	Wed Sep 23 12:28:28 2009 +0200
@@ -70,10 +70,10 @@
     # Base URL mainly used by inliner.pep_reference; so this is correct:
     context = inliner.document.settings.context
     try:
-        refedentity = context.req.entity_from_eid(eid_num)
+        refedentity = context._cw.entity_from_eid(eid_num)
     except UnknownEid:
         ref = '#'
-        rest += u' ' + context.req._('(UNEXISTANT EID)')
+        rest += u' ' + context._cw._('(UNEXISTANT EID)')
     else:
         ref = refedentity.absolute_url()
     set_classes(options)
@@ -210,7 +210,7 @@
     :return:
       the data formatted as HTML or the original data if an error occured
     """
-    req = context.req
+    req = context._cw
     if isinstance(data, unicode):
         encoding = 'unicode'
         # remove unprintable characters unauthorized in xml
--- a/hooks/notification.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/hooks/notification.py	Wed Sep 23 12:28:28 2009 +0200
@@ -18,7 +18,7 @@
     """delay rendering of notification view until precommit"""
     def precommit_event(self):
         view = self.view
-        if view.rset is not None and not view.rset:
+        if view.cw_rset is not None and not view.cw_rset:
             return # entity added and deleted in the same transaction (cache effect)
         if view.cw_rset and self.session.deleted_in_transaction(view.cw_rset[cw_rset.cw_row or 0][cw_rset.cw_col or 0]):
             return # entity added and deleted in the same transaction
--- a/server/hook.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/server/hook.py	Wed Sep 23 12:28:28 2009 +0200
@@ -432,10 +432,10 @@
             self.to_send = previous.to_send + self.to_send
 
     def commit_event(self):
-        self.repo.threaded_task(self.sendmails)
+        self.session.repo.threaded_task(self.sendmails)
 
     def sendmails(self):
-        self.config.sendmails(self.to_send)
+        self.session.vreg.config.sendmails(self.to_send)
 
 
 class RQLPrecommitOperation(Operation):
--- a/sobjects/notification.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/sobjects/notification.py	Wed Sep 23 12:28:28 2009 +0200
@@ -17,7 +17,7 @@
 from cubicweb.view import Component
 from cubicweb.common.mail import format_mail
 from cubicweb.common.mail import NotificationView
-from cubicweb.server.hookhelper import SendMailOp
+from cubicweb.server.hook import SendMailOp
 
 
 class RecipientsFinder(Component):
@@ -32,16 +32,16 @@
                 'X primary_email E, E address A')
 
     def recipients(self):
-        mode = self.req.vreg.config['default-recipients-mode']
+        mode = self._cw.vreg.config['default-recipients-mode']
         if mode == 'users':
             # use unsafe execute else we may don't have the right to see users
             # to notify...
-            execute = self.req.unsafe_execute
+            execute = self._cw.unsafe_execute
             dests = [(u.get_email(), u.property_value('ui.language'))
                      for u in execute(self.user_rql, build_descr=True, propagate=True).entities()]
         elif mode == 'default-dest-addrs':
-            lang = self.vreg.property_value('ui.language')
-            dests = zip(self.req.vreg.config['default-dest-addrs'], repeat(lang))
+            lang = self._cw.vreg.property_value('ui.language')
+            dests = zip(self._cw.vreg.config['default-dest-addrs'], repeat(lang))
         else: # mode == 'none'
             dests = []
         return dests
@@ -54,7 +54,7 @@
     default
     """
     def send_on_commit(self, recipients, msg):
-        SendMailOp(self.req, recipients=recipients, msg=msg)
+        SendMailOp(self._cw, recipients=recipients, msg=msg)
     send = send_on_commit
 
 
@@ -101,7 +101,7 @@
 """
 
     def context(self, **kwargs):
-        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)
         content = entity.printable_value(self.content_attr, format='text/plain')
         if content:
             contentformat = getattr(entity, self.content_attr + '_format',
@@ -113,8 +113,8 @@
         return super(ContentAddedView, self).context(content=content, **kwargs)
 
     def subject(self):
-        entity = self.rset.get_entity(self.row or 0, self.col or 0)
-        return  u'%s #%s (%s)' % (self.req.__('New %s' % entity.e_schema),
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
+        return  u'%s #%s (%s)' % (self._cw.__('New %s' % entity.e_schema),
                                   entity.eid, self.user_data['login'])
 
 
--- a/test/unittest_rset.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/test/unittest_rset.py	Wed Sep 23 12:28:28 2009 +0200
@@ -105,7 +105,7 @@
         self.assertEquals(rs.limit(2).rows, [[12000, 'adim'], [13000, 'syt']])
         rs2 = rs.limit(2, offset=1)
         self.assertEquals(rs2.rows, [[13000, 'syt'], [14000, 'nico']])
-        self.assertEquals(rs2.get_entity(0, 0).row, 0)
+        self.assertEquals(rs2.get_entity(0, 0).cw_row, 0)
         self.assertEquals(rs.limit(2, offset=2).rows, [[14000, 'nico']])
         self.assertEquals(rs.limit(2, offset=3).rows, [])
 
@@ -229,16 +229,16 @@
         rset = self.execute('Any X,Y,XT,YN WHERE X bookmarked_by Y, X title XT, Y login YN')
 
         e = rset.get_entity(0, 0)
-        self.assertEquals(e.row, 0)
-        self.assertEquals(e.col, 0)
+        self.assertEquals(e.cw_row, 0)
+        self.assertEquals(e.cw_col, 0)
         self.assertEquals(e['title'], 'zou')
         self.assertRaises(KeyError, e.__getitem__, 'path')
         self.assertEquals(e.view('text'), 'zou')
         self.assertEquals(pprelcachedict(e._related_cache), [])
 
         e = rset.get_entity(0, 1)
-        self.assertEquals(e.row, 0)
-        self.assertEquals(e.col, 1)
+        self.assertEquals(e.cw_row, 0)
+        self.assertEquals(e.cw_col, 1)
         self.assertEquals(e['login'], 'anon')
         self.assertRaises(KeyError, e.__getitem__, 'firstname')
         self.assertEquals(pprelcachedict(e._related_cache),
@@ -304,8 +304,8 @@
                     ('Bookmark', 'manger'), ('CWGroup', 'owners'),
                     ('CWGroup', 'users'))
         for entity in rset.entities(): # test get_entity for each row actually
-            etype, n = expected[entity.row]
-            self.assertEquals(entity.id, etype)
+            etype, n = expected[entity.cw_row]
+            self.assertEquals(entity.__regid__, etype)
             attr = etype == 'Bookmark' and 'title' or 'name'
             self.assertEquals(entity[attr], n)
 
@@ -326,7 +326,7 @@
         self.assertEquals(entity.eid, e.eid)
         self.assertEquals(rtype, 'title')
         entity, rtype = rset.related_entity(1, 1)
-        self.assertEquals(entity.id, 'CWGroup')
+        self.assertEquals(entity.__regid__, 'CWGroup')
         self.assertEquals(rtype, 'name')
         #
         rset = self.execute('Any X,N ORDERBY N WHERE X is Bookmark WITH X,N BEING '
--- a/test/unittest_selectors.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/test/unittest_selectors.py	Wed Sep 23 12:28:28 2009 +0200
@@ -107,7 +107,7 @@
     def test_owners_group(self):
         """tests usage of 'owners' group with match_user_group"""
         class SomeAction(action.Action):
-            id = 'yo'
+            __regid__ = 'yo'
             category = 'foo'
             __select__ = match_user_groups('owners')
         self.vreg._loadedmods[__name__] = {}
@@ -118,19 +118,22 @@
             self.create_user('john')
             self.login('john')
             # it should not be possible to use SomeAction not owned objects
-            rset, req = self.rset_and_req('Any G WHERE G is CWGroup, G name "managers"')
+            req = self.request()
+            rset = req.execute('Any G WHERE G is CWGroup, G name "managers"')
             self.failIf('yo' in dict(self.pactions(req, rset)))
             # insert a new card, and check that we can use SomeAction on our object
             self.execute('INSERT Card C: C title "zoubidou"')
             self.commit()
-            rset, req = self.rset_and_req('Card C WHERE C title "zoubidou"')
+            req = self.request()
+            rset = req.execute('Card C WHERE C title "zoubidou"')
             self.failUnless('yo' in dict(self.pactions(req, rset)), self.pactions(req, rset))
             # make sure even managers can't use the action
             self.restore_connection()
-            rset, req = self.rset_and_req('Card C WHERE C title "zoubidou"')
+            req = self.request()
+            rset = req.execute('Card C WHERE C title "zoubidou"')
             self.failIf('yo' in dict(self.pactions(req, rset)))
         finally:
-            del self.vreg[SomeAction.__registry__][SomeAction.id]
+            del self.vreg[SomeAction.__registry__][SomeAction.__regid__]
 
 if __name__ == '__main__':
     unittest_main()
--- a/web/views/autoform.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/web/views/autoform.py	Wed Sep 23 12:28:28 2009 +0200
@@ -87,30 +87,30 @@
                     yield (rschema, targetschemas, role)
                     continue
                 if rschema.is_final():
-                    if not rschema.has_perm(entity.req, permission, eid):
+                    if not rschema.has_perm(entity._cw, permission, eid):
                         continue
                 elif role == 'subject':
                     if not ((not strict and rschema.has_local_role(permission)) or
-                            rschema.has_perm(entity.req, permission, fromeid=eid)):
+                            rschema.has_perm(entity._cw, permission, fromeid=eid)):
                         continue
                     # on relation with cardinality 1 or ?, we need delete perm as well
                     # if the relation is already set
                     if (permission == 'add'
                         and rschema.cardinality(eschema, targetschemas[0], role) in '1?'
                         and eid and entity.related(rschema.type, role)
-                        and not rschema.has_perm(entity.req, 'delete', fromeid=eid,
+                        and not rschema.has_perm(entity._cw, 'delete', fromeid=eid,
                                                  toeid=entity.related(rschema.type, role)[0][0])):
                         continue
                 elif role == 'object':
                     if not ((not strict and rschema.has_local_role(permission)) or
-                            rschema.has_perm(entity.req, permission, toeid=eid)):
+                            rschema.has_perm(entity._cw, permission, toeid=eid)):
                         continue
                     # on relation with cardinality 1 or ?, we need delete perm as well
                     # if the relation is already set
                     if (permission == 'add'
                         and rschema.cardinality(targetschemas[0], eschema, role) in '1?'
                         and eid and entity.related(rschema.type, role)
-                        and not rschema.has_perm(entity.req, 'delete', toeid=eid,
+                        and not rschema.has_perm(entity._cw, 'delete', toeid=eid,
                                                  fromeid=entity.related(rschema.type, role)[0][0])):
                         continue
             yield (rschema, targetschemas, role)
@@ -128,7 +128,7 @@
             entity, categories, permission, strict=strict):
             if rschema.is_final():
                 continue
-            result.append((rschema.display_name(entity.req, role), rschema, role))
+            result.append((rschema.display_name(entity._cw, role), rschema, role))
         return sorted(result)
 
     @iclassmethod
@@ -180,8 +180,8 @@
                 except form.FieldNotFound:
                     # meta attribute such as <attr>_format
                     continue
-        self.maxrelitems = self.req.property_value('navigation.related-limit')
-        self.force_display = bool(self.req.form.get('__force_display'))
+        self.maxrelitems = self._cw.property_value('navigation.related-limit')
+        self.force_display = bool(self._cw.form.get('__force_display'))
 
     @property
     def related_limit(self):
@@ -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.req)
-                subform = self.vreg['forms'].select('edition', self.req, entity=entity)
+                entity = self.vreg['etypes'].etype_class(targettype)(self._cw)
+                subform = self.vreg['forms'].select('edition', self._cw, entity=entity)
                 if subform.form_needs_multipart:
                     return True
         return False
@@ -276,11 +276,11 @@
           - oneline view of related entity
         """
         entity = self.edited_entity
-        pending_deletes = self.req.get_pending_deletes(entity.eid)
+        pending_deletes = self._cw.get_pending_deletes(entity.eid)
         for label, rschema, role in self.srelations_by_category('generic', 'add',
                                                                 strict=True):
             relatedrset = entity.related(rschema, role, limit=self.related_limit)
-            if rschema.has_perm(self.req, 'delete'):
+            if rschema.has_perm(self._cw, 'delete'):
                 toggleable_rel_link_func = editforms.toggleable_relation_link
             else:
                 toggleable_rel_link_func = lambda x, y, z: u''
@@ -305,22 +305,22 @@
         """
         eid = self.edited_entity.eid
         cell = cell and "div_insert_" or "tr"
-        pending_inserts = set(self.req.get_pending_inserts(eid))
+        pending_inserts = set(self._cw.get_pending_inserts(eid))
         for pendingid in pending_inserts:
             eidfrom, rtype, eidto = pendingid.split(':')
             if typed_eid(eidfrom) == eid: # subject
-                label = display_name(self.req, rtype, 'subject')
+                label = display_name(self._cw, rtype, 'subject')
                 reid = eidto
             else:
-                label = display_name(self.req, rtype, 'object')
+                label = display_name(self._cw, rtype, 'object')
                 reid = eidfrom
             jscall = "javascript: cancelPendingInsert('%s', '%s', null, %s);" \
                      % (pendingid, cell, eid)
-            rset = self.req.eid_rset(reid)
+            rset = self._cw.eid_rset(reid)
             eview = self.view('text', rset, row=0)
             # XXX find a clean way to handle baskets
             if rset.description[0][0] == 'Basket':
-                eview = '%s (%s)' % (eview, display_name(self.req, 'Basket'))
+                eview = '%s (%s)' % (eview, display_name(self._cw, 'Basket'))
             yield rtype, pendingid, jscall, label, reid, eview
 
     # inlined forms support ####################################################
@@ -356,7 +356,7 @@
 
         by default true if there is no related entity and we need at least one
         """
-        return not existant and card in '1+' or self.req.form.has_key('force_%s_display' % rschema)
+        return not existant and card in '1+' or self._cw.form.has_key('force_%s_display' % rschema)
 
     def display_inline_creation_form(self, w, rschema, targettype, role,
                                      i18nctx):
--- a/web/views/baseviews.py	Wed Sep 23 11:22:19 2009 +0200
+++ b/web/views/baseviews.py	Wed Sep 23 12:28:28 2009 +0200
@@ -159,9 +159,9 @@
                 self.w(u"\n")
 
     def cell_call(self, row, col=0, **kwargs):
-        entity = self.rset.get_entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.w(cut(entity.dc_title(),
-                   self.req.property_value('navigation.short-line-size')))
+                   self._cw.property_value('navigation.short-line-size')))
 
 
 class MetaDataView(EntityView):