Author: phd
Date: Sun May 15 09:48:10 2011
New Revision: 4387
Log:
The first patch by Daniel Fetchinson from a series of patches for python 3 compatibility:
change all 'mydict.has_key(name)' type of checks with 'name in mydict'.
Modified:
SQLObject/trunk/docs/News.txt
SQLObject/trunk/sqlobject/cache.py
SQLObject/trunk/sqlobject/classregistry.py
SQLObject/trunk/sqlobject/col.py
SQLObject/trunk/sqlobject/dbconnection.py
SQLObject/trunk/sqlobject/declarative.py
SQLObject/trunk/sqlobject/include/pydispatch/dispatcher.py
SQLObject/trunk/sqlobject/include/pydispatch/robustapply.py
SQLObject/trunk/sqlobject/index.py
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/joins.py
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/manager/command.py
SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py
SQLObject/trunk/sqlobject/postgres/pgconnection.py
SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
SQLObject/trunk/sqlobject/sresults.py
SQLObject/trunk/sqlobject/tests/dbtest.py
SQLObject/trunk/sqlobject/util/moduleloader.py
SQLObject/trunk/sqlobject/versioning/__init__.py
Modified: SQLObject/trunk/docs/News.txt
==============================================================================
--- SQLObject/trunk/docs/News.txt Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/docs/News.txt Sun May 15 09:48:10 2011 (r4387)
@@ -21,11 +21,13 @@
now SQLObject uses text_factory instead and properly returns empty
strings.
-Source code
------------
+Source code and internals
+-------------------------
* Decorators @classmethod and @staticmethod are used everywhere.
+* All 'mydict.has_key(name)' checks were replaced with 'name in mydict'.
+
SQLObject 1.0.0
===============
Modified: SQLObject/trunk/sqlobject/cache.py
==============================================================================
--- SQLObject/trunk/sqlobject/cache.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/cache.py Sun May 15 09:48:10 2011 (r4387)
@@ -230,9 +230,9 @@
return
self.lock.acquire()
try:
- if self.cache.has_key(id):
+ if id in self.cache:
del self.cache[id]
- if self.expiredCache.has_key(id):
+ if id in self.expiredCache:
del self.expiredCache[id]
finally:
self.lock.release()
@@ -323,7 +323,7 @@
if cls is None:
for cache in self.caches.values():
cache.clear()
- elif self.caches.has_key(cls.__name__):
+ elif cls.__name__ in self.caches:
self.caches[cls.__name__].clear()
def tryGet(self, id, cls):
@@ -356,7 +356,7 @@
if cls is None:
for cache in self.caches.values():
cache.expireAll()
- elif self.caches.has_key(cls.__name__):
+ elif cls.__name__ in self.caches:
self.caches[cls.__name__].expireAll()
def getAll(self, cls=None):
Modified: SQLObject/trunk/sqlobject/classregistry.py
==============================================================================
--- SQLObject/trunk/sqlobject/classregistry.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/classregistry.py Sun May 15 09:48:10 2011 (r4387)
@@ -55,7 +55,7 @@
created. If it's already been created, the callback will be
called immediately.
"""
- if self.classes.has_key(className):
+ if className in self.classes:
callback(self.classes[className], *args, **kw)
else:
self.callbacks.setdefault(className, []).append((callback, args, kw))
@@ -90,7 +90,7 @@
getattr(sys.modules.get(cls.__module__),
'__file__', '(unknown)')))
self.classes[cls.__name__] = cls
- if self.callbacks.has_key(cls.__name__):
+ if cls.__name__ in self.callbacks:
for callback, args, kw in self.callbacks[cls.__name__]:
callback(cls, *args, **kw)
del self.callbacks[cls.__name__]
@@ -124,7 +124,7 @@
self.registries = {}
def registry(self, item):
- if not self.registries.has_key(item):
+ if item not in self.registries:
self.registries[item] = ClassRegistry(item)
return self.registries[item]
Modified: SQLObject/trunk/sqlobject/col.py
==============================================================================
--- SQLObject/trunk/sqlobject/col.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/col.py Sun May 15 09:48:10 2011 (r4387)
@@ -1560,7 +1560,7 @@
def pushKey(kw, name, value):
- if not kw.has_key(name):
+ if not name in kw:
kw[name] = value
all = []
Modified: SQLObject/trunk/sqlobject/dbconnection.py
==============================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/dbconnection.py Sun May 15 09:48:10 2011 (r4387)
@@ -786,7 +786,7 @@
def _SO_delete(self, inst):
cls = inst.__class__.__name__
- if not self._deletedCache.has_key(cls):
+ if not cls in self._deletedCache:
self._deletedCache[cls] = []
self._deletedCache[cls].append(inst.id)
meth = new.instancemethod(self._dbConnection._SO_delete.im_func, self, self.__class__)
@@ -897,7 +897,7 @@
# I'm a little surprised we have to do this, but apparently
# the object's private dictionary of attributes doesn't
# override this descriptor.
- if (obj is not None) and obj.__dict__.has_key('_connection'):
+ if (obj is not None) and '_connection' in obj.__dict__:
return obj.__dict__['_connection']
return self.getConnection()
@@ -978,14 +978,14 @@
def registerConnection(self, schemes, builder):
for uriScheme in schemes:
- assert not self.schemeBuilders.has_key(uriScheme) \
+ assert not uriScheme in self.schemeBuilders \
or self.schemeBuilders[uriScheme] is builder, \
"A driver has already been registered for the URI scheme %s" % uriScheme
self.schemeBuilders[uriScheme] = builder
def registerConnectionInstance(self, inst):
if inst.name:
- assert not self.instanceNames.has_key(inst.name) \
+ assert not inst.name in self.instanceNames \
or self.instanceNames[inst.name] is cls, \
"A instance has already been registered with the name %s" % inst.name
assert inst.name.find(':') == -1, "You cannot include ':' in your class names (%r)" % cls.name
@@ -997,7 +997,7 @@
uri += '?' + urllib.urlencode(args)
else:
uri += '&' + urllib.urlencode(args)
- if self.cachedURIs.has_key(uri):
+ if uri in self.cachedURIs:
return self.cachedURIs[uri]
if uri.find(':') != -1:
scheme, rest = uri.split(':', 1)
@@ -1008,7 +1008,7 @@
conn = connCls.connectionFromURI(uri)
else:
# We just have a name, not a URI
- assert self.instanceNames.has_key(uri), \
+ assert uri in self.instanceNames, \
"No SQLObject driver exists under the name %s" % uri
conn = self.instanceNames[uri]
# @@: Do we care if we clobber another connection?
@@ -1016,7 +1016,7 @@
return conn
def dbConnectionForScheme(self, scheme):
- assert self.schemeBuilders.has_key(scheme), (
+ assert scheme in self.schemeBuilders, (
"No SQLObject driver exists for %s (only %s)"
% (scheme, ', '.join(self.schemeBuilders.keys())))
return self.schemeBuilders[scheme]()
Modified: SQLObject/trunk/sqlobject/declarative.py
==============================================================================
--- SQLObject/trunk/sqlobject/declarative.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/declarative.py Sun May 15 09:48:10 2011 (r4387)
@@ -63,7 +63,7 @@
self.type = type
def __call__(self, *args, **kw):
- assert not kw.has_key('self') and not kw.has_key('cls'), (
+ assert not 'self' in kw and not 'cls' in kw, (
"You cannot use 'self' or 'cls' arguments to a "
"classinstancemethod")
return self.func(*((self.obj, self.type) + args), **kw)
@@ -87,7 +87,7 @@
cls = type.__new__(meta, class_name, bases, new_attrs)
for func in early_funcs:
func(cls)
- if new_attrs.has_key('__classinit__'):
+ if '__classinit__' in new_attrs:
cls.__classinit__ = staticmethod(cls.__classinit__.im_func)
cls.__classinit__(cls, new_attrs)
for func in post_funcs:
@@ -107,7 +107,7 @@
def __classinit__(cls, new_attrs):
cls.declarative_count = counter.next()
for name in cls.__mutableattributes__:
- if not new_attrs.has_key(name):
+ if name not in new_attrs:
setattr(cls, copy.copy(getattr(cls, name)))
def __instanceinit__(self, new_attrs):
@@ -119,7 +119,7 @@
% (self.__class__.__name__, name))
for name, value in new_attrs.items():
setattr(self, name, value)
- if not new_attrs.has_key('declarative_count'):
+ if 'declarative_count' not in new_attrs:
self.declarative_count = counter.next()
def __init__(self, *args, **kw):
@@ -127,7 +127,7 @@
assert len(self.__unpackargs__) == 2, \
"When using __unpackargs__ = ('*', varname), you must only provide a single variable name (you gave %r)" % self.__unpackargs__
name = self.__unpackargs__[1]
- if kw.has_key(name):
+ if name in kw:
raise TypeError(
"keyword parameter '%s' was given by position and name"
% name)
@@ -140,14 +140,14 @@
len(self.__unpackargs__),
len(args)))
for name, arg in zip(self.__unpackargs__, args):
- if kw.has_key(name):
+ if name in kw:
raise TypeError(
"keyword parameter '%s' was given by position and name"
% name)
kw[name] = arg
- if kw.has_key('__alsocopy'):
+ if '__alsocopy' in kw:
for name, value in kw['__alsocopy'].items():
- if not kw.has_key(name):
+ if name not in kw:
if name in self.__mutableattributes__:
value = copy.copy(value)
kw[name] = value
@@ -175,7 +175,7 @@
else:
name = '%s class' % cls.__name__
v = cls.__dict__.copy()
- if v.has_key('declarative_count'):
+ if 'declarative_count' in v:
name = '%s %i' % (name, v['declarative_count'])
del v['declarative_count']
# @@: simplifying repr:
Modified: SQLObject/trunk/sqlobject/include/pydispatch/dispatcher.py
==============================================================================
--- SQLObject/trunk/sqlobject/include/pydispatch/dispatcher.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/include/pydispatch/dispatcher.py Sun May 15 09:48:10 2011 (r4387)
@@ -140,7 +140,7 @@
if weak:
receiver = saferef.safeRef(receiver, onDelete=_removeReceiver)
senderkey = id(sender)
- if connections.has_key(senderkey):
+ if senderkey in connections:
signals = connections[senderkey]
else:
connections[senderkey] = signals = {}
@@ -160,7 +160,7 @@
receiverID = id(receiver)
# get current set, remove any current references to
# this receiver in the set, including back-references
- if signals.has_key(signal):
+ if signal in signals:
receivers = signals[signal]
_removeOldBackRefs(senderkey, signal, receiver, receivers)
else:
@@ -296,7 +296,7 @@
for receiver in set:
if receiver: # filter out dead instance-method weakrefs
try:
- if not receivers.has_key( receiver ):
+ if not receiver in receivers:
receivers[receiver] = 1
yield receiver
except TypeError:
Modified: SQLObject/trunk/sqlobject/include/pydispatch/robustapply.py
==============================================================================
--- SQLObject/trunk/sqlobject/include/pydispatch/robustapply.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/include/pydispatch/robustapply.py Sun May 15 09:48:10 2011 (r4387)
@@ -32,7 +32,7 @@
receiver, codeObject, startIndex = function( receiver )
acceptable = codeObject.co_varnames[startIndex+len(arguments):codeObject.co_argcount]
for name in codeObject.co_varnames[startIndex:startIndex+len(arguments)]:
- if named.has_key( name ):
+ if name in named:
raise TypeError(
"""Argument %r specified both positionally and as a keyword for calling %r"""% (
name, receiver,
@@ -46,4 +46,4 @@
del named[arg]
return receiver(*arguments, **named)
-
\ No newline at end of file
+
Modified: SQLObject/trunk/sqlobject/index.py
==============================================================================
--- SQLObject/trunk/sqlobject/index.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/index.py Sun May 15 09:48:10 2011 (r4387)
@@ -26,7 +26,7 @@
if args and kw:
raise TypeError, "You cannot mix named and unnamed arguments"
columns = [d['column'] for d in self.descriptions
- if d.has_key('column')]
+ if 'column' in d]
if kw and len(kw) != len(columns) or args and len(args) != len(columns):
raise TypeError, ("get() takes exactly %d argument and an optional "
"named argument 'connection' (%d given)" % (
@@ -49,12 +49,12 @@
for desc in columns:
if not isinstance(desc, dict):
desc = {'column': desc}
- if desc.has_key('expression'):
- assert not desc.has_key('column'), (
+ if 'expression' in desc:
+ assert 'column' not in desc, (
'You cannot provide both an expression and a column '
'(for %s in index %s in %s)' %
(desc, self.name, self.soClass))
- assert not desc.has_key('length'), (
+ assert 'length' not in desc, (
'length does not apply to expressions (for %s in '
'index %s in %s)' %
(desc, self.name, self.soClass))
@@ -64,7 +64,7 @@
if not isinstance(columnName, str):
columnName = columnName.name
colDict = self.soClass.sqlmeta.columns
- if not colDict.has_key(columnName):
+ if columnName not in colDict:
for possible in colDict.values():
if possible.origName == columnName:
column = possible
@@ -91,7 +91,7 @@
uniqueOrIndex = 'INDEX'
spec = []
for desc in self.descriptions:
- if desc.has_key('expression'):
+ if 'expression' in desc:
spec.append(self.getExpression(desc, 'sqlite'))
else:
spec.append(desc['column'].dbName)
@@ -111,9 +111,9 @@
uniqueOrIndex = 'INDEX'
spec = []
for desc in self.descriptions:
- if desc.has_key('expression'):
+ if 'expression' in desc:
spec.append(self.getExpression(desc, 'mysql'))
- elif desc.has_key('length'):
+ elif 'length' in desc:
spec.append('%s(%d)' % (desc['column'].dbName, desc['length']))
else:
spec.append(desc['column'].dbName)
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
==============================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py Sun May 15 09:48:10 2011 (r4387)
@@ -57,7 +57,7 @@
continue
currentClass = childClass
while currentClass:
- if tableRegistryCopy.has_key(currentClass):
+ if currentClass in tableRegistryCopy:
if currentClass in tableRegistry:
#DSM: Remove this class as it is a parent one
#DSM: of a needed children
@@ -214,7 +214,7 @@
@classmethod
def getColumns(sqlmeta):
columns = sqlmeta.getAllColumns()
- if columns.has_key('childName'):
+ if 'childName' in columns:
del columns['childName']
return columns
@@ -349,7 +349,7 @@
#DSM: Note: we can't use the ** call paremeter directly
#DSM: as we must be able to delete items from the dictionary
#DSM: (and our children must know that the items were removed!)
- if kw.has_key('kw'):
+ if 'kw' in kw:
kw = kw['kw']
#DSM: If we are the children of an inheritable class,
#DSM: we must first create our parent
Modified: SQLObject/trunk/sqlobject/joins.py
==============================================================================
--- SQLObject/trunk/sqlobject/joins.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/joins.py Sun May 15 09:48:10 2011 (r4387)
@@ -35,7 +35,7 @@
name = joinMethodName
def withClass(self, soClass):
- if self.kw.has_key('joinMethodName'):
+ if 'joinMethodName' in self.kw:
self._joinMethodName = self.kw['joinMethodName']
del self.kw['joinMethodName']
return self.baseClass(creationOrder=self.creationOrder,
Modified: SQLObject/trunk/sqlobject/main.py
==============================================================================
--- SQLObject/trunk/sqlobject/main.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/main.py Sun May 15 09:48:10 2011 (r4387)
@@ -92,9 +92,9 @@
elif var.startswith('_doc_'):
props.setdefault(var[5:], {})['doc'] = value
for var, setters in props.items():
- if len(setters) == 1 and setters.has_key('doc'):
+ if len(setters) == 1 and 'doc' in setters:
continue
- if d.has_key(var):
+ if var in d:
if isinstance(d[var], (types.MethodType, types.FunctionType)):
warnings.warn(
"I tried to set the property %r, but it was "
@@ -119,7 +119,7 @@
for var, value in d.items():
if isinstance(value, property):
for prop in [value.fget, value.fset, value.fdel]:
- if prop and not d.has_key(prop.__name__):
+ if prop and not prop.__name__ in d:
delFunc(obj, var)
break
@@ -238,7 +238,7 @@
def __classinit__(cls, new_attrs):
for attr in cls._unshared_attributes:
- if not new_attrs.has_key(attr):
+ if attr not in new_attrs:
setattr(cls, attr, None)
declarative.setup_attributes(cls, new_attrs)
@@ -464,17 +464,17 @@
del sqlmeta.columnDefinitions[name]
sqlmeta.columnList.remove(column)
delattr(soClass, rawGetterName(name))
- if sqlmeta._plainGetters.has_key(name):
+ if name in sqlmeta._plainGetters:
delattr(soClass, getterName(name))
delattr(soClass, rawSetterName(name))
- if sqlmeta._plainSetters.has_key(name):
+ if name in sqlmeta._plainSetters:
delattr(soClass, setterName(name))
if column.foreignKey:
delattr(soClass, rawGetterName(soClass.sqlmeta.style.instanceIDAttrToAttr(name)))
- if sqlmeta._plainForeignGetters.has_key(name):
+ if name in sqlmeta._plainForeignGetters:
delattr(soClass, getterName(name))
delattr(soClass, rawSetterName(soClass.sqlmeta.style.instanceIDAttrToAttr(name)))
- if sqlmeta._plainForeignSetters.has_key(name):
+ if name in sqlmeta._plainForeignSetters:
delattr(soClass, setterName(name))
if column.alternateMethodName:
delattr(soClass, column.alternateMethodName)
@@ -565,15 +565,15 @@
# by index.
sqlmeta.joins[i] = None
delattr(soClass, rawGetterName(meth))
- if sqlmeta._plainJoinGetters.has_key(meth):
+ if meth in sqlmeta._plainJoinGetters:
delattr(soClass, getterName(meth))
if hasattr(join, 'remove'):
delattr(soClass, '_SO_remove' + join.addRemovePrefix)
- if sqlmeta._plainJoinRemovers.has_key(meth):
+ if meth in sqlmeta._plainJoinRemovers:
delattr(soClass, 'remove' + join.addRemovePrefix)
if hasattr(join, 'add'):
delattr(soClass, '_SO_add' + join.addRemovePrefix)
- if sqlmeta._plainJoinAdders.has_key(meth):
+ if meth in sqlmeta._plainJoinAdders:
delattr(soClass, 'add' + join.addRemovePrefix)
if soClass._SO_finishedClassCreation:
@@ -728,11 +728,11 @@
if not is_base:
cls._SO_cleanDeprecatedAttrs(new_attrs)
- if new_attrs.has_key('_connection'):
+ if '_connection' in new_attrs:
connection = new_attrs['_connection']
del cls._connection
- assert not new_attrs.has_key('connection')
- elif new_attrs.has_key('connection'):
+ assert 'connection' not in new_attrs
+ elif 'connection' in new_attrs:
connection = new_attrs['connection']
del cls.connection
else:
@@ -818,7 +818,7 @@
inheritance. Lastly it calls sqlmeta.setClass, which handles
much of the setup.
"""
- if (not new_attrs.has_key('sqlmeta')
+ if ('sqlmeta' not in new_attrs
and not is_base):
# We have to create our own subclass, usually.
# type(className, bases_tuple, attr_dict) creates a new subclass.
@@ -859,7 +859,7 @@
a deprecation warning is given.
"""
for attr in ():
- if new_attrs.has_key(attr):
+ if attr in new_attrs:
deprecated("%r is deprecated and read-only; please do "
"not use it in your classes until it is fully "
"deprecated" % attr, level=1, stacklevel=5)
@@ -1056,7 +1056,7 @@
# Filter out items that don't map to column names.
# Those will be set directly on the object using
# setattr(obj, name, value).
- is_column = self.sqlmeta._plainSetters.has_key
+ is_column = lambda _c: _c in self.sqlmeta._plainSetters
f_is_column = lambda item: is_column(item[0])
f_not_column = lambda item: not is_column(item[0])
items = kw.items()
@@ -1190,14 +1190,14 @@
# The get() classmethod/constructor uses a magic keyword
# argument when it wants an empty object, fetched from the
# database. So we have nothing more to do in that case:
- if kw.has_key('_SO_fetch_no_create'):
+ if '_SO_fetch_no_create' in kw:
return
post_funcs = []
self.sqlmeta.send(events.RowCreateSignal, self, kw, post_funcs)
# Pass the connection object along if we were given one.
- if kw.has_key('connection'):
+ if 'connection' in kw:
connection = kw.pop('connection')
if getattr(self, '_connection', None) is not connection:
self._connection = connection
@@ -1205,7 +1205,7 @@
self._SO_writeLock = threading.Lock()
- if kw.has_key('id'):
+ if 'id' in kw:
id = self.sqlmeta.idType(kw['id'])
del kw['id']
else:
@@ -1238,7 +1238,7 @@
# Then we check if the column wasn't passed in, and
# if not we try to get the default.
- if not kw.has_key(column.name) and not kw.has_key(column.foreignName):
+ if column.name not in kw and column.foreignName not in kw:
default = column.default
# If we don't get it, it's an error:
Modified: SQLObject/trunk/sqlobject/manager/command.py
==============================================================================
--- SQLObject/trunk/sqlobject/manager/command.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/manager/command.py Sun May 15 09:48:10 2011 (r4387)
@@ -65,7 +65,7 @@
existing[col.dbName] = col
missing = {}
for col in soClass.sqlmeta.columnList:
- if existing.has_key(col.dbName):
+ if col.dbName in existing:
del existing[col.dbName]
else:
missing[col.dbName] = col
@@ -220,7 +220,7 @@
using the dependency_stack to detect any circular reference.
"""
# Return value from the cache if already calculated
- if dependency_levels.has_key(cls):
+ if cls in dependency_levels:
return dependency_levels[cls]
# Check for circular references
if cls in dependency_stack:
@@ -766,7 +766,7 @@
existing[col.dbName] = col
missing = {}
for col in soClass.sqlmeta.columnList:
- if existing.has_key(col.dbName):
+ if col.dbName in existing:
del existing[col.dbName]
else:
missing[col.dbName] = col
@@ -968,7 +968,7 @@
for fn in os.listdir(last_version_dir):
if not fn.endswith('.sql'):
continue
- if not files_copy.has_key(fn):
+ if not fn in files_copy:
if v > 1:
print "Missing file %s" % fn
break
Modified: SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py
==============================================================================
--- SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/maxdb/maxdbconnection.py Sun May 15 09:48:10 2011 (r4387)
@@ -269,7 +269,7 @@
if default is not None:
kw['default'] = default
- if keymap.has_key(field_name):
+ if field_name in keymap:
kw['foreignKey'] = keymap[field_name]
results.append(colClass(**kw))
Modified: SQLObject/trunk/sqlobject/postgres/pgconnection.py
==============================================================================
--- SQLObject/trunk/sqlobject/postgres/pgconnection.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/postgres/pgconnection.py Sun May 15 09:48:10 2011 (r4387)
@@ -258,7 +258,7 @@
for field, t, notnull, defaultstr in colData:
if field == primaryKey:
continue
- if keymap.has_key(field):
+ if field in keymap:
colClass = col.ForeignKey
kw = {'foreignKey': soClass.sqlmeta.style.dbTableToPythonClass(keymap[field])}
name = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
==============================================================================
--- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py Sun May 15 09:48:10 2011 (r4387)
@@ -139,7 +139,7 @@
return conn
threadid = thread.get_ident()
if (self._pool is not None
- and self._threadPool.has_key(threadid)):
+ and threadid in self._threadPool):
conn = self._threadPool[threadid]
del self._threadPool[threadid]
if conn in self._pool:
@@ -163,7 +163,7 @@
threadid = self._threadOrigination.get(id(conn))
DBAPI.releaseConnection(self, conn, explicit=explicit)
if (self._pool is not None and threadid
- and not self._threadPool.has_key(threadid)):
+ and threadid not in self._threadPool):
self._threadPool[threadid] = conn
else:
if self._pool and conn in self._pool:
Modified: SQLObject/trunk/sqlobject/sresults.py
==============================================================================
--- SQLObject/trunk/sqlobject/sresults.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/sresults.py Sun May 15 09:48:10 2011 (r4387)
@@ -23,7 +23,7 @@
else:
orderBy = self._mungeOrderBy(orderBy)
ops['dbOrderBy'] = orderBy
- if ops.has_key('connection') and ops['connection'] is None:
+ if 'connection' in ops and ops['connection'] is None:
del ops['connection']
if ops.get('limit', None):
assert not ops.get('start', None) and not ops.get('end', None), \
Modified: SQLObject/trunk/sqlobject/tests/dbtest.py
==============================================================================
--- SQLObject/trunk/sqlobject/tests/dbtest.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/tests/dbtest.py Sun May 15 09:48:10 2011 (r4387)
@@ -99,7 +99,7 @@
def getConnectionURI():
name = conftest.option.Database
- if conftest.connectionShortcuts.has_key(name):
+ if name in conftest.connectionShortcuts:
name = conftest.connectionShortcuts[name]
return name
Modified: SQLObject/trunk/sqlobject/util/moduleloader.py
==============================================================================
--- SQLObject/trunk/sqlobject/util/moduleloader.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/util/moduleloader.py Sun May 15 09:48:10 2011 (r4387)
@@ -9,7 +9,7 @@
return mod
def load_module_from_name(filename, module_name):
- if sys.modules.has_key(module_name):
+ if module_name in sys.modules:
return sys.modules[module_name]
init_filename = os.path.join(os.path.dirname(filename), '__init__.py')
if not os.path.exists(init_filename):
@@ -22,7 +22,7 @@
f.write('#\n')
f.close()
fp = None
- if sys.modules.has_key(module_name):
+ if module_name in sys.modules:
return sys.modules[module_name]
if '.' in module_name:
parent_name = '.'.join(module_name.split('.')[:-1])
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
==============================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py Sun May 15 09:36:33 2011 (r4386)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py Sun May 15 09:48:10 2011 (r4387)
@@ -36,7 +36,7 @@
return super(Version, cls).select(clause, *args, **kw)
def __getattr__(self, attr):
- if self.__dict__.has_key(attr):
+ if attr in self.__dict__:
return self.__dict__[attr]
else:
return getattr(self.master, attr)
|