[toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Python 3K will only expose iterators.
http://docs.python.org/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists
--- a/__init__.py Thu Feb 14 15:38:25 2013 +0100
+++ b/__init__.py Thu Feb 14 16:01:24 2013 +0100
@@ -215,7 +215,7 @@
# set empty dict else translation won't be done for backward
# compatibility reason (see ValidationError.translate method)
substitutions = {}
- for key in errors.keys():
+ for key in list(errors):
if isinstance(key, tuple):
errors[rname(*key)] = errors.pop(key)
return ValidationError(getattr(entity, 'eid', entity), errors,
--- a/cwvreg.py Thu Feb 14 15:38:25 2013 +0100
+++ b/cwvreg.py Thu Feb 14 16:01:24 2013 +0100
@@ -91,7 +91,7 @@
# web/views/basecomponents.py
def registration_callback(vreg):
# register everything in the module except SeeAlsoComponent
- vreg.register_all(globals().values(), __name__, (SeeAlsoVComponent,))
+ vreg.register_all(globals().itervalues(), __name__, (SeeAlsoVComponent,))
# conditionally register SeeAlsoVComponent
if 'see_also' in vreg.schema:
vreg.register(SeeAlsoVComponent)
@@ -624,7 +624,7 @@
"""
self.schema = schema
for registry, regcontent in self.items():
- for objects in regcontent.values():
+ for objects in regcontent.itervalues():
for obj in objects:
obj.schema = schema
@@ -725,7 +725,7 @@
self.unregister(obj)
super(CWRegistryStore, self).initialization_completed()
if 'uicfg' in self: # 'uicfg' is not loaded in a pure repository mode
- for rtags in self['uicfg'].values():
+ for rtags in self['uicfg'].itervalues():
for rtag in rtags:
# don't check rtags if we don't want to cleanup_interface_sobjects
rtag.init(self.schema, check=self.config.cleanup_interface_sobjects)
--- a/dataimport.py Thu Feb 14 15:38:25 2013 +0100
+++ b/dataimport.py Thu Feb 14 16:01:24 2013 +0100
@@ -393,7 +393,7 @@
if isinstance(data[0], (tuple, list)):
columns = None
else:
- columns = data[0].keys()
+ columns = list(data[0])
execmany_func(cu, statement, data, table, columns, encoding)
except Exception:
print 'unable to copy data into table %s', table
@@ -755,7 +755,7 @@
self.tell(pformat(sorted(error[1])))
def _print_stats(self):
- nberrors = sum(len(err) for err in self.errors.values())
+ nberrors = sum(len(err) for err in self.errors.itervalues())
self.tell('\nImport statistics: %i entities, %i types, %i relations and %i errors'
% (self.store.nb_inserted_entities,
self.store.nb_inserted_types,
@@ -1056,7 +1056,7 @@
# for a given inlined relation,
# browse each couple to be inserted
for data in datalist:
- keys = data.keys()
+ keys = list(data)
# For inlined relations, it exists only two case:
# (rtype, cw_eid) or (cw_eid, rtype)
if keys[0] == 'cw_eid':
--- a/devtools/devctl.py Thu Feb 14 15:38:25 2013 +0100
+++ b/devtools/devctl.py Thu Feb 14 16:01:24 2013 +0100
@@ -251,7 +251,7 @@
for reg, objdict in vreg.items():
if reg in ('boxes', 'contentnavigation'):
continue
- for objects in objdict.values():
+ for objects in objdict.itervalues():
for obj in objects:
objid = '%s_%s' % (reg, obj.__regid__)
if objid in done:
--- a/devtools/testlib.py Thu Feb 14 15:38:25 2013 +0100
+++ b/devtools/testlib.py Thu Feb 14 16:01:24 2013 +0100
@@ -1206,7 +1206,7 @@
# # XXX broken
# from cubicweb.devtools.apptest import TestEnvironment
# env = testclass._env = TestEnvironment('data', configcls=testclass.configcls)
-# for reg in env.vreg.values():
+# for reg in env.vreg.itervalues():
# reg._selected = {}
# try:
# orig_select_best = reg.__class__.__orig_select_best
--- a/entities/test/unittest_wfobjs.py Thu Feb 14 15:38:25 2013 +0100
+++ b/entities/test/unittest_wfobjs.py Thu Feb 14 16:01:24 2013 +0100
@@ -96,7 +96,7 @@
def setup_database(self):
req = self.request()
rschema = self.schema['in_state']
- for rdef in rschema.rdefs.values():
+ for rdef in rschema.rdefs.itervalues():
self.assertEqual(rdef.cardinality, '1*')
self.member = self.create_user(req, 'member')
--- a/entity.py Thu Feb 14 15:38:25 2013 +0100
+++ b/entity.py Thu Feb 14 16:01:24 2013 +0100
@@ -553,7 +553,7 @@
def __repr__(self):
return '<Entity %s %s %s at %s>' % (
- self.e_schema, self.eid, self.cw_attr_cache.keys(), id(self))
+ self.e_schema, self.eid, list(self.cw_attr_cache), id(self))
def __cmp__(self, other):
raise NotImplementedError('comparison not implemented for %s' % self.__class__)
--- a/hooks/syncschema.py Thu Feb 14 15:38:25 2013 +0100
+++ b/hooks/syncschema.py Thu Feb 14 16:01:24 2013 +0100
@@ -219,7 +219,7 @@
repo.set_schema(repo.schema, rebuildinfered=rebuildinfered)
# CWUser class might have changed, update current session users
cwuser_cls = self.session.vreg['etypes'].etype_class('CWUser')
- for session in repo._sessions.values():
+ for session in repo._sessions.itervalues():
session.user.__class__ = cwuser_cls
except Exception:
self.critical('error while setting schema', exc_info=True)
--- a/hooks/syncsession.py Thu Feb 14 15:38:25 2013 +0100
+++ b/hooks/syncsession.py Thu Feb 14 16:01:24 2013 +0100
@@ -26,7 +26,7 @@
def get_user_sessions(repo, ueid):
- for session in repo._sessions.values():
+ for session in repo._sessions.itervalues():
if ueid == session.user.eid:
yield session
--- a/misc/migration/3.11.0_Any.py Thu Feb 14 15:38:25 2013 +0100
+++ b/misc/migration/3.11.0_Any.py Thu Feb 14 16:01:24 2013 +0100
@@ -46,7 +46,7 @@
'%s relation should not be in support_relations' % rtype
return mapping
# for now, only pyrorql sources have a mapping
- for source in repo.sources_by_uri.values():
+ for source in repo.sources_by_uri.itervalues():
if not isinstance(source, PyroRQLSource):
continue
sourceentity = session.entity_from_eid(source.eid)
--- a/misc/migration/bootstrapmigration_repository.py Thu Feb 14 15:38:25 2013 +0100
+++ b/misc/migration/bootstrapmigration_repository.py Thu Feb 14 16:01:24 2013 +0100
@@ -76,7 +76,7 @@
with hooks_control(session, session.HOOKS_ALLOW_ALL, 'integrity'):
for rschema in repo.schema.relations():
rpermsdict = permsdict.get(rschema.eid, {})
- for rdef in rschema.rdefs.values():
+ for rdef in rschema.rdefs.itervalues():
for action in rdef.ACTIONS:
actperms = []
for something in rpermsdict.get(action == 'update' and 'add' or action, ()):
--- a/misc/scripts/pyroforge2datafeed.py Thu Feb 14 15:38:25 2013 +0100
+++ b/misc/scripts/pyroforge2datafeed.py Thu Feb 14 16:01:24 2013 +0100
@@ -74,7 +74,7 @@
# only cleanup entities table, remaining stuff should be cleaned by a c-c
# db-check to be run after this script
-for entities in todelete.values():
+for entities in todelete.itervalues():
system_source.delete_info_multi(session, entities, source_name)
@@ -87,7 +87,7 @@
if schemaent.__regid__ != 'CWEType':
assert schemaent.__regid__ == 'CWRType'
sch = schema._eid_index[schemaent.eid]
- for rdef in sch.rdefs.values():
+ for rdef in sch.rdefs.itervalues():
if not source.support_entity(rdef.subject) \
or not source.support_entity(rdef.object):
continue
--- a/pylintext.py Thu Feb 14 15:38:25 2013 +0100
+++ b/pylintext.py Thu Feb 14 16:01:24 2013 +0100
@@ -17,7 +17,7 @@
def cubicweb_transform(module):
# handle objectify_predicate decorator (and its former name until bw compat
# is kept). Only look at module level functions, should be enough.
- for assnodes in module.locals.values():
+ for assnodes in module.locals.itervalues():
for node in assnodes:
if isinstance(node, scoped_nodes.Function) and node.decorators:
for decorator in node.decorators.nodes:
--- a/server/checkintegrity.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/checkintegrity.py Thu Feb 14 16:01:24 2013 +0100
@@ -317,7 +317,7 @@
continue
smandatory = set()
omandatory = set()
- for rdef in rschema.rdefs.values():
+ for rdef in rschema.rdefs.itervalues():
if rdef.cardinality[0] in '1+':
smandatory.add(rdef.subject)
if rdef.cardinality[1] in '1+':
@@ -345,7 +345,7 @@
for rschema in schema.relations():
if not rschema.final or rschema in VIRTUAL_RTYPES:
continue
- for rdef in rschema.rdefs.values():
+ for rdef in rschema.rdefs.itervalues():
if rdef.cardinality[0] in '1+':
rql = 'Any X WHERE X %s NULL, X is %s, X cw_source S, S name "system"' % (
rschema, rdef.subject)
--- a/server/migractions.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/migractions.py Thu Feb 14 16:01:24 2013 +0100
@@ -457,7 +457,7 @@
{'x': expreid}, ask_confirm=False)
else:
newexprs.pop(expression)
- for expression in newexprs.values():
+ for expression in newexprs.itervalues():
expr = expression.expression
if not confirm or self.confirm('Add %s expression for %s permission of %s?'
% (expr, action, erschema)):
--- a/server/msplanner.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/msplanner.py Thu Feb 14 16:01:24 2013 +0100
@@ -1075,7 +1075,7 @@
"""return all sources supporting given term / solindices"""
sources = [selected_source]
sourcesterms = self._sourcesterms
- for source in sourcesterms.keys():
+ for source in list(sourcesterms):
if source is selected_source:
continue
if not (term in sourcesterms[source] and
@@ -1099,9 +1099,9 @@
# term has to belong to the same scope if there is more
# than the system source remaining
if len(sourcesterms) > 1 and not scope is self.rqlst:
- candidates = (t for t in sourceterms.keys() if scope is ms_scope(t))
+ candidates = (t for t in sourceterms if scope is ms_scope(t))
else:
- candidates = sourceterms #.iterkeys()
+ candidates = sourceterms
# we only want one unlinked term in each generated query
candidates = [t for t in candidates
if isinstance(t, (Constant, Relation)) or
--- a/server/pool.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/pool.py Thu Feb 14 16:01:24 2013 +0100
@@ -63,13 +63,13 @@
# FIXME: what happends if a commit fail
# would need a two phases commit or like, but I don't know how to do
# this using the db-api...
- for source, cnx in self.source_cnxs.values():
+ for source, cnx in self.source_cnxs.itervalues():
# let exception propagates
cnx.commit()
def rollback(self):
"""rollback the current transaction for this user"""
- for source, cnx in self.source_cnxs.values():
+ for source, cnx in self.source_cnxs.itervalues():
# catch exceptions, rollback other sources anyway
try:
cnx.rollback()
@@ -83,12 +83,12 @@
"""close all connections in the set"""
if i_know_what_i_do is not True: # unexpected closing safety belt
raise RuntimeError('connections set shouldn\'t be closed')
- for cu in self._cursors.values():
+ for cu in self._cursors.itervalues():
try:
cu.close()
except Exception:
continue
- for _, cnx in self.source_cnxs.values():
+ for _, cnx in self.source_cnxs.itervalues():
try:
cnx.close()
except Exception:
@@ -102,7 +102,7 @@
def cnxset_freed(self):
"""connections set is being freed from a session"""
- for source, cnx in self.source_cnxs.values():
+ for source, cnx in self.source_cnxs.itervalues():
source.cnxset_freed(cnx)
def sources(self):
@@ -114,7 +114,7 @@
if uri == 'system':
continue
yield source
- #return [source_cnx[0] for source_cnx in self.source_cnxs.values()]
+ #return [source_cnx[0] for source_cnx in self.source_cnxs.itervalues()]
def source(self, uid):
"""return the source object with the given uri"""
--- a/server/querier.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/querier.py Thu Feb 14 16:01:24 2013 +0100
@@ -530,7 +530,7 @@
def relation_defs(self):
"""return the list for relation definitions to insert"""
- for rdefs in self._expanded_r_defs.values():
+ for rdefs in self._expanded_r_defs.itervalues():
for rdef in rdefs:
yield rdef
for rdef in self.r_defs:
--- a/server/repository.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/repository.py Thu Feb 14 16:01:24 2013 +0100
@@ -123,7 +123,7 @@
relations = []
activeintegrity = session.is_hook_category_activated('activeintegrity')
eschema = entity.e_schema
- for attr in entity.cw_edited.iterkeys():
+ for attr in entity.cw_edited:
rschema = eschema.subjrels[attr]
if not rschema.final: # inlined relation
value = entity.cw_edited[attr]
@@ -201,7 +201,7 @@
# changed. To any existing user object have a different class than
# the new loaded one. We are hot fixing this.
usercls = self.vreg['etypes'].etype_class('CWUser')
- for session in self._sessions.values():
+ for session in self._sessions.itervalues():
if not isinstance(session.user, InternalManager):
session.user.__class__ = usercls
@@ -327,7 +327,7 @@
self.querier.set_schema(schema)
# don't use self.sources, we may want to give schema even to disabled
# sources
- for source in self.sources_by_uri.values():
+ for source in self.sources_by_uri.itervalues():
source.set_schema(schema)
self.schema = schema
@@ -415,7 +415,7 @@
# XXX: session.cnxset is accessed from a local storage, would be interesting
# to see if there is a cnxset set in any thread specific data)
return '%s: %s (%s)' % (self._cnxsets_pool.qsize(),
- ','.join(session.user.login for session in self._sessions.values()
+ ','.join(session.user.login for session in self._sessions.itervalues()
if session.cnxset),
threading.currentThread())
def shutdown(self):
@@ -729,7 +729,7 @@
for rschema, _eschema in cwuser.attribute_definitions()
if not rschema.meta)
cwuserattrs = self._cwuser_attrs
- for k in chain(fetch_attrs, query_attrs.iterkeys()):
+ for k in chain(fetch_attrs, query_attrs):
if k not in cwuserattrs:
raise Exception('bad input for find_user')
with self.internal_session() as session:
@@ -738,7 +738,7 @@
rql = 'Any %s WHERE X is CWUser, ' % ','.join(var[1] for var in vars)
rql += ','.join('X %s %s' % (var[0], var[1]) for var in vars) + ','
rset = session.execute(rql + ','.join('X %s %%(%s)s' % (attr, attr)
- for attr in query_attrs.iterkeys()),
+ for attr in query_attrs),
query_attrs)
return rset.rows
@@ -962,7 +962,7 @@
def close_sessions(self):
"""close every opened sessions"""
- for sessionid in self._sessions.keys():
+ for sessionid in self._sessions:
try:
self.close(sessionid, checkshuttingdown=False)
except Exception: # XXX BaseException?
@@ -976,7 +976,7 @@
self.debug('cleaning session unused since %s',
strftime('%T', localtime(mintime)))
nbclosed = 0
- for session in self._sessions.values():
+ for session in self._sessions.itervalues():
if session.timestamp < mintime:
self.close(session.id)
nbclosed += 1
--- a/server/sources/__init__.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/sources/__init__.py Thu Feb 14 16:01:24 2013 +0100
@@ -187,7 +187,7 @@
except KeyError:
pass
# check for unknown options
- if confdict and not confdict.keys() == ['adapter']:
+ if confdict and tuple(confdict) != ('adapter',):
if fail_if_unknown:
msg = _('unknown options %s') % ', '.join(confdict)
raise ValidationError(eid, {role_name('config', 'subject'): msg})
@@ -242,7 +242,7 @@
"""remove sensitive information such as login / password from source
definition
"""
- for key in sourcedef.keys():
+ for key in list(sourcedef):
if not key in self.PUBLIC_KEYS:
sourcedef.pop(key)
--- a/server/sources/remoterql.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/sources/remoterql.py Thu Feb 14 16:01:24 2013 +0100
@@ -247,11 +247,10 @@
# fake connection wrapper returned when we can't connect to the
# external source (hence we've no chance to synchronize...)
return
- etypes = self.support_entities.keys()
+ etypes = list(self.support_entities)
if mtime is None:
mtime = self.latest_retrieval
- updatetime, modified, deleted = extrepo.entities_modified_since(
- etypes, mtime)
+ updatetime, modified, deleted = extrepo.entities_modified_since(etypes, mtime)
self._query_cache.clear()
repo = self.repo
session = repo.internal_session()
--- a/server/test/unittest_datafeed.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/test/unittest_datafeed.py Thu Feb 14 16:01:24 2013 +0100
@@ -53,7 +53,7 @@
stats = dfsource.pull_data(session, force=True)
self.commit()
# test import stats
- self.assertEqual(sorted(stats.keys()), ['checked', 'created', 'updated'])
+ self.assertEqual(sorted(stats), ['checked', 'created', 'updated'])
self.assertEqual(len(stats['created']), 1)
entity = self.execute('Card X').get_entity(0, 0)
self.assertIn(entity.eid, stats['created'])
--- a/server/test/unittest_migractions.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/test/unittest_migractions.py Thu Feb 14 16:01:24 2013 +0100
@@ -472,7 +472,7 @@
def test_add_remove_cube_and_deps(self):
cubes = set(self.config.cubes())
schema = self.repo.schema
- self.assertEqual(sorted((str(s), str(o)) for s, o in schema['see_also'].rdefs.keys()),
+ self.assertEqual(sorted((str(s), str(o)) for s, o in schema['see_also'].rdefs.iterkeys()),
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'),
('Bookmark', 'Bookmark'), ('Bookmark', 'Note'),
('Note', 'Note'), ('Note', 'Bookmark')]))
@@ -487,7 +487,7 @@
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File',
'sender', 'in_thread', 'reply_to', 'data_format'):
self.assertFalse(ertype in schema, ertype)
- self.assertEqual(sorted(schema['see_also'].rdefs.keys()),
+ self.assertEqual(sorted(schema['see_also'].rdefs.iterkeys()),
sorted([('Folder', 'Folder'),
('Bookmark', 'Bookmark'),
('Bookmark', 'Note'),
@@ -510,7 +510,7 @@
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File',
'sender', 'in_thread', 'reply_to', 'data_format'):
self.assertTrue(ertype in schema, ertype)
- self.assertEqual(sorted(schema['see_also'].rdefs.keys()),
+ self.assertEqual(sorted(schema['see_also'].rdefs.iterkeys()),
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'),
('Bookmark', 'Bookmark'),
('Bookmark', 'Note'),
--- a/server/test/unittest_msplanner.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/test/unittest_msplanner.py Thu Feb 14 16:01:24 2013 +0100
@@ -149,7 +149,7 @@
plan.preprocess(union)
ppi = PartPlanInformation(plan, union.children[0])
for sourcevars in ppi._sourcesterms.itervalues():
- for var in sourcevars.keys():
+ for var in list(sourcevars):
solindices = sourcevars.pop(var)
sourcevars[var._ms_table_key()] = solindices
self.assertEqual(ppi._sourcesterms, sourcesterms)
--- a/server/utils.py Thu Feb 14 15:38:25 2013 +0100
+++ b/server/utils.py Thu Feb 14 16:01:24 2013 +0100
@@ -93,7 +93,7 @@
def cleanup_solutions(rqlst, solutions):
for sol in solutions:
- for vname in sol.keys():
+ for vname in list(sol):
if not (vname in rqlst.defined_vars or vname in rqlst.aliases):
del sol[vname]
--- a/sobjects/__init__.py Thu Feb 14 15:38:25 2013 +0100
+++ b/sobjects/__init__.py Thu Feb 14 16:01:24 2013 +0100
@@ -20,7 +20,7 @@
import os.path as osp
def registration_callback(vreg):
- vreg.register_all(globals().values(), __name__)
+ vreg.register_all(globals().itervalues(), __name__)
global URL_MAPPING
URL_MAPPING = {}
if vreg.config.apphome:
--- a/sobjects/test/unittest_cwxmlparser.py Thu Feb 14 15:38:25 2013 +0100
+++ b/sobjects/test/unittest_cwxmlparser.py Thu Feb 14 16:01:24 2013 +0100
@@ -194,7 +194,7 @@
})
session = self.repo.internal_session(safe=True)
stats = dfsource.pull_data(session, force=True, raise_on_error=True)
- self.assertEqual(sorted(stats.keys()), ['checked', 'created', 'updated'])
+ self.assertEqual(sorted(stats), ['checked', 'created', 'updated'])
self.assertEqual(len(stats['created']), 2)
self.assertEqual(stats['updated'], set())
--- a/test/unittest_entity.py Thu Feb 14 15:38:25 2013 +0100
+++ b/test/unittest_entity.py Thu Feb 14 16:01:24 2013 +0100
@@ -127,11 +127,11 @@
self.assertEqual(user._cw_related_cache, {})
email = user.primary_email[0]
self.assertEqual(sorted(user._cw_related_cache), ['primary_email_subject'])
- self.assertEqual(email._cw_related_cache.keys(), ['primary_email_object'])
+ self.assertEqual(list(email._cw_related_cache), ['primary_email_object'])
groups = user.in_group
self.assertEqual(sorted(user._cw_related_cache), ['in_group_subject', 'primary_email_subject'])
for group in groups:
- self.assertFalse('in_group_subject' in group._cw_related_cache, group._cw_related_cache.keys())
+ self.assertFalse('in_group_subject' in group._cw_related_cache, list(group._cw_related_cache))
def test_related_limit(self):
req = self.request()
--- a/testfunc/test/windmill/test_connexion.py Thu Feb 14 15:38:25 2013 +0100
+++ b/testfunc/test/windmill/test_connexion.py Thu Feb 14 16:01:24 2013 +0100
@@ -1,5 +1,5 @@
from cubicweb.devtools import DEFAULT_SOURCES
-LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].values()
+LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
--- a/testfunc/test/windmill/test_creation.py Thu Feb 14 15:38:25 2013 +0100
+++ b/testfunc/test/windmill/test_creation.py Thu Feb 14 16:01:24 2013 +0100
@@ -1,5 +1,5 @@
from cubicweb.devtools import DEFAULT_SOURCES
-LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].values()
+LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
--- a/testfunc/test/windmill/test_edit_relation.py Thu Feb 14 15:38:25 2013 +0100
+++ b/testfunc/test/windmill/test_edit_relation.py Thu Feb 14 16:01:24 2013 +0100
@@ -1,5 +1,5 @@
from cubicweb.devtools import DEFAULT_SOURCES
-LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].values()
+LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
--- a/web/application.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/application.py Thu Feb 14 16:01:24 2013 +0100
@@ -425,7 +425,7 @@
"""
# don't log form values they may contains sensitive information
self.debug('publish "%s" (%s, form params: %s)',
- path, req.session.sessionid, req.form.keys())
+ path, req.session.sessionid, list(req.form))
# remove user callbacks on a new request (except for json controllers
# to avoid callbacks being unregistered before they could be called)
tstart = clock()
--- a/web/controller.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/controller.py Thu Feb 14 16:01:24 2013 +0100
@@ -152,7 +152,7 @@
and '_cwmsgid' in newparams):
# are we here on creation or modification?
if any(eid == self._edited_entity.eid
- for eid in self._cw.data.get('eidmap', {}).values()):
+ for eid in self._cw.data.get('eidmap', {}).itervalues()):
msg = self._cw._('click here to see created entity')
else:
msg = self._cw._('click here to see edited entity')
--- a/web/facet.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/facet.py Thu Feb 14 16:01:24 2013 +0100
@@ -154,7 +154,7 @@
for term in select.selection[:]:
select.remove_selected(term)
# remove unbound variables which only have some type restriction
- for dvar in select.defined_vars.values():
+ for dvar in list(select.defined_vars.itervalues()):
if not (dvar is filtered_variable or dvar.stinfo['relations']):
select.undefine_variable(dvar)
# global tree config: DISTINCT, LIMIT, OFFSET
@@ -303,7 +303,7 @@
# optional relation
return ovar
if all(rdef.cardinality[cardidx] in '1+'
- for rdef in rschema.rdefs.values()):
+ for rdef in rschema.rdefs.itervalues()):
# mandatory relation without any restriction on the other variable
for orel in ovar.stinfo['relations']:
if rel is orel:
--- a/web/http_headers.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/http_headers.py Thu Feb 14 16:01:24 2013 +0100
@@ -27,7 +27,7 @@
def casemappingify(d):
global header_case_mapping
- newd = dict([(key.lower(),key) for key in d.keys()])
+ newd = dict([(key.lower(),key) for key in d])
header_case_mapping.update(newd)
def lowerify(d):
--- a/web/request.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/request.py Thu Feb 14 16:01:24 2013 +0100
@@ -459,7 +459,7 @@
def clear_user_callbacks(self):
if self.session is not None: # XXX
- for key in self.session.data.keys():
+ for key in list(self.session.data):
if key.startswith('cb_'):
del self.session.data[key]
@@ -753,8 +753,7 @@
def from_controller(self):
"""return the id (string) of the controller issuing the request"""
controller = self.relative_path(False).split('/', 1)[0]
- registered_controllers = self.vreg['controllers'].keys()
- if controller in registered_controllers:
+ if controller in self.vreg['controllers']:
return controller
return 'view'
--- a/web/test/unittest_views_searchrestriction.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/test/unittest_views_searchrestriction.py Thu Feb 14 16:01:24 2013 +0100
@@ -79,7 +79,7 @@
select = self.parse('DISTINCT Any V,TN,L ORDERBY TN,L WHERE T nom TN, V connait T, T is Personne, V is CWUser,'
'NOT V in_state VS, VS name "published", V login L')
rschema = self.schema['connait']
- for rdefs in rschema.rdefs.values():
+ for rdefs in rschema.rdefs.itervalues():
rdefs.cardinality = '++'
try:
self.assertEqual(self._generate(select, 'in_state', 'subject', 'name'),
@@ -87,7 +87,7 @@
"NOT EXISTS(V in_state VS), VS name 'published', "
"V in_state A, A name B")
finally:
- for rdefs in rschema.rdefs.values():
+ for rdefs in rschema.rdefs.itervalues():
rdefs.cardinality = '**'
def test_nonregr3(self):
--- a/web/test/unittest_viewselector.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/test/unittest_viewselector.py Thu Feb 14 16:01:24 2013 +0100
@@ -78,11 +78,11 @@
self.assertEqual(len(content), expected, content)
return
try:
- self.assertSetEqual(content.keys(), expected)
+ self.assertSetEqual(list(content), expected)
except Exception:
- print registry, sorted(expected), sorted(content.keys())
- print 'no more', [v for v in expected if not v in content.keys()]
- print 'missing', [v for v in content.keys() if not v in expected]
+ print registry, sorted(expected), sorted(content)
+ print 'no more', [v for v in expected if not v in content]
+ print 'missing', [v for v in content if not v in expected]
raise
def setUp(self):
@@ -486,14 +486,14 @@
def test_properties(self):
- self.assertEqual(sorted(k for k in self.vreg['propertydefs'].keys()
- if k.startswith('ctxcomponents.edit_box')),
- ['ctxcomponents.edit_box.context',
- 'ctxcomponents.edit_box.order',
- 'ctxcomponents.edit_box.visible'])
- self.assertEqual([k for k in self.vreg['propertyvalues'].keys()
- if not k.startswith('system.version')],
- [])
+ self.assertEqual(sorted(k for k in self.vreg['propertydefs'].iterkeys()
+ if k.startswith('ctxcomponents.edit_box')),
+ ['ctxcomponents.edit_box.context',
+ 'ctxcomponents.edit_box.order',
+ 'ctxcomponents.edit_box.visible'])
+ self.assertEqual([k for k in self.vreg['propertyvalues'].iterkeys()
+ if not k.startswith('system.version')],
+ [])
self.assertEqual(self.vreg.property_value('ctxcomponents.edit_box.visible'), True)
self.assertEqual(self.vreg.property_value('ctxcomponents.edit_box.order'), 2)
self.assertEqual(self.vreg.property_value('ctxcomponents.possible_views_box.visible'), False)
--- a/web/views/autoform.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/views/autoform.py Thu Feb 14 16:01:24 2013 +0100
@@ -1011,4 +1011,4 @@
AutomaticEntityForm.error('field for %s %s may not be found in schema' % (rtype, role))
return None
- vreg.register_all(globals().values(), __name__)
+ vreg.register_all(globals().itervalues(), __name__)
--- a/web/views/debug.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/views/debug.py Thu Feb 14 16:01:24 2013 +0100
@@ -105,7 +105,7 @@
w(u'</table>')
if req.cnx.is_repo_in_memory and req.user.is_in_group('managers'):
w(u'<h3>%s</h3>' % _('opened sessions'))
- sessions = repo._sessions.values()
+ sessions = repo._sessions.itervalues()
if sessions:
w(u'<ul>')
for session in sessions:
--- a/web/views/formrenderers.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/views/formrenderers.py Thu Feb 14 16:01:24 2013 +0100
@@ -238,8 +238,8 @@
if form.fieldsets_in_order:
fieldsets = form.fieldsets_in_order
else:
- fieldsets = byfieldset.keys()
- for fieldset in fieldsets:
+ fieldsets = byfieldset.iterkeys()
+ for fieldset in list(fieldsets):
try:
fields = byfieldset.pop(fieldset)
except KeyError:
--- a/web/views/sparql.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/views/sparql.py Thu Feb 14 16:01:24 2013 +0100
@@ -140,4 +140,4 @@
def registration_callback(vreg):
if Sparql2rqlTranslator is not None:
- vreg.register_all(globals().values(), __name__)
+ vreg.register_all(globals().itervalues(), __name__)
--- a/web/views/uicfg.py Thu Feb 14 15:38:25 2013 +0100
+++ b/web/views/uicfg.py Thu Feb 14 16:01:24 2013 +0100
@@ -575,7 +575,7 @@
_keys = frozenset('novalue_label novalue_include_rtype reload rvid edit_target'.split())
def tag_relation(self, key, tag):
- for tagkey in tag.iterkeys():
+ for tagkey in tag:
assert tagkey in self._keys, 'tag %r not in accepted tags: %r' % (tag, self._keys)
return super(ReleditTags, self).tag_relation(key, tag)
@@ -659,5 +659,5 @@
def registration_callback(vreg):
- vreg.register_all(globals().values(), __name__)
+ vreg.register_all(globals().itervalues(), __name__)
indexview_etype_section.init(vreg.schema)