web/views/basecomponents.py
changeset 3451 6b46d73823f5
parent 3407 da9cc8cc7c5f
child 3659 993997b4b41d
--- 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')))