web/views/management.py
changeset 3451 6b46d73823f5
parent 3377 dd9d292b6a6d
child 3733 c3feb6a33f58
--- 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>' % (