# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1237827359 -3600 # Node ID 96752791c2b6e4018af36ad7a4c8af8773b5e78e # Parent 544609e83317b243fa513b79e713e8d5f8d5e710 pylint cleanup diff -r 544609e83317 -r 96752791c2b6 __init__.py --- a/__init__.py Mon Mar 23 17:38:30 2009 +0100 +++ b/__init__.py Mon Mar 23 17:55:59 2009 +0100 @@ -88,8 +88,8 @@ from cubicweb.rset import ResultSet rset = ResultSet([('A',)]*size, '%s X' % etype, description=[(etype,)]*size) - def get_entity(row, col=0, etype=etype, vreg=self.vreg, rset=rset): - return self.vreg.etype_class(etype)(self, rset, row, col) + def get_entity(row, col=0, etype=etype, req=self, rset=rset): + return req.vreg.etype_class(etype)(req, rset, row, col) rset.get_entity = get_entity return self.decorate_rset(rset) diff -r 544609e83317 -r 96752791c2b6 common/appobject.py --- a/common/appobject.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/appobject.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,3 +1,5 @@ +"""pre 3.2 bw compat""" +# pylint: disable-msg=W0614,W0401 from warnings import warn warn('moved to cubicweb.appobject', DeprecationWarning, stacklevel=2) from cubicweb.appobject import * diff -r 544609e83317 -r 96752791c2b6 common/entity.py --- a/common/entity.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/entity.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,3 +1,5 @@ +"""pre 3.2 bw compat""" +# pylint: disable-msg=W0614,W0401 from warnings import warn warn('moved to cubicweb.entity', DeprecationWarning, stacklevel=2) from cubicweb.entity import * diff -r 544609e83317 -r 96752791c2b6 common/i18n.py --- a/common/i18n.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/i18n.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,14 +1,14 @@ """Some i18n/gettext utilities. :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" import re import os -from os.path import join, abspath, basename, splitext, exists +from os.path import join, basename, splitext, exists from glob import glob from cubicweb.toolsutils import create_dir diff -r 544609e83317 -r 96752791c2b6 common/mttransforms.py --- a/common/mttransforms.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/mttransforms.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,7 +1,7 @@ """mime type transformation engine for cubicweb, based on mtconverter :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -14,7 +14,7 @@ register_pil_transforms, register_pygments_transforms) -from cubicweb.common.uilib import rest_publish, html_publish, remove_html_tags +from cubicweb.common.uilib import rest_publish, html_publish HTML_MIMETYPES = ('text/html', 'text/xhtml', 'application/xhtml+xml') diff -r 544609e83317 -r 96752791c2b6 common/registerers.py --- a/common/registerers.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/registerers.py Mon Mar 23 17:55:59 2009 +0100 @@ -11,7 +11,6 @@ __docformat__ = "restructuredtext en" from cubicweb.vregistry import registerer, yes_registerer -from cubicweb.selectors import implements from cubicweb.cwvreg import use_interfaces class priority_registerer(registerer): diff -r 544609e83317 -r 96752791c2b6 common/schema.py --- a/common/schema.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/schema.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,3 +1,5 @@ +"""pre 3.0 bw compat""" +# pylint: disable-msg=W0614,W0401 from warnings import warn warn('moved to cubicweb.schema', DeprecationWarning, stacklevel=2) from cubicweb.schema import * diff -r 544609e83317 -r 96752791c2b6 common/selectors.py --- a/common/selectors.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/selectors.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,3 +1,5 @@ +"""pre 3.2 bw compat""" +# pylint: disable-msg=W0614,W0401 from warnings import warn warn('moved to cubicweb.selectors', DeprecationWarning, stacklevel=2) from cubicweb.selectors import * diff -r 544609e83317 -r 96752791c2b6 common/uilib.py --- a/common/uilib.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/uilib.py Mon Mar 23 17:55:59 2009 +0100 @@ -15,9 +15,7 @@ from datetime import datetime, date, timedelta from urllib import quote as urlquote from cStringIO import StringIO -from copy import deepcopy -from logilab.common.textutils import unormalize from logilab.mtconverter import html_escape, html_unescape from cubicweb.utils import ustrftime @@ -340,7 +338,7 @@ cell_12 = line[j+1] is not None cell_21 = line[j+1] is not None and line[j+1].next_sibling() is not None link_type = link_types.get((cell_11, cell_12, cell_21), 0) - if link_type == 0 and i > 0 and links[i-1][j] in (1,2,3): + if link_type == 0 and i > 0 and links[i-1][j] in (1, 2, 3): link_type = 2 links[-1].append(link_type) diff -r 544609e83317 -r 96752791c2b6 common/utils.py --- a/common/utils.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/utils.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,3 +1,5 @@ +"""pre 3.2 bw compat""" +# pylint: disable-msg=W0614,W0401 from warnings import warn warn('moved to cubicweb.utils', DeprecationWarning, stacklevel=2) from cubicweb.utils import * diff -r 544609e83317 -r 96752791c2b6 common/view.py --- a/common/view.py Mon Mar 23 17:38:30 2009 +0100 +++ b/common/view.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,3 +1,5 @@ +"""pre 3.2 bw compat""" +# pylint: disable-msg=W0614,W0401 from warnings import warn warn('moved to cubicweb.view', DeprecationWarning, stacklevel=2) from cubicweb.view import * diff -r 544609e83317 -r 96752791c2b6 cwconfig.py --- a/cwconfig.py Mon Mar 23 17:38:30 2009 +0100 +++ b/cwconfig.py Mon Mar 23 17:55:59 2009 +0100 @@ -18,7 +18,7 @@ ConfigurationMixIn, merge_options) from cubicweb import CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, ConfigurationError -from cubicweb.toolsutils import env_path, read_config, create_dir +from cubicweb.toolsutils import env_path, create_dir CONFIGURATIONS = [] diff -r 544609e83317 -r 96752791c2b6 cwctl.py --- a/cwctl.py Mon Mar 23 17:38:30 2009 +0100 +++ b/cwctl.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,10 +7,11 @@ from os import remove, listdir, system, kill, getpgid from os.path import exists, join, isfile, isdir +from logilab.common.clcommands import register_commands, pop_arg + from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage -from cubicweb.cwconfig import CubicWebConfiguration, CONFIGURATIONS -from cubicweb.toolsutils import (Command, register_commands, main_run, - rm, create_dir, pop_arg, confirm) +from cubicweb.cwconfig import CubicWebConfiguration as cwcfg, CONFIGURATIONS +from cubicweb.toolsutils import Command, main_run, rm, create_dir, confirm def wait_process_end(pid, maxtry=10, waittime=1): """wait for a process to actually die""" @@ -63,7 +64,7 @@ considering $REGISTRY_DIR/startorder file if it exists (useful when some instances depends on another as external source """ - regdir = CubicWebConfiguration.registry_dir() + regdir = cwcfg.registry_dir() _allinstances = list_instances(regdir) if isfile(join(regdir, 'startorder')): allinstances = [] @@ -74,7 +75,8 @@ _allinstances.remove(line) allinstances.append(line) except ValueError: - print 'ERROR: startorder file contains unexistant instance %s' % line + print ('ERROR: startorder file contains unexistant ' + 'instance %s' % line) allinstances += _allinstances else: allinstances = _allinstances @@ -161,8 +163,8 @@ """run the command with its specific arguments""" if args: raise BadCommandUsage('Too much arguments') - print 'CubicWeb version:', CubicWebConfiguration.cubicweb_version() - print 'Detected mode:', CubicWebConfiguration.mode + print 'CubicWeb version:', cwcfg.cubicweb_version() + print 'Detected mode:', cwcfg.mode print print 'Available configurations:' for config in CONFIGURATIONS: @@ -174,20 +176,20 @@ print ' ', line print try: - cubesdir = CubicWebConfiguration.cubes_dir() - namesize = max(len(x) for x in CubicWebConfiguration.available_cubes()) + cubesdir = cwcfg.cubes_dir() + namesize = max(len(x) for x in cwcfg.available_cubes()) except ConfigurationError, ex: print 'No cubes available:', ex except ValueError: print 'No cubes available in %s' % cubesdir else: print 'Available cubes (%s):' % cubesdir - for cube in CubicWebConfiguration.available_cubes(): + for cube in cwcfg.available_cubes(): if cube in ('CVS', '.svn', 'shared', '.hg'): continue templdir = join(cubesdir, cube) try: - tinfo = CubicWebConfiguration.cube_pkginfo(cube) + tinfo = cwcfg.cube_pkginfo(cube) tversion = tinfo.version except ConfigurationError: tinfo = None @@ -202,7 +204,7 @@ print ' available modes: %s' % ', '.join(modes) print try: - regdir = CubicWebConfiguration.registry_dir() + regdir = cwcfg.registry_dir() except ConfigurationError, ex: print 'No application available:', ex print @@ -211,13 +213,13 @@ if instances: print 'Available applications (%s):' % regdir for appid in instances: - modes = CubicWebConfiguration.possible_configurations(appid) + modes = cwcfg.possible_configurations(appid) if not modes: print '* %s (BROKEN application, no configuration found)' % appid continue print '* %s (%s)' % (appid, ', '.join(modes)) try: - config = CubicWebConfiguration.config_for(appid, modes[0]) + config = cwcfg.config_for(appid, modes[0]) except Exception, exc: print ' (BROKEN application, %s)' % exc continue @@ -268,19 +270,19 @@ cubes = get_csv(pop_arg(args, 1)) appid = pop_arg(args) # get the configuration and helper - CubicWebConfiguration.creating = True - config = CubicWebConfiguration.config_for(appid, configname) + cwcfg.creating = True + config = cwcfg.config_for(appid, configname) config.set_language = False config.init_cubes(config.expand_cubes(cubes)) helper = self.config_helper(config) # check the cube exists try: - templdirs = [CubicWebConfiguration.cube_dir(cube) + templdirs = [cwcfg.cube_dir(cube) for cube in cubes] except ConfigurationError, ex: print ex print '\navailable cubes:', - print ', '.join(CubicWebConfiguration.available_cubes()) + print ', '.join(cwcfg.available_cubes()) return # create the registry directory for this application create_dir(config.apphome) @@ -296,7 +298,6 @@ # write down configuration config.save() # handle i18n files structure - # XXX currently available languages are guessed from translations found # in the first cube given from cubicweb.common import i18n langs = [lang for lang, _ in i18n.available_catalogs(join(templdirs[0], 'i18n'))] @@ -336,8 +337,8 @@ def run(self, args): """run the command with its specific arguments""" appid = pop_arg(args, msg="No application specified !") - configs = [CubicWebConfiguration.config_for(appid, configname) - for configname in CubicWebConfiguration.possible_configurations(appid)] + configs = [cwcfg.config_for(appid, configname) + for configname in cwcfg.possible_configurations(appid)] if not configs: raise ExecutionError('unable to guess configuration for %s' % appid) for config in configs: @@ -390,7 +391,7 @@ # without all options defined debug = self.get('debug') force = self.get('force') - config = CubicWebConfiguration.config_for(appid) + config = cwcfg.config_for(appid) if self.get('profile'): config.global_set_option('profile', self.config.profile) helper = self.config_helper(config, cmdname='start') @@ -429,7 +430,7 @@ def stop_application(self, appid): """stop the application's server""" - config = CubicWebConfiguration.config_for(appid) + config = cwcfg.config_for(appid) helper = self.config_helper(config, cmdname='stop') helper.poststop() # do this anyway pidf = config['pid-file'] @@ -474,7 +475,7 @@ actionverb = 'restarted' def run_args(self, args, askconfirm): - regdir = CubicWebConfiguration.registry_dir() + regdir = cwcfg.registry_dir() if not isfile(join(regdir, 'startorder')) or len(args) <= 1: # no specific startorder super(RestartApplicationCommand, self).run_args(args, askconfirm) @@ -528,10 +529,11 @@ name = 'status' options = () - def status_application(self, appid): + @staticmethod + def status_application(appid): """print running status information for an application""" - for mode in CubicWebConfiguration.possible_configurations(appid): - config = CubicWebConfiguration.config_for(appid, mode) + for mode in cwcfg.possible_configurations(appid): + config = cwcfg.config_for(appid, mode) print '[%s-%s]' % (appid, mode), try: pidf = config['pid-file'] @@ -615,9 +617,9 @@ def upgrade_application(self, appid): from logilab.common.changelog import Version - if not (CubicWebConfiguration.mode == 'dev' or self.config.nostartstop): + if not (cwcfg.mode == 'dev' or self.config.nostartstop): self.stop_application(appid) - config = CubicWebConfiguration.config_for(appid) + config = cwcfg.config_for(appid) config.creating = True # notice we're not starting the server config.verbosity = self.config.verbosity config.set_sources_mode(self.config.ext_sources or ('migration',)) @@ -663,10 +665,9 @@ # handle i18n upgrade: # * install new languages # * recompile catalogs - # XXX currently available languages are guessed from translations found # in the first componant given from cubicweb.common import i18n - templdir = CubicWebConfiguration.cube_dir(config.cubes()[0]) + templdir = cwcfg.cube_dir(config.cubes()[0]) langs = [lang for lang, _ in i18n.available_catalogs(join(templdir, 'i18n'))] errors = config.i18ncompile(langs) if errors: @@ -679,7 +680,7 @@ mih.shutdown() print print 'application migrated' - if not (CubicWebConfiguration.mode == 'dev' or self.config.nostartstop): + if not (cwcfg.mode == 'dev' or self.config.nostartstop): self.start_application(appid) print @@ -715,7 +716,7 @@ ) def run(self, args): appid = pop_arg(args, 99, msg="No application specified !") - config = CubicWebConfiguration.config_for(appid) + config = cwcfg.config_for(appid) if self.config.ext_sources: assert not self.config.system_only sources = self.config.ext_sources @@ -740,10 +741,11 @@ given, recompile for all registered applications. """ name = 'i18ncompile' - - def i18ncompile_application(self, appid): + + @staticmethod + def i18ncompile_application(appid): """recompile application's messages catalogs""" - config = CubicWebConfiguration.config_for(appid) + config = cwcfg.config_for(appid) try: config.bootstrap_cubes() except IOError, ex: @@ -770,7 +772,7 @@ def run(self, args): """run the command with its specific arguments""" - regdir = CubicWebConfiguration.registry_dir() + regdir = cwcfg.registry_dir() for appid in sorted(listdir(regdir)): print appid @@ -782,7 +784,7 @@ def run(self, args): """run the command with its specific arguments""" - for cube in CubicWebConfiguration.available_cubes(): + for cube in cwcfg.available_cubes(): print cube register_commands((ListCommand, @@ -802,7 +804,7 @@ def run(args): """command line tool""" - CubicWebConfiguration.load_cwctl_plugins() + cwcfg.load_cwctl_plugins() main_run(args, __doc__) if __name__ == '__main__': diff -r 544609e83317 -r 96752791c2b6 cwvreg.py --- a/cwvreg.py Mon Mar 23 17:38:30 2009 +0100 +++ b/cwvreg.py Mon Mar 23 17:55:59 2009 +0100 @@ -6,8 +6,6 @@ """ __docformat__ = "restructuredtext en" -from warnings import warn - from logilab.common.decorators import cached, clear_cache from logilab.common.interface import extend @@ -19,6 +17,9 @@ _ = unicode def use_interfaces(obj): + """return interfaces used by the given object by searchinf for implements + selectors, with a bw compat fallback to accepts_interfaces attribute + """ from cubicweb.selectors import implements try: # XXX deprecated @@ -35,12 +36,6 @@ raise return () -def expand_parent_classes(iface): - res = [iface] - for parent in iface.__bases__: - res += expand_parent_classes(parent) - return res - class CubicWebRegistry(VRegistry): """extend the generic VRegistry with some cubicweb specific stuff""" @@ -59,7 +54,7 @@ if not item[0] in ('propertydefs', 'propertyvalues')] def values(self): - return [value for key,value in self._registries.items() + return [value for key, value in self._registries.items() if not key in ('propertydefs', 'propertyvalues')] def reset(self): @@ -106,8 +101,8 @@ def register(self, obj, **kwargs): if kwargs.get('registryname', obj.__registry__) == 'etypes': if obj.id != 'Any' and not obj.id in self.schema: - self.error('don\'t register %s, %s type not defined in the schema', - obj, obj.id) + self.error('don\'t register %s, %s type not defined in the ' + 'schema', obj, obj.id) return kwargs['clear'] = True super(CubicWebRegistry, self).register(obj, **kwargs) @@ -130,29 +125,18 @@ for classes in self.get('etypes', {}).values(): for cls in classes: for iface in cls.__implements__: - interfaces.update(expand_parent_classes(iface)) - interfaces.update(expand_parent_classes(cls)) + interfaces.update(iface.__mro__) + interfaces.update(expand_parent_classes(cls.__mro__)) for obj, ifaces in self._needs_iface.items(): - ifaces = frozenset(isinstance(iface, basestring) and iface in self.schema and self.etype_class(iface) or iface + ifaces = frozenset(isinstance(iface, basestring) + and iface in self.schema + and self.etype_class(iface) + or iface for iface in ifaces) if not ifaces & interfaces: self.debug('kicking vobject %s (unsupported interface)', obj) self.unregister(obj) - - - def eid_rset(self, cursor, eid, etype=None): - """return a result set for the given eid without doing actual query - (we have the eid, we can suppose it exists and user has access to the - entity) - """ - msg = '.eid_rset is deprecated, use req.eid_rset' - warn(msg, DeprecationWarning, stacklevel=2) - try: - return cursor.req.eid_rset(eid, etype) - except AttributeError: - # cursor is a session - return cursor.eid_rset(eid, etype) @cached def etype_class(self, etype): diff -r 544609e83317 -r 96752791c2b6 dbapi.py --- a/dbapi.py Mon Mar 23 17:38:30 2009 +0100 +++ b/dbapi.py Mon Mar 23 17:55:59 2009 +0100 @@ -5,12 +5,12 @@ (most parts of this document are reported here in docstrings) :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" -from logging import getLogger, StreamHandler +from logging import getLogger from time import time, clock from cubicweb import ConnectionError, RequestSessionMixIn, set_log_methods @@ -42,7 +42,7 @@ from cubicweb.server.repository import Repository return Repository(config, vreg=vreg) else: # method == 'pyro' - from Pyro import core, naming, config as pyroconfig + from Pyro import core, naming from Pyro.errors import NamingError, ProtocolError core.initClient(banner=0) nsid = ':%s.%s' % (config['pyro-ns-group'], database) @@ -54,7 +54,7 @@ except ProtocolError: raise ConnectionError('Could not connect to the Pyro name server ' '(host: %s:%i)' % (nshost, nsport)) - except NamingError, ex: + except NamingError: raise ConnectionError('Could not get repository for %s ' '(not registered in Pyro), ' 'you may have to restart your server-side ' @@ -358,11 +358,7 @@ def check(self): """raise `BadSessionId` if the connection is no more valid""" - try: - self._repo.check_session(self.sessionid) - except AttributeError: - # XXX backward compat for repository running cubicweb < 2.48.3 - self._repo.session_data(self.sessionid) + self._repo.check_session(self.sessionid) def get_shared_data(self, key, default=None, pop=False): """return value associated to `key` in shared data""" diff -r 544609e83317 -r 96752791c2b6 devtools/devctl.py --- a/devtools/devctl.py Mon Mar 23 17:38:30 2009 +0100 +++ b/devtools/devctl.py Mon Mar 23 17:55:59 2009 +0100 @@ -9,7 +9,7 @@ import sys from datetime import datetime -from os import walk, mkdir, chdir, listdir, getcwd +from os import mkdir, chdir, listdir from os.path import join, exists, abspath, basename, normpath, split, isdir diff -r 544609e83317 -r 96752791c2b6 devtools/htmlparser.py --- a/devtools/htmlparser.py Mon Mar 23 17:38:30 2009 +0100 +++ b/devtools/htmlparser.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,10 +1,8 @@ """defines a validating HTML parser used in web application tests""" import re -from StringIO import StringIO from lxml import etree -from lxml.builder import E from cubicweb.view import STRICT_DOCTYPE, TRANSITIONAL_DOCTYPE, CW_XHTML_EXTENSIONS @@ -55,20 +53,6 @@ for blockquote in blockquotes: parent = blockquote.getparent() parent.remove(blockquote) -## # for each blockquote, wrap unauthorized child in a div -## for blockquote in blockquotes: -## if len(blockquote): -## needs_wrap = [(index, child) for index, child in enumerate(blockquote) -## if child.tag not in expected] -## for index, child in needs_wrap: -## # the child is automatically popped from blockquote when -## # its parent is changed -## div = E.div(child) -## blockquote.insert(index, div) -## elif blockquote.text: -## div = E.div(blockquote.text) -## blockquote.text = None -## blockquote.append(div) data = etree.tostring(tree) return '%s\n%s' % (STRICT_DOCTYPE, data) diff -r 544609e83317 -r 96752791c2b6 devtools/repotest.py --- a/devtools/repotest.py Mon Mar 23 17:38:30 2009 +0100 +++ b/devtools/repotest.py Mon Mar 23 17:55:59 2009 +0100 @@ -217,10 +217,10 @@ variantes = _orig_build_variantes(self, newsolutions) sortedvariantes = [] for variante in variantes: - orderedkeys = sorted((k[1], k[2], v) for k,v in variante.iteritems()) + orderedkeys = sorted((k[1], k[2], v) for k, v in variante.iteritems()) variante = DumbOrderedDict(sorted(variante.iteritems(), - lambda a,b: cmp((a[0][1],a[0][2],a[1]), - (b[0][1],b[0][2],b[1])))) + lambda a, b: cmp((a[0][1],a[0][2],a[1]), + (b[0][1],b[0][2],b[1])))) sortedvariantes.append( (orderedkeys, variante) ) return [v for ok, v in sorted(sortedvariantes)] @@ -230,7 +230,7 @@ def _check_permissions(*args, **kwargs): res, restricted = _orig_check_permissions(*args, **kwargs) - res = DumbOrderedDict(sorted(res.iteritems(), lambda a,b: cmp(a[1], b[1]))) + res = DumbOrderedDict(sorted(res.iteritems(), lambda a, b: cmp(a[1], b[1]))) return res, restricted def _dummy_check_permissions(self, rqlst): diff -r 544609e83317 -r 96752791c2b6 devtools/testlib.py --- a/devtools/testlib.py Mon Mar 23 17:38:30 2009 +0100 +++ b/devtools/testlib.py Mon Mar 23 17:55:59 2009 +0100 @@ -13,8 +13,6 @@ from logilab.common.testlib import InnerTest from logilab.common.pytest import nocoverage -from rql import parse - from cubicweb.devtools import VIEW_VALIDATORS from cubicweb.devtools.apptest import EnvBasedTC from cubicweb.devtools._apptest import unprotected_entities, SYSTEM_RELATIONS @@ -24,8 +22,6 @@ from cubicweb.sobjects.notification import NotificationView from cubicweb.vregistry import NoSelectableObject -from cubicweb.web.action import Action -from cubicweb.web.views.basetemplates import TheMainTemplate ## TODO ############### @@ -149,7 +145,7 @@ if rschema.is_final() or rschema in ignored_relations: continue rset = cu.execute('DISTINCT Any X,Y WHERE X %s Y' % rschema) - existingrels.setdefault(rschema.type, set()).update((x,y) for x, y in rset) + existingrels.setdefault(rschema.type, set()).update((x, y) for x, y in rset) q = make_relations_queries(self.schema, edict, cu, ignored_relations, existingrels=existingrels) for rql, args in q: @@ -329,10 +325,6 @@ # resultset's syntax tree rset = backup_rset for action in self.list_actions_for(rset): - # XXX this seems a bit dummy - #yield InnerTest(self._testname(rset, action.id, 'action'), - # self.failUnless, - # isinstance(action, Action)) yield InnerTest(self._testname(rset, action.id, 'action'), action.url) for box in self.list_boxes_for(rset): yield InnerTest(self._testname(rset, box.id, 'box'), box.dispatch) diff -r 544609e83317 -r 96752791c2b6 entity.py --- a/entity.py Mon Mar 23 17:38:30 2009 +0100 +++ b/entity.py Mon Mar 23 17:55:59 2009 +0100 @@ -951,7 +951,7 @@ for rschema in self.e_schema.indexable_attributes(): try: value = self.printable_value(rschema, format='text/plain') - except TransformError, ex: + except TransformError: continue except: self.exception("can't add value of %s to text index for entity %s", diff -r 544609e83317 -r 96752791c2b6 etwist/server.py --- a/etwist/server.py Mon Mar 23 17:38:30 2009 +0100 +++ b/etwist/server.py Mon Mar 23 17:55:59 2009 +0100 @@ -360,7 +360,7 @@ acount += 1 else: try: - ocount[obj.__class__]+= 1 + ocount[obj.__class__] += 1 except KeyError: ocount[obj.__class__] = 1 except AttributeError: diff -r 544609e83317 -r 96752791c2b6 goa/dbmyams.py --- a/goa/dbmyams.py Mon Mar 23 17:38:30 2009 +0100 +++ b/goa/dbmyams.py Mon Mar 23 17:55:59 2009 +0100 @@ -13,12 +13,8 @@ from google.appengine.ext import db from google.appengine.api import datastore_types -from yams.schema2sql import eschema_attrs -from yams.constraints import SizeConstraint -from yams.reader import PyFileReader from yams.buildobjs import (String, Int, Float, Boolean, Date, Time, Datetime, - Interval, Password, Bytes, ObjectRelation, - SubjectRelation, RestrictedEntityType) + Bytes, SubjectRelation) from yams.buildobjs import metadefinition, EntityType from cubicweb.schema import CubicWebSchemaLoader diff -r 544609e83317 -r 96752791c2b6 goa/gaesource.py --- a/goa/gaesource.py Mon Mar 23 17:38:30 2009 +0100 +++ b/goa/gaesource.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,22 +1,19 @@ """Adapter for google appengine source. :organization: Logilab -:copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" -from logilab.common.decorators import cached, clear_cache - -from cubicweb import AuthenticationError, UnknownEid, server +from cubicweb import AuthenticationError, UnknownEid from cubicweb.server.sources import AbstractSource, ConnectionWrapper from cubicweb.server.pool import SingleOperation from cubicweb.server.utils import crypt_password from cubicweb.goa.dbinit import set_user_groups from cubicweb.goa.rqlinterpreter import RQLInterpreter -from google.appengine.api.datastore import Key, Entity, Get, Put, Delete -from google.appengine.api.datastore import Query +from google.appengine.api.datastore import Key, Entity, Put, Delete from google.appengine.api import datastore_errors, users def _init_groups(guser, euser): diff -r 544609e83317 -r 96752791c2b6 goa/goaconfig.py --- a/goa/goaconfig.py Mon Mar 23 17:38:30 2009 +0100 +++ b/goa/goaconfig.py Mon Mar 23 17:55:59 2009 +0100 @@ -11,7 +11,7 @@ from cubicweb import CW_SOFTWARE_ROOT from cubicweb.cwconfig import CubicWebConfiguration -from cubicweb.web.webconfig import WebConfiguration, merge_options, Method +from cubicweb.web.webconfig import WebConfiguration, merge_options from cubicweb.server.serverconfig import ServerConfiguration from cubicweb.goa.dbmyams import load_schema diff -r 544609e83317 -r 96752791c2b6 goa/goactl.py --- a/goa/goactl.py Mon Mar 23 17:38:30 2009 +0100 +++ b/goa/goactl.py Mon Mar 23 17:55:59 2009 +0100 @@ -6,16 +6,17 @@ """ __docformat__ = "restructuredtext en" -from os.path import exists, join, split, dirname, basename, normpath, abspath +from os.path import exists, join, split, basename, normpath, abspath + +from logilab.common.clcommands import register_commands from cubicweb import BadCommandUsage from cubicweb import CW_SOFTWARE_ROOT from cubicweb.toolsutils import (Command, register_commands, copy_skeleton, - create_dir, create_symlink, create_copy) + create_dir, create_symlink) from cubicweb.cwconfig import CubicWebConfiguration from logilab import common as lgc -from logilab.common.textutils import get_csv from logilab import constraint as lgcstr from logilab import mtconverter as lgmtc import rql, yams, yapps, simplejson, dateutil, vobject, docutils, roman @@ -213,8 +214,8 @@ packagesdir = join(appldir, 'cubes') create_init_file(join(appldir, 'cubes'), 'cubes') cubesdir = CubicWebConfiguration.cubes_dir() - for include in ('addressbook','basket', 'blog','classfolders', - 'classtags', 'comment', 'file', 'link', + for include in ('addressbook', 'basket', 'blog','folder', + 'tag', 'comment', 'file', 'link', 'mailinglist', 'person', 'task', 'zone', ): create_symlink(join(cubesdir, include), join(packagesdir, include)) diff -r 544609e83317 -r 96752791c2b6 goa/rqlinterpreter.py --- a/goa/rqlinterpreter.py Mon Mar 23 17:38:30 2009 +0100 +++ b/goa/rqlinterpreter.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,7 +1,7 @@ """provide a minimal RQL support for google appengine dbmodel :organization: Logilab -:copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -10,7 +10,6 @@ from datetime import datetime from rql import RQLHelper, nodes -from logilab.common.compat import any from cubicweb import Binary from cubicweb.rset import ResultSet diff -r 544609e83317 -r 96752791c2b6 goa/testlib.py --- a/goa/testlib.py Mon Mar 23 17:38:30 2009 +0100 +++ b/goa/testlib.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,4 +1,4 @@ -from logilab.common.testlib import TestCase, mock_object +from logilab.common.testlib import TestCase import os, os.path as osp import time @@ -15,7 +15,6 @@ from google.appengine.api import datastore_file_stub from google.appengine.ext import db as gdb from cubicweb.goa import db, do_monkey_patch - from cubicweb.goa.dbmyams import load_schema import_appengine_failed = None except ImportError, exc: raise @@ -34,8 +33,6 @@ import_appengine_failed = 'cannot import appengine: %s' % exc -from cubicweb import CW_SOFTWARE_ROOT -from cubicweb.server.utils import crypt_password from cubicweb.devtools.fake import FakeRequest from cubicweb.goa.goavreg import GAERegistry from cubicweb.goa.goaconfig import GAEConfiguration diff -r 544609e83317 -r 96752791c2b6 hercule.py --- a/hercule.py Mon Mar 23 17:38:30 2009 +0100 +++ b/hercule.py Mon Mar 23 17:55:59 2009 +0100 @@ -37,7 +37,7 @@ format_results(writer, layout, stream) finally: stream.close() - status = os.waitpid(pid, 0) + os.waitpid(pid, 0) def izip2(list1, list2): for i in xrange(len(list1)): diff -r 544609e83317 -r 96752791c2b6 md5crypt.py --- a/md5crypt.py Mon Mar 23 17:38:30 2009 +0100 +++ b/md5crypt.py Mon Mar 23 17:55:59 2009 +0100 @@ -53,7 +53,7 @@ def crypt(pw, salt, magic=None): - if magic==None: + if magic is None: magic = MAGIC # Take care of the magic string if present if salt[:len(magic)] == magic: @@ -63,7 +63,7 @@ salt = salt[:8] ctx = pw + magic + salt final = md5.md5(pw + salt + pw).digest() - for pl in range(len(pw),0,-16): + for pl in xrange(len(pw), 0, -16): if pl > 16: ctx = ctx + final[:16] else: @@ -80,7 +80,7 @@ # The following is supposed to make # things run slower. # my question: WTF??? - for i in range(1000): + for i in xrange(1000): ctx1 = '' if i & 1: ctx1 = ctx1 + pw diff -r 544609e83317 -r 96752791c2b6 rset.py --- a/rset.py Mon Mar 23 17:38:30 2009 +0100 +++ b/rset.py Mon Mar 23 17:55:59 2009 +0100 @@ -179,8 +179,7 @@ else: entities = sorted(enumerate(self), key=lambda (i, e): keyfunc(e), reverse=reverse) - - for index, entity in entities: + for index, _ in entities: rows.append(self.rows[index]) descr.append(self.description[index]) rset.rowcount = len(rows) @@ -210,7 +209,7 @@ for idx, line in enumerate(self): if col >= 0: try: - key = self.get_entity(idx,col) + key = self.get_entity(idx, col) except NotAnEntity: key = line[col] else: diff -r 544609e83317 -r 96752791c2b6 schema.py --- a/schema.py Mon Mar 23 17:38:30 2009 +0100 +++ b/schema.py Mon Mar 23 17:55:59 2009 +0100 @@ -101,7 +101,6 @@ @monkeypatch(ybo) def _add_relation(relations, rdef, name=None, insertidx=None): if isinstance(rdef, RichString): - default_format = rdef.default_format format_attrdef = ybo.String(meta=True, internationalizable=True, default=rdef.default_format, maxsize=50, constraints=rdef.format_constraints) diff -r 544609e83317 -r 96752791c2b6 schemaviewer.py --- a/schemaviewer.py Mon Mar 23 17:38:30 2009 +0100 +++ b/schemaviewer.py Mon Mar 23 17:55:59 2009 +0100 @@ -46,13 +46,12 @@ esection = Section(children=(Title(self.req._('Entities'), klass='titleUnderline'),)) layout.append(esection) - entities = [eschema for eschema in schema.entities() + eschemas = [eschema for eschema in schema.entities() if not eschema.is_final()] if skipmeta: - entities = [eschema for eschema in entities + eschemas = [eschema for eschema in eschemas if not eschema.meta] - keys = [(eschema.type, eschema) for eschema in entities] - for key, eschema in sorted(keys): + for eschema in sorted(eschema): esection.append(self.visit_entityschema(eschema, skiprels)) if display_relations: title = Title(self.req._('Relations'), klass='titleUnderline') diff -r 544609e83317 -r 96752791c2b6 selectors.py --- a/selectors.py Mon Mar 23 17:38:30 2009 +0100 +++ b/selectors.py Mon Mar 23 17:55:59 2009 +0100 @@ -53,7 +53,7 @@ from cubicweb import Unauthorized, NoSelectableObject, NotAnEntity, role from cubicweb.vregistry import (NoSelectableObject, Selector, - chainall, chainfirst, objectify_selector) + chainall, objectify_selector) from cubicweb.cwconfig import CubicWebConfiguration from cubicweb.schema import split_expression @@ -619,7 +619,7 @@ return int(self.target_etype in rschema.objects(eschema)) else: return int(self.target_etype in rschema.subjects(eschema)) - except KeyError, ex: + except KeyError: return 0 return 1 diff -r 544609e83317 -r 96752791c2b6 server/hookhelper.py --- a/server/hookhelper.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/hookhelper.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,7 +1,7 @@ """helper functions for application hooks :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -10,7 +10,7 @@ from threading import Lock from cubicweb import RepositoryError -from cubicweb.server.pool import Operation, SingleLastOperation +from cubicweb.server.pool import SingleLastOperation def entity_name(session, eid): diff -r 544609e83317 -r 96752791c2b6 server/hooks.py --- a/server/hooks.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/hooks.py Mon Mar 23 17:55:59 2009 +0100 @@ -84,7 +84,6 @@ FTIndexEntityOp(session, entity=session.entity(eidto)) elif ftcontainer == 'object': FTIndexEntityOp(session, entity=session.entity(eidfrom)) - def fti_update_after_delete_relation(session, eidfrom, rtype, eidto): """sync fulltext index when relevant relation is deleted. Reindexing both entities is necessary. diff -r 544609e83317 -r 96752791c2b6 server/msplanner.py --- a/server/msplanner.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/msplanner.py Mon Mar 23 17:55:59 2009 +0100 @@ -49,19 +49,18 @@ :organization: Logilab -:copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" -from copy import deepcopy from itertools import imap, ifilterfalse from logilab.common.compat import any from logilab.common.decorators import cached from rql.stmts import Union, Select -from rql.nodes import VariableRef, Comparison, Relation, Constant, Exists, Variable +from rql.nodes import VariableRef, Comparison, Relation, Constant, Variable from cubicweb import server from cubicweb.utils import make_uid @@ -1231,7 +1230,7 @@ return False if not same_scope(var): return False - if any(v for v,_ in var.stinfo['attrvars'] if not v.name in variables): + if any(v for v, _ in var.stinfo['attrvars'] if not v.name in variables): return False return True diff -r 544609e83317 -r 96752791c2b6 server/pool.py --- a/server/pool.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/pool.py Mon Mar 23 17:55:59 2009 +0100 @@ -11,7 +11,7 @@ :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" diff -r 544609e83317 -r 96752791c2b6 server/rqlannotation.py --- a/server/rqlannotation.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/rqlannotation.py Mon Mar 23 17:55:59 2009 +0100 @@ -2,18 +2,16 @@ code generation. :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" from logilab.common.compat import any -from rql.nodes import Relation, Exists, VariableRef, Constant, Variable, Or +from rql.nodes import Relation, VariableRef, Constant, Variable, Or from rql.utils import common_parent -from cubicweb import server - def _annotate_select(annotator, rqlst): for subquery in rqlst.with_: annotator._annotate_union(subquery.query) diff -r 544609e83317 -r 96752791c2b6 server/rqlrewrite.py --- a/server/rqlrewrite.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/rqlrewrite.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,7 +1,7 @@ """RQL rewriting utilities, used for read security checking :organization: Logilab -:copyright: 2007-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2007-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ @@ -25,7 +25,7 @@ except KeyError: pass break - except KeyError,ex: + except KeyError: # variable has been rewritten continue else: @@ -357,7 +357,7 @@ else: # target == 'subject': cardindex = 1 ttypes_func = rschema.subjects - rprop = lambda x,y,z: rschema.rproperty(y, x, z) + rprop = lambda x, y, z: rschema.rproperty(y, x, z) for etype in self.varstinfo['possibletypes']: for ttype in ttypes_func(etype): if rprop(etype, ttype, 'cardinality')[cardindex] in '+*': diff -r 544609e83317 -r 96752791c2b6 server/serverctl.py --- a/server/serverctl.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/serverctl.py Mon Mar 23 17:55:59 2009 +0100 @@ -9,10 +9,11 @@ import os from logilab.common.configuration import REQUIRED, Configuration, ini_format_section +from logilab.common.clcommands import register_commands, cmd_run, pop_arg from cubicweb import AuthenticationError, ExecutionError, ConfigurationError -from cubicweb.toolsutils import Command, CommandHandler, pop_arg, cmd_run, \ - register_commands, confirm, restrict_perms_to_user +from cubicweb.toolsutils import (Command, CommandHandler, confirm, + restrict_perms_to_user) from cubicweb.server.serverconfig import ServerConfiguration diff -r 544609e83317 -r 96752791c2b6 server/session.py --- a/server/session.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/session.py Mon Mar 23 17:55:59 2009 +0100 @@ -9,7 +9,6 @@ import sys import threading from time import time -from types import NoneType from rql.nodes import VariableRef, Function, ETYPE_PYOBJ_MAP, etype_from_pyobj from yams import BASE_TYPES @@ -550,7 +549,7 @@ return 'en' return None -_IMANAGER= InternalManager() +_IMANAGER = InternalManager() from logging import getLogger from cubicweb import set_log_methods diff -r 544609e83317 -r 96752791c2b6 server/sqlutils.py --- a/server/sqlutils.py Mon Mar 23 17:38:30 2009 +0100 +++ b/server/sqlutils.py Mon Mar 23 17:55:59 2009 +0100 @@ -19,7 +19,7 @@ from cubicweb import Binary, ConfigurationError from cubicweb.common.uilib import remove_html_tags from cubicweb.server import SQL_CONNECT_HOOKS -from cubicweb.server.utils import crypt_password, cartesian_product +from cubicweb.server.utils import crypt_password db.USE_MX_DATETIME = False diff -r 544609e83317 -r 96752791c2b6 toolsutils.py --- a/toolsutils.py Mon Mar 23 17:38:30 2009 +0100 +++ b/toolsutils.py Mon Mar 23 17:55:59 2009 +0100 @@ -1,7 +1,7 @@ """some utilities for cubicweb tools :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -11,7 +11,7 @@ from os.path import exists, join, abspath, normpath from logilab.common.clcommands import Command as BaseCommand, \ - main_run as base_main_run, register_commands, pop_arg, cmd_run + main_run as base_main_run from logilab.common.compat import any from cubicweb import warning diff -r 544609e83317 -r 96752791c2b6 utils.py --- a/utils.py Mon Mar 23 17:38:30 2009 +0100 +++ b/utils.py Mon Mar 23 17:55:59 2009 +0100 @@ -39,12 +39,11 @@ date as parameter, and returning True if the date should be included. """ - date = begin incr = timedelta(incr, 0, 0) - while date <= end: - if include is None or include(date): - yield date - date += incr + while begin <= end: + if include is None or include(begin): + yield begin + begin += incr def ustrftime(date, fmt='%Y-%m-%d'): """like strftime, but returns a unicode string instead of an encoded diff -r 544609e83317 -r 96752791c2b6 view.py --- a/view.py Mon Mar 23 17:38:30 2009 +0100 +++ b/view.py Mon Mar 23 17:55:59 2009 +0100 @@ -13,8 +13,7 @@ from logilab.mtconverter import html_escape from cubicweb import NotAnEntity, NoSelectableObject -from cubicweb.selectors import (yes, match_user_groups, non_final_entity, - nonempty_rset, none_rset) +from cubicweb.selectors import yes, non_final_entity, nonempty_rset, none_rset from cubicweb.selectors import require_group_compat, accepts_compat from cubicweb.appobject import AppRsetObject from cubicweb.utils import UStringIO, HTMLStream @@ -136,12 +135,12 @@ according to optional row and col parameters, which are locating a particular row or cell in the result set: - * if row [and col] are specified, `cell_call` is called + * if row is specified, `cell_call` is called * if none of them is supplied, the view is considered to apply on the whole result set (which may be None in this case), `call` is called """ - row, col = context.get('row'), context.get('col') + row = context.get('row') if row is not None: context.setdefault('col', 0) view_func = self.cell_call diff -r 544609e83317 -r 96752791c2b6 web/application.py --- a/web/application.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/application.py Mon Mar 23 17:55:59 2009 +0100 @@ -14,7 +14,6 @@ from cubicweb import set_log_methods from cubicweb import (ValidationError, Unauthorized, AuthenticationError, NoSelectableObject, RepositoryError) -from cubicweb.cwconfig import CubicWebConfiguration from cubicweb.cwvreg import CubicWebRegistry from cubicweb.web import (LOGGER, StatusResponse, DirectResponse, Redirect, NotFound, RemoteCallFailed, ExplicitLogin, InvalidSession) diff -r 544609e83317 -r 96752791c2b6 web/component.py --- a/web/component.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/component.py Mon Mar 23 17:55:59 2009 +0100 @@ -14,8 +14,8 @@ from cubicweb.view import View, Component from cubicweb.selectors import ( paginated_rset, one_line_rset, primary_view, match_context_prop, - partial_has_related_entities, partial_relation_possible, - condition_compat, accepts_compat, has_relation_compat) + partial_has_related_entities, condition_compat, accepts_compat, + has_relation_compat) from cubicweb.common.registerers import accepts_registerer _ = unicode diff -r 544609e83317 -r 96752791c2b6 web/facet.py --- a/web/facet.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/facet.py Mon Mar 23 17:55:59 2009 +0100 @@ -520,7 +520,7 @@ if not self.facet.start_unfolded: cssclass += ' hidden' if len(self.items) > 6: - cssclass +=' overflowed' + cssclass += ' overflowed' self.w(u'
\n' % cssclass) for item in self.items: item.render(self.w) diff -r 544609e83317 -r 96752791c2b6 web/form.py --- a/web/form.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/form.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,7 +7,6 @@ __docformat__ = "restructuredtext en" from warnings import warn -from datetime import date, datetime from simplejson import dumps @@ -17,10 +16,8 @@ from cubicweb import typed_eid from cubicweb.appobject import AppObject -from cubicweb.utils import ustrftime -from cubicweb.selectors import yes, match_form_params, non_final_entity -from cubicweb.view import NOINDEX, NOFOLLOW, View, EntityView, AnyRsetView -from cubicweb.schema import FormatConstraint +from cubicweb.selectors import yes, non_final_entity +from cubicweb.view import NOINDEX, NOFOLLOW, View from cubicweb.common import tags from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param, stdmsgs from cubicweb.web.httpcache import NoHTTPCacheManager diff -r 544609e83317 -r 96752791c2b6 web/views/actions.py --- a/web/views/actions.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/actions.py Mon Mar 23 17:55:59 2009 +0100 @@ -8,7 +8,7 @@ from cubicweb.vregistry import objectify_selector from cubicweb.selectors import ( - yes, one_line_rset, two_lines_rset, one_etype_rset, relation_possible, + one_line_rset, two_lines_rset, one_etype_rset, relation_possible, non_final_entity, authenticated_user, match_user_groups, match_search_state, has_editable_relation, has_permission, has_add_permission, diff -r 544609e83317 -r 96752791c2b6 web/views/ajaxedit.py --- a/web/views/ajaxedit.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/ajaxedit.py Mon Mar 23 17:55:59 2009 +0100 @@ -6,7 +6,7 @@ """ __docformat__ = "restructuredtext en" -from cubicweb.selectors import chainfirst, match_form_params, match_kwargs +from cubicweb.selectors import match_form_params, match_kwargs from cubicweb.web.box import EditRelationBoxTemplate class AddRelationView(EditRelationBoxTemplate): diff -r 544609e83317 -r 96752791c2b6 web/views/basecomponents.py --- a/web/views/basecomponents.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/basecomponents.py Mon Mar 23 17:55:59 2009 +0100 @@ -11,16 +11,12 @@ from rql import parse -from cubicweb import Unauthorized -from cubicweb.selectors import (yes, non_final_entity, one_line_rset, - chainfirst, two_etypes_rset, - match_form_params, relation_possible) +from cubicweb.selectors import yes, two_etypes_rset, match_form_params from cubicweb.common.uilib import html_escape, toggle_action from cubicweb.schema import display_name from cubicweb.web.htmlwidgets import MenuWidget, PopupBoxMenu, BoxSeparator, BoxLink -from cubicweb.web.component import (Component, EntityVComponent, - RelatedObjectsVComponent) +from cubicweb.web.component import Component, RelatedObjectsVComponent _ = unicode diff -r 544609e83317 -r 96752791c2b6 web/views/baseforms.py --- a/web/views/baseforms.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/baseforms.py Mon Mar 23 17:55:59 2009 +0100 @@ -14,13 +14,10 @@ from logilab.mtconverter import html_escape from logilab.common.decorators import cached -from cubicweb.selectors import (specified_etype_implements, implements, - match_kwargs, match_form_params, one_line_rset, - non_final_entity, accepts_etype_compat) -from cubicweb.utils import make_uid +from cubicweb.selectors import (specified_etype_implements, accepts_etype_compat, + non_final_entity, match_kwargs, one_line_rset) from cubicweb.view import View, EntityView -from cubicweb.common.uilib import cut -from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param +from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param from cubicweb.web.controller import NAV_FORM_PARAMETERS from cubicweb.web.widgets import checkbox, InputWidget, ComboBoxWidget from cubicweb.web.form import FormMixIn diff -r 544609e83317 -r 96752791c2b6 web/views/basetemplates.py --- a/web/views/basetemplates.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/basetemplates.py Mon Mar 23 17:55:59 2009 +0100 @@ -10,7 +10,6 @@ from logilab.mtconverter import html_escape -from cubicweb import NoSelectableObject, ObjectNotFound from cubicweb.vregistry import objectify_selector from cubicweb.selectors import match_kwargs from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW diff -r 544609e83317 -r 96752791c2b6 web/views/boxes.py --- a/web/views/boxes.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/boxes.py Mon Mar 23 17:55:59 2009 +0100 @@ -16,8 +16,7 @@ from logilab.mtconverter import html_escape -from cubicweb.selectors import (any_rset, appobject_selectable, - match_user_groups, non_final_entity) +from cubicweb.selectors import match_user_groups, non_final_entity from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem from cubicweb.view import EntityView from cubicweb.web.box import BoxTemplate diff -r 544609e83317 -r 96752791c2b6 web/views/calendar.py --- a/web/views/calendar.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/calendar.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,7 +7,7 @@ from datetime import datetime, date, timedelta -from vobject import iCalendar, icalendar +from vobject import iCalendar from logilab.mtconverter import html_escape @@ -155,9 +155,9 @@ users = [] task_max = 0 for row in xrange(self.rset.rowcount): - task = self.rset.get_entity(row,0) + task = self.rset.get_entity(row, 0) if len(self.rset[row]) > 1 and self.rset.description[row][1] == 'EUser': - user = self.rset.get_entity(row,1) + user = self.rset.get_entity(row, 1) else: user = None the_dates = [] @@ -183,15 +183,15 @@ for d in the_dates: d_tasks = dates.setdefault((d.year, d.month, d.day), {}) - t_users = d_tasks.setdefault(task,set()) + t_users = d_tasks.setdefault(task, set()) t_users.add( user ) - if len(d_tasks)>task_max: + if len(d_tasks) > task_max: task_max = len(d_tasks) days = [] - nrows = max(3,task_max) + nrows = max(3, task_max) # colors here are class names defined in cubicweb.css - colors = [ "col%x"%i for i in range(12) ] + colors = [ "col%x" % i for i in range(12) ] next_color_index = 0 visited_tasks = {} # holds a description of a task @@ -213,7 +213,7 @@ # to every 'new' task we must affect a color # (which must be the same for every user concerned # by the task) - for i,t in enumerate(rows): + for i, t in enumerate(rows): if t is None: if task in task_colors: color = task_colors[task] @@ -334,14 +334,13 @@ lastday = first_day_of_week + timedelta(6) firstday = first_day_of_week dates = [[] for i in range(7)] - task_max = 0 task_colors = {} # remember a color assigned to a task # colors here are class names defined in cubicweb.css - colors = [ "col%x"%i for i in range(12) ] + 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) + task = self.rset.get_entity(row, 0) if task in done_tasks: continue done_tasks.append(task) diff -r 544609e83317 -r 96752791c2b6 web/views/editforms.py --- a/web/views/editforms.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/editforms.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,25 +7,15 @@ """ __docformat__ = "restructuredtext en" -from copy import copy - from simplejson import dumps -from logilab.mtconverter import html_escape -from logilab.common.decorators import cached - -from cubicweb.selectors import (specified_etype_implements, implements, - match_kwargs, match_form_params, one_line_rset, - non_final_entity, accepts_etype_compat) +from cubicweb.selectors import match_kwargs, one_line_rset, non_final_entity from cubicweb.utils import make_uid -from cubicweb.view import View, EntityView +from cubicweb.view import EntityView from cubicweb.common import tags -from cubicweb.common.uilib import cut -from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param -from cubicweb.web.controller import NAV_FORM_PARAMETERS +from cubicweb.web import stdmsgs from cubicweb.web.form import MultipleFieldsForm, EntityFieldsForm, FormMixIn, FormRenderer -from cubicweb.web.formfields import StringField, RichTextField, guess_field -from cubicweb.web.formwidgets import HiddenInput +from cubicweb.web.formfields import guess_field _ = unicode diff -r 544609e83317 -r 96752791c2b6 web/views/embedding.py --- a/web/views/embedding.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/embedding.py Mon Mar 23 17:55:59 2009 +0100 @@ -157,7 +157,7 @@ req = Request(url, headers=(headers or {})) content = urlopen(req).read() page_source = unicode(content, guess_encoding(content), 'replace') - page_source =page_source + page_source = page_source match = BODY_RGX.search(page_source) if match is None: return page_source diff -r 544609e83317 -r 96752791c2b6 web/views/eproperties.py --- a/web/views/eproperties.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/eproperties.py Mon Mar 23 17:55:59 2009 +0100 @@ -12,10 +12,10 @@ from logilab.common.decorators import cached from cubicweb.selectors import (one_line_rset, none_rset, implements, - match_user_groups, chainfirst, chainall) + match_user_groups) from cubicweb.utils import UStringIO from cubicweb.view import StartupView -from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param, stdmsgs +from cubicweb.web import INTERNAL_FIELD_VALUE, eid_param from cubicweb.web.views import baseviews from cubicweb.web.form import FormMixIn diff -r 544609e83317 -r 96752791c2b6 web/views/facets.py --- a/web/views/facets.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/facets.py Mon Mar 23 17:55:59 2009 +0100 @@ -11,12 +11,11 @@ from logilab.mtconverter import html_escape from cubicweb.vregistry import objectify_selector -from cubicweb.selectors import (chainfirst, chainall, non_final_entity, - two_lines_rset, match_context_prop, - yes, relation_possible) +from cubicweb.selectors import (non_final_entity, two_lines_rset, + match_context_prop, yes, relation_possible) from cubicweb.web.box import BoxTemplate -from cubicweb.web.facet import (AbstractFacet, VocabularyFacet, FacetStringWidget, - RelationFacet, prepare_facets_rqlst, filter_hiddens) +from cubicweb.web.facet import (AbstractFacet, FacetStringWidget, RelationFacet, + prepare_facets_rqlst, filter_hiddens) @objectify_selector def contextview_selector(cls, req, rset, row=None, col=None, view=None, @@ -60,7 +59,7 @@ req.add_css('cubicweb.facets.css') if self.roundcorners: req.html_headers.add_onload('jQuery(".facet").corner("tl br 10px");') - rset, vid, divid, paginate=self._get_context(view) + rset, vid, divid, paginate = self._get_context(view) if rset.rowcount < 2: # XXX done by selectors, though maybe necessary when rset has been hijacked return if vid is None: diff -r 544609e83317 -r 96752791c2b6 web/views/iprogress.py --- a/web/views/iprogress.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/iprogress.py Mon Mar 23 17:55:59 2009 +0100 @@ -9,7 +9,7 @@ from logilab.mtconverter import html_escape -from cubicweb.selectors import implements, accept +from cubicweb.selectors import implements from cubicweb.interfaces import IProgress, IMileStone from cubicweb.schema import display_name from cubicweb.view import EntityView diff -r 544609e83317 -r 96752791c2b6 web/views/massmailing.py --- a/web/views/massmailing.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/massmailing.py Mon Mar 23 17:55:59 2009 +0100 @@ -8,8 +8,6 @@ import operator -from logilab.mtconverter import html_escape - from cubicweb.interfaces import IEmailable from cubicweb.selectors import implements, match_user_groups from cubicweb.view import EntityView diff -r 544609e83317 -r 96752791c2b6 web/views/plots.py --- a/web/views/plots.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/plots.py Mon Mar 23 17:55:59 2009 +0100 @@ -25,8 +25,7 @@ import sys if 'matplotlib.backends' not in sys.modules: matplotlib.use('Agg') - from matplotlib.ticker import FormatStrFormatter - from pylab import figure, show + from pylab import figure except ImportError: pass else: diff -r 544609e83317 -r 96752791c2b6 web/views/schema.py --- a/web/views/schema.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/schema.py Mon Mar 23 17:55:59 2009 +0100 @@ -9,10 +9,9 @@ from itertools import cycle from logilab.mtconverter import html_escape -from logilab.common.graph import escape, GraphGenerator, DotBackend from yams import schema2dot as s2d -from cubicweb.selectors import implements, rql_condition, yes +from cubicweb.selectors import implements, yes from cubicweb.schemaviewer import SchemaViewer from cubicweb.view import EntityView, StartupView from cubicweb.common.uilib import ureport_as_html @@ -135,7 +134,7 @@ # XXX remove this method once yams > 0.20 is out def node_properties(self, eschema): """return default DOT drawing options for an entity schema""" - label = ['{',eschema.type,'|'] + label = ['{', eschema.type, '|'] label.append(r'\l'.join(rel.type for rel in eschema.subject_relations() if rel.final and self.display_attr(rel))) label.append(r'\l}') # trailing \l ensure alignement of the last one diff -r 544609e83317 -r 96752791c2b6 web/views/startup.py --- a/web/views/startup.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/startup.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,10 +7,11 @@ """ __docformat__ = "restructuredtext en" +from logilab.common.textutils import unormalize from logilab.mtconverter import html_escape from cubicweb.view import StartupView -from cubicweb.common.uilib import ureport_as_html, unormalize, ajax_replace_url +from cubicweb.common.uilib import ureport_as_html, ajax_replace_url from cubicweb.web.httpcache import EtagHTTPCacheManager _ = unicode diff -r 544609e83317 -r 96752791c2b6 web/views/tableview.py --- a/web/views/tableview.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/tableview.py Mon Mar 23 17:55:59 2009 +0100 @@ -11,7 +11,7 @@ from logilab.mtconverter import html_escape -from cubicweb.selectors import nonempty_rset, match_form_params, accept_rset +from cubicweb.selectors import nonempty_rset, match_form_params from cubicweb.utils import make_uid from cubicweb.view import EntityView, AnyRsetView from cubicweb.common.uilib import toggle_action, limitsize, jsonize, htmlescape diff -r 544609e83317 -r 96752791c2b6 web/views/tabs.py --- a/web/views/tabs.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/tabs.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,15 +7,12 @@ __docformat__ = "restructuredtext en" -from logilab.common.decorators import monkeypatch from logilab.mtconverter import html_escape from cubicweb import NoSelectableObject, role from cubicweb.selectors import partial_has_related_entities -from cubicweb.utils import HTMLHead from cubicweb.view import EntityView -from cubicweb.common import uilib, tags -from cubicweb.web.views.basecontrollers import JSonController +from cubicweb.common import tags class LazyViewMixin(object): diff -r 544609e83317 -r 96752791c2b6 web/views/timetable.py --- a/web/views/timetable.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/timetable.py Mon Mar 23 17:55:59 2009 +0100 @@ -38,9 +38,9 @@ # XXX: try refactoring with calendar.py:OneMonthCal for row in xrange(self.rset.rowcount): - task = self.rset.get_entity(row,0) + task = self.rset.get_entity(row, 0) if len(self.rset[row])>1: - user = self.rset.get_entity(row,1) + user = self.rset.get_entity(row, 1) else: user = u"*" the_dates = [] @@ -55,9 +55,9 @@ the_dates.append(task.stop) for d in the_dates: d_users = dates.setdefault(d, {}) - u_tasks = d_users.setdefault(user,set()) + u_tasks = d_users.setdefault(user, set()) u_tasks.add( task ) - task_max = users_max.setdefault(user,0) + task_max = users_max.setdefault(user, 0) if len(u_tasks)>task_max: users_max[user] = len(u_tasks) if user not in users: @@ -71,7 +71,7 @@ rows = [] # colors here are class names defined in cubicweb.css - colors = [ "col%x"%i for i in range(12) ] + colors = ["col%x" % i for i in xrange(12)] next_color_index = 0 visited_tasks = {} # holds a description of a task for a user @@ -100,7 +100,7 @@ # (which must be the same for every user concerned # by the task) task, user = key - for i,t in enumerate(user_columns): + for i, t in enumerate(user_columns): if t is None: if task in task_colors: color = task_colors[task] @@ -128,16 +128,16 @@ self.w(u'') self.w(u'
\n') - def render_col_headers(self,users,widths): + def render_col_headers(self, users, widths): """ render column headers """ self.w(u'\n') self.w(u' \n') columns = [] - for user,width in zip(users,widths): - self.w(u'' % max(MIN_COLS,width)) - if user!=u"*": - user.view('secondary',w=self.w) + for user, width in zip(users, widths): + self.w(u'' % max(MIN_COLS, width)) + if user != u"*": + user.view('secondary', w=self.w) else: self.w(user) self.w(u'') @@ -164,7 +164,7 @@ previous_is_empty = False klass = "even" - if date.day_of_week in (5,6) and not empty_line: + if date.day_of_week in (5, 6) and not empty_line: klass = "odd" self.w(u'' % klass) odd = not odd diff -r 544609e83317 -r 96752791c2b6 web/views/urlrewrite.py --- a/web/views/urlrewrite.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/urlrewrite.py Mon Mar 23 17:55:59 2009 +0100 @@ -92,7 +92,6 @@ """for each `input`, `output `in rules, if `uri` matches `input`, req's form is updated with `output` """ - rset = None for data in self.rules: try: inputurl, infos, required_groups = data @@ -109,7 +108,7 @@ # XXX what about i18n ? (vtitle for instance) for param, value in infos.items(): if isinstance(value, basestring): - req.form[param]= inputurl.sub(value, uri) + req.form[param] = inputurl.sub(value, uri) else: req.form[param] = value break diff -r 544609e83317 -r 96752791c2b6 web/views/wdoc.py --- a/web/views/wdoc.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/wdoc.py Mon Mar 23 17:55:59 2009 +0100 @@ -205,9 +205,9 @@ w(unicode(line, encoding)) for entry in cl.entries: if entry.date: - date = strptime(entry.date, '%Y-%m-%d') + edate = strptime(entry.date, '%Y-%m-%d') else: - date = date.today() + edate = date.today() messages = [] for msglines, submsgs in entry.messages: msgstr = unicode(' '.join(l.strip() for l in msglines), encoding) @@ -216,15 +216,15 @@ msgstr += ' - ' + unicode(' '.join(l.strip() for l in submsglines), encoding) msgstr += u'\n' messages.append(msgstr) - entry = (date, messages) + entry = (edate, messages) allentries.insert(bisect_right(allentries, entry), entry) latestdate = None i = 0 - for date, messages in reversed(allentries): - if latestdate != date: - fdate = self.format_date(date) + for edate, messages in reversed(allentries): + if latestdate != edate: + fdate = self.format_date(edate) w(u'\n%s' % fdate) - w('~'*len(fdate)) + w('~' * len(fdate)) latestdate = date for msg in messages: w(u'* %s' % msg) diff -r 544609e83317 -r 96752791c2b6 web/views/workflow.py --- a/web/views/workflow.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/views/workflow.py Mon Mar 23 17:55:59 2009 +0100 @@ -45,7 +45,6 @@ def cell_call(self, row, col): entity = self.entity(row, col) - eid = entity.eid state = entity.in_state[0] transition = self.req.eid_rset(self.req.form['treid']).get_entity(0, 0) dest = transition.destination() diff -r 544609e83317 -r 96752791c2b6 web/webconfig.py --- a/web/webconfig.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/webconfig.py Mon Mar 23 17:55:59 2009 +0100 @@ -7,8 +7,7 @@ __docformat__ = "restructuredtext en" import os -from os.path import join, dirname, exists, split -from urlparse import urljoin +from os.path import join, exists, split from logilab.common.configuration import Method from logilab.common.decorators import cached diff -r 544609e83317 -r 96752791c2b6 web/webctl.py --- a/web/webctl.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/webctl.py Mon Mar 23 17:55:59 2009 +0100 @@ -23,8 +23,8 @@ print '-' * 72 config.input_config('pyro-client', inputlevel) if confirm('allow anonymous access', False): - config.global_set_option('anonymous-user', 'anon') - config.global_set_option('anonymous-password', 'anon') + config.global_set_option('anonymous-user', 'anon') + config.global_set_option('anonymous-password', 'anon') def postcreate(self): """hooks called once application's initialization has been completed""" diff -r 544609e83317 -r 96752791c2b6 web/widgets.py --- a/web/widgets.py Mon Mar 23 17:38:30 2009 +0100 +++ b/web/widgets.py Mon Mar 23 17:55:59 2009 +0100 @@ -9,7 +9,6 @@ """ __docformat__ = "restructuredtext en" -from simplejson import dumps from datetime import datetime from logilab.mtconverter import html_escape