Author: ianb
Date: 2005-02-20 09:33:10 +0000 (Sun, 20 Feb 2005)
New Revision: 627
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
trunk/SQLObject/sqlobject/index.py
trunk/SQLObject/sqlobject/inheritance/iteration.py
trunk/SQLObject/sqlobject/main.py
trunk/SQLObject/sqlobject/sqlbuilder.py
trunk/SQLObject/sqlobject/sresults.py
trunk/SQLObject/sqlobject/tests/test_basic.py
trunk/SQLObject/sqlobject/tests/test_style.py
trunk/SQLObject/sqlobject/tests/test_style_old.py
Log:
Moved more attributes into sqlmeta, including attributes that are
per-class and private (like _SO_columns); these get set in
sqlmeta.setClass
Added a test for .set() usage (apparently I was only ever doing tests
for setting individual attributes).
Modified: trunk/SQLObject/sqlobject/dbconnection.py
===================================================================
--- trunk/SQLObject/sqlobject/dbconnection.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -275,7 +275,7 @@
", ".join(select.tables))
else:
columns = ", ".join(["%s.%s" % (cls.sqlmeta.table, col.dbName)
- for col in cls._SO_columns])
+ for col in cls.sqlmeta._columns])
if columns:
q += "%s.%s, %s FROM %s WHERE " % \
(cls.sqlmeta.table, cls.sqlmeta.idName, columns,
@@ -310,8 +310,8 @@
else:
desc = False
assert sqlbuilder.sqlIdentifier(s), "Strings in clauses are expected to be column identifiers. I got: %r" % s
- if select.sourceClass._SO_columnDict.has_key(s):
- s = select.sourceClass._SO_columnDict[s].dbName
+ if select.sourceClass.sqlmeta._columnDict.has_key(s):
+ s = select.sourceClass.sqlmeta._columnDict[s].dbName
if desc:
return sqlbuilder.DESC(sqlbuilder.SQLConstant(s))
else:
@@ -365,7 +365,7 @@
def createColumns(self, soClass):
columnDefs = [self.createIDColumn(soClass)] \
+ [self.createColumn(soClass, col)
- for col in soClass._SO_columns]
+ for col in soClass.sqlmeta._columns]
return ",\n".join([" %s" % c for c in columnDefs])
def createColumn(self, soClass, col):
@@ -464,27 +464,12 @@
self.sqlrepr(secondValue)))
def _SO_columnClause(self, soClass, kw):
- return ' AND '.join(['%s = %s' %
- (soClass._SO_columnDict[key].dbName,
- self.sqlrepr(value))
- for key, value
- in kw.items()])
- terms = []
- for key, value in kw.items():
- if hasattr(value, '_SO_joinDict'): #handle an object value
- # find the joinColumn
- for join in value._SO_joinDict.values():
- if join.otherClass is soClass:
- dbName = join.joinColumn
- break
- else: #if nothing found
- raise TypeError, "Cannot selectBy(%s=%r)" % (key, value)
- value = value.id
- else:
- dbName = soClass._SO_columnDict[key].dbName
- term = '%s = %s' % (dbName, self.sqlrepr(value))
- terms.append(term)
- return ' AND '.join(terms)
+ return ' AND '.join(
+ ['%s = %s' %
+ (soClass.sqlmeta._columnDict[key].dbName,
+ self.sqlrepr(value))
+ for key, value
+ in kw.items()])
def sqlrepr(self, v):
return sqlrepr(v, self.dbName)
Modified: trunk/SQLObject/sqlobject/index.py
===================================================================
--- trunk/SQLObject/sqlobject/index.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/index.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -37,7 +37,7 @@
columnName = desc['column']
if not isinstance(columnName, str):
columnName = columnName.name
- colDict = self.soClass._SO_columnDict
+ colDict = self.soClass.sqlmeta._columnDict
if not colDict.has_key(columnName):
for possible in colDict.values():
if possible.origName == columnName:
Modified: trunk/SQLObject/sqlobject/inheritance/iteration.py
===================================================================
--- trunk/SQLObject/sqlobject/inheritance/iteration.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/inheritance/iteration.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -12,7 +12,7 @@
self._results = []
#phd: find the index of the childName column
childNameIdx = None
- columns = select.sourceClass._SO_columns
+ columns = select.sourceClass.sqlmeta._columns
for i in range(len(columns)): #phd: enumerate() is unavailable python 2.2
if columns[i].name == "childName":
childNameIdx = i
Modified: trunk/SQLObject/sqlobject/main.py
===================================================================
--- trunk/SQLObject/sqlobject/main.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/main.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -127,7 +127,7 @@
def findDependantColumns(name, klass):
depends = []
- for col in klass._SO_columns:
+ for col in klass.sqlmeta._columns:
if col.foreignKey == name and col.cascade is not None:
depends.append(col)
return depends
@@ -159,8 +159,23 @@
__metaclass__ = declarative.DeclarativeMeta
# These attributes shouldn't be shared with superclasses:
- _unshared_attributes = ['table']
+ _unshared_attributes = ['table', 'idName']
+ # These are internal bookkeeping attributes; the class-level
+ # definition is a default for the instances, instances will
+ # reset these values.
+
+ # When an object is being created, it has an instance
+ # variable _creating, which is true. This way all the
+ # setters can be captured until the object is complete,
+ # and then the row is inserted into the database. Once
+ # that happens, _creating is deleted from the instance,
+ # and only the class variable (which is always false) is
+ # left.
+ _creating = False
+ _obsolete = False
+ _perConnection = False
+
def __classinit__(cls, new_attrs):
for attr in cls._unshared_attributes:
if not new_attrs.has_key(attr):
@@ -180,6 +195,30 @@
cls.table = cls.style.pythonClassToDBTable(cls.soClass.__name__)
if cls.idName is None:
cls.idName = cls.style.idForTable(cls.table)
+
+ # plainSetters are columns that haven't been overridden by the
+ # user, so we can contact the database directly to set them.
+ # Note that these can't set these in the SQLObject class
+ # itself, because they specific to this subclass of SQLObject,
+ # and cannot be shared among classes.
+ cls._plainSetters = {}
+ cls._plainGetters = {}
+ cls._plainForeignSetters = {}
+ cls._plainForeignGetters = {}
+ cls._plainJoinGetters = {}
+ cls._plainJoinAdders = {}
+ cls._plainJoinRemovers = {}
+
+ # This is a dictionary of columnName: columnObject
+ cls._columnDict = {}
+ cls._columns = []
+
+ # We keep track of the different joins by index,
+ # putting them in this list.
+ cls._joinList = []
+ cls._joinDict = {}
+ cls._indexList = []
+
setClass = classmethod(setClass)
class _sqlmeta_attr(object):
@@ -223,16 +262,6 @@
__metaclass__ = declarative.DeclarativeMeta
- # When an object is being created, it has an instance
- # variable _SO_creating, which is true. This way all the
- # setters can be captured until the object is complete,
- # and then the row is inserted into the database. Once
- # that happens, _SO_creating is deleted from the instance,
- # and only the class variable (which is always false) is
- # left.
- _SO_creating = False
- _SO_obsolete = False
-
# Sometimes an intance is attached to a connection, not
# globally available. In that case, self._SO_perConnection
# will be true. It's false by default:
@@ -417,23 +446,6 @@
if connection or not hasattr(cls, '_connection'):
cls.setConnection(connection)
- # plainSetters are columns that haven't been overridden by the
- # user, so we can contact the database directly to set them.
- # Note that these can't set these in the SQLObject class
- # itself, because they specific to this subclass of SQLObject,
- # and cannot be shared among classes.
- cls._SO_plainSetters = {}
- cls._SO_plainGetters = {}
- cls._SO_plainForeignSetters = {}
- cls._SO_plainForeignGetters = {}
- cls._SO_plainJoinGetters = {}
- cls._SO_plainJoinAdders = {}
- cls._SO_plainJoinRemovers = {}
-
- # This is a dictionary of columnName: columnObject
- cls._SO_columnDict = {}
- cls._SO_columns = []
-
# We have to check if there are columns in the inherited
# _columns where the attribute has been set to None in this
# class. If so, then we need to remove that column from
@@ -451,11 +463,6 @@
########################################
# Now we do the joins:
- # We keep track of the different joins by index,
- # putting them in this list.
- cls._SO_joinList = []
- cls._SO_joinDict = {}
-
for join in cls._joins:
cls.addJoin(join)
@@ -464,7 +471,6 @@
cls._SO_finishedClassCreation = True
makeProperties(cls)
- cls._SO_indexList = []
for idx in cls._indexes:
cls.addIndex(idx)
@@ -535,15 +541,15 @@
def addIndex(cls, indexDef):
index = indexDef.withClass(cls)
- cls._SO_indexList.append(index)
+ cls.sqlmeta._indexList.append(index)
addIndex = classmethod(addIndex)
def addColumn(cls, columnDef, changeSchema=False, connection=None):
column = columnDef.withClass(cls)
name = column.name
assert name != 'id', "The 'id' column is implicit, and should not be defined as a column"
- cls._SO_columnDict[name] = column
- cls._SO_columns.append(column)
+ cls.sqlmeta._columnDict[name] = column
+ cls.sqlmeta._columns.append(column)
if columnDef not in cls._columns:
cls._columns.append(columnDef)
@@ -572,7 +578,7 @@
# _SO_get_columnName definition.
if not hasattr(cls, getterName(name)) or (name == 'childName'):
setattr(cls, getterName(name), getter)
- cls._SO_plainGetters[name] = 1
+ cls.sqlmeta._plainGetters[name] = 1
#################################################
# Create the setter function(s)
@@ -593,7 +599,7 @@
# We keep track of setters that haven't been
# overridden, because we can combine these
# set columns into one SQL UPDATE query.
- cls._SO_plainSetters[name] = 1
+ cls.sqlmeta._plainSetters[name] = 1
##################################################
# Here we check if the column is a foreign key, in
@@ -623,7 +629,7 @@
# (sans ID ending)
if not hasattr(cls, getterName(name)[:-2]):
setattr(cls, getterName(name)[:-2], getter)
- cls._SO_plainForeignGetters[name[:-2]] = 1
+ cls.sqlmeta._plainForeignGetters[name[:-2]] = 1
if not column.immutable:
# The setter just gets the ID of the object,
@@ -632,7 +638,7 @@
setattr(cls, rawSetterName(name)[:-2], setter)
if not hasattr(cls, setterName(name)[:-2]):
setattr(cls, setterName(name)[:-2], setter)
- cls._SO_plainForeignSetters[name[:-2]] = 1
+ cls.sqlmeta._plainForeignSetters[name[:-2]] = 1
# We'll need to put in a real reference at
# some point. See needSet at the top of the
@@ -670,28 +676,28 @@
def delColumn(cls, column, changeSchema=False, connection=None):
if isinstance(column, str):
- column = cls._SO_columnDict[column]
+ column = cls.sqlmeta._columnDict[column]
if isinstance(column, col.Col):
- for c in cls._SO_columns:
+ for c in cls.sqlmeta._columns:
if column is c.columnDef:
column = c
break
- cls._SO_columns.remove(column)
+ cls.sqlmeta._columns.remove(column)
cls._columns.remove(column.columnDef)
name = column.name
- del cls._SO_columnDict[name]
+ del cls.sqlmeta._columnDict[name]
delattr(cls, rawGetterName(name))
- if cls._SO_plainGetters.has_key(name):
+ if cls.sqlmeta._plainGetters.has_key(name):
delattr(cls, getterName(name))
delattr(cls, rawSetterName(name))
- if cls._SO_plainSetters.has_key(name):
+ if cls.sqlmeta._plainSetters.has_key(name):
delattr(cls, setterName(name))
if column.foreignKey:
delattr(cls, rawGetterName(name)[:-2])
- if cls._SO_plainForeignGetters.has_key(name[:-2]):
+ if cls.sqlmeta._plainForeignGetters.has_key(name[:-2]):
delattr(cls, getterName(name)[:-2])
delattr(cls, rawSetterName(name)[:-2])
- if cls._SO_plainForeignSetters.has_key(name[:-2]):
+ if cls.sqlmeta._plainForeignSetters.has_key(name[:-2]):
delattr(cls, setterName(name)[:-2])
if column.alternateMethodName:
delattr(cls, column.alternateMethodName)
@@ -711,23 +717,23 @@
# join class.
join = joinDef.withClass(cls)
meth = join.joinMethodName
- cls._SO_joinDict[joinDef] = join
+ cls.sqlmeta._joinDict[joinDef] = join
- cls._SO_joinList.append(join)
- index = len(cls._SO_joinList)-1
+ cls.sqlmeta._joinList.append(join)
+ index = len(cls.sqlmeta._joinList)-1
if joinDef not in cls._joins:
cls._joins.append(joinDef)
# The function fetches the join by index, and
# then lets the join object do the rest of the
# work:
- func = eval('lambda self: self._SO_joinList[%i].performJoin(self)' % index)
+ func = eval('lambda self: self.sqlmeta._joinList[%i].performJoin(self)' % index)
# And we do the standard _SO_get_... _get_... deal
setattr(cls, rawGetterName(meth), func)
if not hasattr(cls, getterName(meth)):
setattr(cls, getterName(meth), func)
- cls._SO_plainJoinGetters[meth] = 1
+ cls.sqlmeta._plainJoinGetters[meth] = 1
# Some joins allow you to remove objects from the
# join.
@@ -735,21 +741,21 @@
# Again, we let it do the remove, and we do the
# standard naming trick.
- func = eval('lambda self, obj: self._SO_joinList[%i].remove(self, obj)' % index)
+ func = eval('lambda self, obj: self.sqlmeta._joinList[%i].remove(self, obj)' % index)
setattr(cls, '_SO_remove' + join.addRemoveName, func)
if not hasattr(cls, 'remove' + join.addRemoveName):
setattr(cls, 'remove' + join.addRemoveName, func)
- cls._SO_plainJoinRemovers[meth] = 1
+ cls.sqlmeta._plainJoinRemovers[meth] = 1
# Some joins allow you to add objects.
if hasattr(join, 'add'):
# And again...
- func = eval('lambda self, obj: self._SO_joinList[%i].add(self, obj)' % (len(cls._SO_joinList)-1))
+ func = eval('lambda self, obj: self.sqlmeta._joinList[%i].add(self, obj)' % (len(cls.sqlmeta._joinList)-1))
setattr(cls, '_SO_add' + join.addRemoveName, func)
if not hasattr(cls, 'add' + join.addRemoveName):
setattr(cls, 'add' + join.addRemoveName, func)
- cls._SO_plainJoinAdders[meth] = 1
+ cls.sqlmeta._plainJoinAdders[meth] = 1
if cls._SO_finishedClassCreation:
makeProperties(cls)
@@ -757,25 +763,25 @@
addJoin = classmethod(addJoin)
def delJoin(cls, joinDef):
- join = cls._SO_joinDict[joinDef]
+ join = cls.sqlmeta._joinDict[joinDef]
meth = join.joinMethodName
cls._joins.remove(joinDef)
- del cls._SO_joinDict[joinDef]
- for i in range(len(cls._SO_joinList)):
- if cls._SO_joinList[i] is joinDef:
+ del cls.sqlmeta._joinDict[joinDef]
+ for i in range(len(cls.sqlmeta._joinList)):
+ if cls.sqlmeta._joinList[i] is joinDef:
# Have to leave None, because we refer to joins
# by index.
- cls._SO_joinList[i] = None
+ cls.sqlmeta._joinList[i] = None
delattr(cls, rawGetterName(meth))
- if cls._SO_plainJoinGetters.has_key(meth):
+ if cls.sqlmeta._plainJoinGetters.has_key(meth):
delattr(cls, getterName(meth))
if hasattr(join, 'remove'):
delattr(cls, '_SO_remove' + join.addRemovePrefix)
- if cls._SO_plainJoinRemovers.has_key(meth):
+ if cls.sqlmeta._plainJoinRemovers.has_key(meth):
delattr(cls, 'remove' + join.addRemovePrefix)
if hasattr(join, 'add'):
delattr(cls, '_SO_add' + join.addRemovePrefix)
- if cls._SO_plainJoinAdders.has_key(meth):
+ if cls.sqlmeta._plainJoinAdders.has_key(meth):
delattr(cls, 'add' + join.addRemovePrefix)
if cls._SO_finishedClassCreation:
@@ -806,7 +812,7 @@
self._SO_perConnection = True
if not selectResults:
- dbNames = [col.dbName for col in self._SO_columns]
+ dbNames = [col.dbName for col in self.sqlmeta._columns]
selectResults = self._connection._SO_selectOne(self, dbNames)
if not selectResults:
raise SQLObjectNotFound, "The object %s by the ID %s does not exist" % (self.__class__.__name__, self.id)
@@ -833,7 +839,7 @@
else:
return result
self._expired = False
- dbNames = [col.dbName for col in self._SO_columns]
+ dbNames = [col.dbName for col in self.sqlmeta._columns]
selectResults = self._connection._SO_selectOne(self, dbNames)
if not selectResults:
raise SQLObjectNotFound, "The object %s by the ID %s has been deleted" % (self.__class__.__name__, self.id)
@@ -848,7 +854,7 @@
self.syncUpdate()
self._SO_writeLock.acquire()
try:
- dbNames = [col.dbName for col in self._SO_columns]
+ dbNames = [col.dbName for col in self.sqlmeta._columns]
selectResults = self._connection._SO_selectOne(self, dbNames)
if not selectResults:
raise SQLObjectNotFound, "The object %s by the ID %s has been deleted" % (self.__class__.__name__, self.id)
@@ -862,8 +868,9 @@
return
self._SO_writeLock.acquire()
try:
- if self._SO_columnDict:
- values = [(self._SO_columnDict[v[0]].dbName, v[1]) for v in self._SO_createValues.items()]
+ if self.sqlmeta._columnDict:
+ values = [(self.sqlmeta._columnDict[v[0]].dbName, v[1])
+ for v in self._SO_createValues.items()]
self._connection._SO_update(self, values)
self.dirty = False
self._SO_createValues = {}
@@ -877,7 +884,7 @@
try:
if self._expired:
return
- for column in self._SO_columns:
+ for column in self.sqlmeta._columns:
delattr(self, instanceName(column.name))
self._expired = True
self._connection.cache.expire(self.id, self.__class__)
@@ -888,7 +895,7 @@
# This is the place where we actually update the
# database.
- # If we are _SO_creating, the object doesn't yet exist
+ # If we are _creating, the object doesn't yet exist
# in the database, and we can't insert it until all
# the parts are set. So we just keep them in a
# dictionary until later:
@@ -898,15 +905,15 @@
dbValue = value
if toPython:
value = toPython(dbValue, self._SO_validatorState)
- if self._SO_creating or self.sqlmeta.lazyUpdate:
+ if self.sqlmeta._creating or self.sqlmeta.lazyUpdate:
self.dirty = True
self._SO_createValues[name] = dbValue
setattr(self, instanceName(name), value)
return
- self._connection._SO_update(self,
- [(self._SO_columnDict[name].dbName,
- dbValue)])
+ self._connection._SO_update(
+ self, [(self.sqlmeta._columnDict[name].dbName,
+ dbValue)])
if self.sqlmeta.cacheValues:
setattr(self, instanceName(name), value)
@@ -918,15 +925,15 @@
# 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._SO_plainSetters.has_key
+ is_column = self.sqlmeta._plainSetters.has_key
f_is_column = lambda item: is_column(item[0])
f_not_column = lambda item: not is_column(item[0])
items = kw.items()
extra = dict(filter(f_not_column, items))
kw = dict(filter(f_is_column, items))
- # _SO_creating is special, see _SO_setValue
- if self._SO_creating or self.sqlmeta.lazyUpdate:
+ # _creating is special, see _SO_setValue
+ if self.sqlmeta._creating or self.sqlmeta.lazyUpdate:
for name, value in kw.items():
fromPython = getattr(self, '_SO_fromPython_%s' % name, None)
if fromPython:
@@ -941,7 +948,7 @@
try:
getattr(self.__class__, name)
except AttributeError:
- if name not in self._SO_columnDict:
+ if name not in self.sqlmeta._columnDict:
raise TypeError, "%s.set() got an unexpected keyword argument %s" % (self.__class__.__name__, name)
try:
setattr(self, name, value)
@@ -973,14 +980,14 @@
toPython = getattr(self, '_SO_toPython_%s' % name, None)
if toPython:
value = toPython(dbValue, self._SO_validatorState)
- if self._cacheValues:
+ if self.sqlmeta.cacheValues:
setattr(self, instanceName(name), value)
toUpdate[name] = dbValue
for name, value in extra.items():
try:
getattr(self.__class__, name)
except AttributeError:
- if name not in self._SO_columnDict:
+ if name not in self.sqlmeta._columnDict:
raise TypeError, "%s.set() got an unexpected keyword argument %s" % (self.__class__.__name__, name)
try:
setattr(self, name, value)
@@ -988,25 +995,26 @@
raise AttributeError, '%s (with attribute %r)' % (e, name)
if toUpdate:
- args = [(self._SO_columnDict[name].dbName, value)
+ args = [(self.sqlmeta._columnDict[name].dbName, value)
for name, value in toUpdate.items()]
self._connection._SO_update(self, args)
finally:
self._SO_writeLock.release()
def _SO_selectInit(self, row):
- for col, colValue in zip(self._SO_columns, row):
+ for col, colValue in zip(self.sqlmeta._columns, row):
if col.toPython:
colValue = col.toPython(colValue, self._SO_validatorState)
setattr(self, instanceName(col.name), colValue)
def _SO_getValue(self, name):
# Retrieves a single value from the database. Simple.
- assert not self._SO_obsolete, "%s with id %s has become obsolete" \
- % (self.__class__.__name__, self.id)
+ assert not self.sqlmeta._obsolete, (
+ "%s with id %s has become obsolete" \
+ % (self.__class__.__name__, self.id))
# @@: do we really need this lock?
#self._SO_writeLock.acquire()
- column = self._SO_columnDict[name]
+ column = self.sqlmeta._columnDict[name]
results = self._connection._SO_selectOne(self, [column.dbName])
#self._SO_writeLock.release()
assert results != None, "%s with id %s is not in the database" \
@@ -1050,13 +1058,13 @@
def _create(self, id, **kw):
- self._SO_creating = True
+ self.sqlmeta._creating = True
self._SO_createValues = {}
self._SO_validatorState = SQLObjectState(self)
# First we do a little fix-up on the keywords we were
# passed:
- for column in self._SO_columns:
+ for column in self.sqlmeta._columns:
# If a foreign key is given, we get the ID of the object
# and put that in instead
@@ -1087,7 +1095,7 @@
# to be set, but were delayed until now:
setters = self._SO_createValues.items()
# Here's their database names:
- names = [self._SO_columnDict[v[0]].dbName for v in setters]
+ names = [self.sqlmeta._columnDict[v[0]].dbName for v in setters]
values = [v[1] for v in setters]
# Get rid of _SO_create*, we aren't creating anymore.
# Doesn't have to be threadsafe because we're still in
@@ -1097,7 +1105,7 @@
del self._SO_createValues
else:
self._SO_createValues = {}
- del self._SO_creating
+ del self.sqlmeta._creating
# Do the insert -- most of the SQL in this case is left
# up to DBConnection, since getting a new ID is
@@ -1115,7 +1123,7 @@
result = (connection or cls._connection)._SO_selectOneAlt(
cls,
[cls.sqlmeta.idName] +
- [col.dbName for col in cls._SO_columns],
+ [col.dbName for col in cls.sqlmeta._columns],
dbIDName,
value)
if not result:
@@ -1212,7 +1220,7 @@
def createIndexes(cls, ifNotExists=False, connection=None):
conn = connection or cls._connection
- for index in cls._SO_indexList:
+ for index in cls.sqlmeta._indexList:
if not index:
continue
conn._SO_createIndex(cls, index)
@@ -1220,7 +1228,7 @@
def _getJoinsToCreate(cls):
joins = []
- for join in cls._SO_joinList:
+ for join in cls.sqlmeta._joinList:
if not join:
continue
if not join.hasIntermediateTable():
@@ -1233,7 +1241,7 @@
def dropJoinTables(cls, ifExists=False, connection=None):
conn = connection or cls._connection
- for join in cls._SO_joinList:
+ for join in cls.sqlmeta._joinList:
if not join:
continue
if not join.hasIntermediateTable():
@@ -1279,7 +1287,7 @@
(klass.__name__, self.id, k.__name__))
for row in results:
row.destroySelf()
- self._SO_obsolete = True
+ self.sqlmeta._obsolete = True
self._connection._SO_delete(self)
self._connection.cache.expire(self.id, self.__class__)
@@ -1310,7 +1318,7 @@
def _reprItems(self):
items = []
- for col in self._SO_columns:
+ for col in self.sqlmeta._columns:
value = getattr(self, col.name)
r = repr(value)
if len(r) > 20:
Modified: trunk/SQLObject/sqlobject/sqlbuilder.py
===================================================================
--- trunk/SQLObject/sqlobject/sqlbuilder.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/sqlbuilder.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -341,7 +341,7 @@
return SQLObjectField(self.tableName, self.soClass.sqlmeta.idName, attr)
else:
return SQLObjectField(self.tableName,
- self.soClass._SO_columnDict[attr].dbName,
+ self.soClass.sqlmeta._columnDict[attr].dbName,
attr)
class Field(SQLExpression):
Modified: trunk/SQLObject/sqlobject/sresults.py
===================================================================
--- trunk/SQLObject/sqlobject/sresults.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/sresults.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -36,8 +36,8 @@
else:
desc = False
if isinstance(orderBy, (str, unicode)):
- if self.sourceClass._SO_columnDict.has_key(orderBy):
- val = self.sourceClass._SO_columnDict[orderBy].dbName
+ if self.sourceClass.sqlmeta._columnDict.has_key(orderBy):
+ val = self.sourceClass.sqlmeta._columnDict[orderBy].dbName
if desc:
return '-' + val
else:
Modified: trunk/SQLObject/sqlobject/tests/test_basic.py
===================================================================
--- trunk/SQLObject/sqlobject/tests/test_basic.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/tests/test_basic.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -44,6 +44,8 @@
assert bob.name == 'bob'
bob.name = 'joe'
assert bob.name == 'joe'
+ bob.set(name='joebob', passwd='testtest')
+ assert bob.name == 'joebob'
class TestSO2(SQLObject):
name = StringCol(length=50, dbName='name_col')
Modified: trunk/SQLObject/sqlobject/tests/test_style.py
===================================================================
--- trunk/SQLObject/sqlobject/tests/test_style.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/tests/test_style.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -25,5 +25,5 @@
st1 = SOStyleTest1(a='something', st2=None)
st2 = SOStyleTest2(b='whatever')
st1.st2 = st2
- assert st1._SO_columnDict['st2ID'].dbName == 'idst2'
+ assert st1.sqlmeta._columnDict['st2ID'].dbName == 'idst2'
assert st1.st2 == st2
Modified: trunk/SQLObject/sqlobject/tests/test_style_old.py
===================================================================
--- trunk/SQLObject/sqlobject/tests/test_style_old.py 2005-02-20 04:55:21 UTC (rev 626)
+++ trunk/SQLObject/sqlobject/tests/test_style_old.py 2005-02-20 09:33:10 UTC (rev 627)
@@ -25,7 +25,7 @@
st1 = OldSOStyleTest1(a='something', st2=None)
st2 = OldSOStyleTest2(b='whatever')
st1.st2 = st2
- assert st1._SO_columnDict['st2ID'].dbName == 'idst2'
+ assert st1.sqlmeta._columnDict['st2ID'].dbName == 'idst2'
assert st1.st2 == st2
teardown_module()
|