[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
--- a/entities/adapters.py Thu Oct 21 18:38:36 2010 +0200
+++ b/entities/adapters.py Fri Oct 22 09:15:35 2010 +0200
@@ -27,6 +27,7 @@
from logilab.mtconverter import TransformError
from logilab.common.decorators import cached
+from cubicweb import ValidationError
from cubicweb.view import EntityAdapter, implements_adapter_compat
from cubicweb.selectors import (implements, is_instance, relation_possible,
match_exception)
--- a/req.py Thu Oct 21 18:38:36 2010 +0200
+++ b/req.py Fri Oct 22 09:15:35 2010 +0200
@@ -210,8 +210,7 @@
if not isinstance(values, (list, tuple)):
values = (values,)
for value in values:
- if value is None:
- raise ValueError(_('unauthorized value'))
+ assert value is not None
args.append(u'%s=%s' % (param, self.url_quote(value)))
return '&'.join(args)
--- a/server/migractions.py Thu Oct 21 18:38:36 2010 +0200
+++ b/server/migractions.py Fri Oct 22 09:15:35 2010 +0200
@@ -956,7 +956,7 @@
# get some validation error on commit since integrity hooks
# may think some required relation is missing... This also ensure
# repository caches are properly cleanup
- CleanupDeletedEidsCacheOp.get_instance(session).add_data(eid)
+ hook.CleanupDeletedEidsCacheOp.get_instance(session).add_data(eid)
# and don't forget to remove record from system tables
self.repo.system_source.delete_info(
session, session.entity_from_eid(eid, rdeftype),
--- a/server/session.py Thu Oct 21 18:38:36 2010 +0200
+++ b/server/session.py Fri Oct 22 09:15:35 2010 +0200
@@ -28,6 +28,7 @@
from warnings import warn
from logilab.common.deprecation import deprecated
+from rql import CoercionError
from rql.nodes import ETYPE_PYOBJ_MAP, etype_from_pyobj
from yams import BASE_TYPES
--- a/server/sources/__init__.py Thu Oct 21 18:38:36 2010 +0200
+++ b/server/sources/__init__.py Fri Oct 22 09:15:35 2010 +0200
@@ -55,7 +55,7 @@
def __init__(self, ttl):
# time to live in seconds
if ttl <= 0:
- raise ValueError('TimedCache initialized with a ttl of %ss' % self.ttl.seconds)
+ raise ValueError('TimedCache initialized with a ttl of %ss' % ttl.seconds)
self.ttl = timedelta(seconds=ttl)
def __setitem__(self, key, value):
--- a/server/sources/pyrorql.py Thu Oct 21 18:38:36 2010 +0200
+++ b/server/sources/pyrorql.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""Source to query another RQL repository using pyro"""
__docformat__ = "restructuredtext en"
+_ = unicode
import threading
from os.path import join
--- a/sobjects/supervising.py Thu Oct 21 18:38:36 2010 +0200
+++ b/sobjects/supervising.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""some hooks and views to handle supervising of any data changes"""
__docformat__ = "restructuredtext en"
+_ = unicode
from cubicweb import UnknownEid
from cubicweb.selectors import none_rset
@@ -133,7 +134,8 @@
self.w(msg % locals())
def change_state(self, (entity, fromstate, tostate)):
- msg = self._cw._('changed state of %(etype)s #%(eid)s (%(title)s)')
+ _ = self._cw._
+ msg = _('changed state of %(etype)s #%(eid)s (%(title)s)')
self.w(u'%s\n' % (msg % self._entity_context(entity)))
self.w(_(' from state %(fromstate)s to state %(tostate)s\n' %
{'fromstate': _(fromstate.name), 'tostate': _(tostate.name)}))
--- a/web/application.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/application.py Fri Oct 22 09:15:35 2010 +0200
@@ -216,7 +216,7 @@
session = self.session_manager.open_session(req)
cookie = req.get_cookie()
cookie[self.SESSION_VAR] = session.sessionid
- if req.https:
+ if req.https and req.base_url().startswith('https://'):
cookie[self.SESSION_VAR]['secure'] = True
req.set_cookie(cookie, self.SESSION_VAR, maxage=None)
if not session.anonymous_session:
--- a/web/facet.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/facet.py Fri Oct 22 09:15:35 2010 +0200
@@ -45,6 +45,7 @@
"""
__docformat__ = "restructuredtext en"
+_ = unicode
from copy import deepcopy
from datetime import date, datetime, timedelta
--- a/web/formfields.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/formfields.py Fri Oct 22 09:15:35 2010 +0200
@@ -349,8 +349,8 @@
if support_args(self.value, 'form', 'field'):
return self.value(form, self)
else:
- warn("[3.10] field's value callback must now take form and field as argument",
- DeprecationWarning)
+ warn("[3.10] field's value callback must now take form and "
+ "field as argument (%s)" % self, DeprecationWarning)
return self.value(form)
return self.value
formattr = '%s_%s_default' % (self.role, self.name)
--- a/web/views/basecontrollers.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/basecontrollers.py Fri Oct 22 09:15:35 2010 +0200
@@ -20,6 +20,7 @@
"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.common.date import strptime
@@ -119,7 +120,7 @@
self.validate_cache(view)
template = self.appli.main_template_id(self._cw)
return self._cw.vreg['views'].main_template(self._cw, template,
- rset=rset, view=view)
+ rset=rset, view=view)
def _select_view_and_rset(self, rset):
req = self._cw
@@ -584,7 +585,9 @@
def publish(self, rset=None):
body = self._cw.form['description']
- self.sendmail(self._cw.config['submit-mail'], _('%s error report') % self._cw.config.appid, body)
+ self.sendmail(self._cw.config['submit-mail'],
+ self._cw._('%s error report') % self._cw.config.appid,
+ body)
url = self._cw.build_url(__message=self._cw._('bug report sent'))
raise Redirect(url)
@@ -596,11 +599,10 @@
def publish(self, rset=None):
txuuid = self._cw.form['txuuid']
errors = self._cw.cnx.undo_transaction(txuuid)
- if errors:
- self.w(self._cw._('some errors occurred:'))
- self.wview('pyvalist', pyvalue=errors)
- else:
+ if not errors:
self.redirect()
+ return self._cw._('some errors occurred:') + self.view('pyvalist',
+ pyvalue=errors)
def redirect(self):
req = self._cw
--- a/web/views/basetemplates.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/basetemplates.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""default templates for CubicWeb web client"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.mtconverter import xml_escape
from logilab.common.deprecation import class_renamed
--- a/web/views/bookmark.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/bookmark.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""Primary view for bookmarks + user's bookmarks box"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.mtconverter import xml_escape
@@ -100,7 +101,7 @@
label = self.build_link(bookmark.title, bookmark.action_url())
if self.can_delete:
dlink = u'[<a class="action" href="javascript:removeBookmark(%s)" title="%s">-</a>]' % (
- bookmark.eid, _('delete this bookmark'))
+ bookmark.eid, req._('delete this bookmark'))
label = '<div>%s %s</div>' % (dlink, label)
self.append(label)
if self.can_edit:
--- a/web/views/csvexport.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/csvexport.py Fri Oct 22 09:15:35 2010 +0200
@@ -15,10 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""csv export views
+"""csv export views"""
-"""
__docformat__ = "restructuredtext en"
+_ = unicode
from cubicweb.schema import display_name
from cubicweb.uilib import UnicodeCSVWriter
--- a/web/views/cwuser.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/cwuser.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""Specific views for users and groups"""
__docformat__ = "restructuredtext en"
+_ = unicode
import hashlib
@@ -107,6 +108,7 @@
__select__ = tabs.PrimaryTab.__select__ & is_instance('CWGroup')
def render_entity_attributes(self, entity):
+ _ = self._cw._
rql = 'Any U, FN, LN, CD, LL ORDERBY L WHERE U in_group G, ' \
'U login L, U firstname FN, U surname LN, U creation_date CD, ' \
'U last_login_time LL, G eid %(x)s'
--- a/web/views/debug.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/debug.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,11 +18,13 @@
"""management and error screens"""
__docformat__ = "restructuredtext en"
+_ = unicode
from time import strftime, localtime
from logilab.mtconverter import xml_escape
+from cubicweb import BadConnectionId
from cubicweb.selectors import none_rset, match_user_groups
from cubicweb.view import StartupView
from cubicweb.web.views import actions
@@ -144,7 +146,7 @@
cache_max_age = 0
def call(self, **kwargs):
- self.w(u'<h1>%s</h1>' % _("Registry's content"))
+ self.w(u'<h1>%s</h1>' % self._cw._("Registry's content"))
keys = sorted(self._cw.vreg)
url = xml_escape(self._cw.url())
self.w(u'<p>%s</p>\n' % ' - '.join('<a href="%s#%s">%s</a>'
@@ -180,20 +182,20 @@
Connection, Cursor,
CubicWebRequestBase)
try:
- from cubicweb.server.session import Session, ChildSession, InternalSession
- lookupclasses += (InternalSession, ChildSession, Session)
+ from cubicweb.server.session import Session, InternalSession
+ lookupclasses += (InternalSession, Session)
except ImportError:
pass # no server part installed
self.w(u'<h1>%s</h1>' % _('Garbage collection information'))
counters, ocounters, garbage = gc_info(lookupclasses,
viewreferrersclasses=())
- self.w(u'<h3>%s</h3>' % _('Looked up classes'))
+ self.w(u'<h3>%s</h3>' % self._cw._('Looked up classes'))
values = sorted(counters.iteritems(), key=lambda x: x[1], reverse=True)
self.wview('pyvaltable', pyvalue=values)
- self.w(u'<h3>%s</h3>' % _('Most referenced classes'))
+ self.w(u'<h3>%s</h3>' % self._cw._('Most referenced classes'))
values = sorted(ocounters.iteritems(), key=lambda x: x[1], reverse=True)
self.wview('pyvaltable', pyvalue=values[:self._cw.form.get('nb', 20)])
if garbage:
- self.w(u'<h3>%s</h3>' % _('Unreachable objects'))
+ self.w(u'<h3>%s</h3>' % self._cw._('Unreachable objects'))
values = sorted(xml_escape(repr(o)) for o in garbage)
self.wview('pyvallist', pyvalue=values)
--- a/web/views/embedding.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/embedding.py Fri Oct 22 09:15:35 2010 +0200
@@ -20,6 +20,7 @@
"""
__docformat__ = "restructuredtext en"
+_ = unicode
import re
from urlparse import urljoin
--- a/web/views/facets.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/facets.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""the facets box and some basic facets"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.mtconverter import xml_escape
--- a/web/views/formrenderers.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/formrenderers.py Fri Oct 22 09:15:35 2010 +0200
@@ -31,7 +31,9 @@
.. autoclass:: cubicweb.web.views.formrenderers.EntityInlinedFormRenderer
"""
+
__docformat__ = "restructuredtext en"
+_ = unicode
from warnings import warn
@@ -107,17 +109,20 @@
def render(self, w, form, values):
self._set_options(values)
form.add_media()
- w(self.open_form(form, values))
+ data = []
+ _w = data.append
+ _w(self.open_form(form, values))
if self.display_progress_div:
- w(u'<div id="progress">%s</div>' % self._cw._('validating...'))
- w(u'<fieldset>')
- self.render_fields(w, form, values)
- self.render_buttons(w, form)
- w(u'</fieldset>')
- w(self.close_form(form, values))
+ _w(u'<div id="progress">%s</div>' % self._cw._('validating...'))
+ _w(u'<fieldset>')
+ self.render_fields(_w, form, values)
+ self.render_buttons(_w, form)
+ _w(u'</fieldset>')
+ _w(self.close_form(form, values))
errormsg = self.error_message(form)
if errormsg:
data.insert(0, errormsg)
+ w(''.join(data))
def render_label(self, form, field):
if field.label is None:
--- a/web/views/isioc.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/isioc.py Fri Oct 22 09:15:35 2010 +0200
@@ -21,6 +21,7 @@
"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.mtconverter import xml_escape
--- a/web/views/old_calendar.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/old_calendar.py Fri Oct 22 09:15:35 2010 +0200
@@ -17,6 +17,9 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""html calendar views"""
+__docformat__ = "restructuredtext en"
+_ = unicode
+
from datetime import date, time, timedelta
from logilab.mtconverter import xml_escape
--- a/web/views/plots.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/plots.py Fri Oct 22 09:15:35 2010 +0200
@@ -15,10 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""basic plot views
+"""basic plot views"""
-"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.common.date import datetime2ticks
from logilab.mtconverter import xml_escape
--- a/web/views/primary.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/primary.py Fri Oct 22 09:15:35 2010 +0200
@@ -371,13 +371,13 @@
__regid__ = 'attribute'
__select__ = EntityView.__select__ & match_kwargs('rtype')
- def cell_call(self, row, col, rtype, **kwargs):
+ def cell_call(self, row, col, rtype, role, **kwargs):
entity = self.cw_rset.get_entity(row, col)
if self._cw.vreg.schema.rschema(rtype).final:
self.w(entity.printable_value(rtype))
else:
dispctrl = uicfg.primaryview_display_ctrl.etype_get(
- entity.e_schema, rtype, kwargs['role'], '*')
+ entity.e_schema, rtype, role, '*')
rset = entity.related(rtype, role)
if rset:
self.wview('autolimited', rset, initargs={'dispctrl': dispctrl})
--- a/web/views/reledit.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/reledit.py Fri Oct 22 09:15:35 2010 +0200
@@ -15,8 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""the 'reedit' feature (eg edit attribute/relation from primary view)
-"""
+"""the 'reedit' feature (eg edit attribute/relation from primary view"""
+
+__docformat__ = "restructuredtext en"
+_ = unicode
import copy
from warnings import warn
@@ -209,7 +211,7 @@
return rschema.has_perm(self._cw, 'delete', **kwargs)
def _build_edit_zone(self):
- return self._editzone % {'msg' : xml_escape(_(self._cw._(self._editzonemsg)))}
+ return self._editzone % {'msg' : xml_escape(self._cw._(self._editzonemsg))}
def _build_delete_zone(self):
return self._deletezone % {'msg': xml_escape(self._cw._(self._deletemsg))}
--- a/web/views/schema.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/schema.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""Specific views for schema related entities"""
__docformat__ = "restructuredtext en"
+_ = unicode
from itertools import cycle
@@ -125,6 +126,7 @@
# set layout permissions in a table for each group of relation
# definition
w = self.w
+ _ = self._cw._
w(u'<div style="margin: 0px 1.5em">')
tmpl = u'<strong>%s</strong> %s <strong>%s</strong>'
for perm, rdefs in perms.iteritems():
@@ -147,7 +149,7 @@
default_tab = 'schema-diagram'
def call(self):
- self.w(u'<h1>%s</h1>' % _('Schema of the data model'))
+ self.w(u'<h1>%s</h1>' % self._cw._('Schema of the data model'))
self.render_tabs(self.tabs, self.default_tab)
@@ -155,9 +157,11 @@
__regid__ = 'schema-diagram'
def call(self):
- 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>')
+ _ = self._cw._
+ self.w(self._cw._(
+ u'<div>This schema of the data model <em>excludes</em> the '
+ 'meta-data, but you can also display a <a href="%s">complete '
+ 'schema with meta-data</a>.</div>')
% xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=0)))
self.w(u'<div><a href="%s">%s</a></div>' %
(self._cw.build_url('view', vid='owl'),
@@ -397,15 +401,16 @@
def cell_call(self, row, col):
entity = self.cw_rset.get_entity(row, col)
eschema = self._cw.vreg.schema.eschema(entity.name)
- self.w(u'<h4>%s</h4>' % _('This entity type permissions:').capitalize())
+ self.w(u'<h4>%s</h4>' % self._cw._('This entity type permissions:'))
self.permissions_table(eschema)
self.w(u'<div style="margin: 0px 1.5em">')
- self.w(u'<h4>%s</h4>' % _('Attributes permissions:').capitalize())
+ self.w(u'<h4>%s</h4>' % self._cw._('Attributes permissions:'))
for attr, etype in eschema.attribute_definitions():
if attr not in META_RTYPES:
rdef = eschema.rdef(attr)
attrtype = str(rdef.rtype)
- self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attrtype, _(attrtype)))
+ self.w(u'<h4 class="schema">%s (%s)</h4> '
+ % (attrtype, self._cw._(attrtype)))
self.permissions_table(rdef)
self.w(u'</div>')
--- a/web/views/sparql.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/sparql.py Fri Oct 22 09:15:35 2010 +0200
@@ -15,10 +15,10 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""SPARQL integration
+"""SPARQL integration"""
-"""
__docformat__ = "restructuredtext en"
+_ = unicode
from yams import xy
from rql import TypeResolverException
--- a/web/views/tableview.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/tableview.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""generic table view, including filtering abilities"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.mtconverter import xml_escape
--- a/web/views/tabs.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/tabs.py Fri Oct 22 09:15:35 2010 +0200
@@ -18,6 +18,7 @@
"""base classes to handle tabbed views"""
__docformat__ = "restructuredtext en"
+_ = unicode
from logilab.common.deprecation import class_renamed
from logilab.mtconverter import xml_escape
--- a/web/views/treeview.py Thu Oct 21 18:38:36 2010 +0200
+++ b/web/views/treeview.py Fri Oct 22 09:15:35 2010 +0200
@@ -20,6 +20,7 @@
"""
__docformat__ = "restructuredtext en"
+_ = unicode
from warnings import warn