[SQL-CVS] r625 - in trunk/SQLObject/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2005-02-20 04:49:47
|
Author: ianb Date: 2005-02-20 04:49:42 +0000 (Sun, 20 Feb 2005) New Revision: 625 Modified: trunk/SQLObject/sqlobject/main.py trunk/SQLObject/sqlobject/tests/test_basic.py Log: Moved cacheValues into sqlmeta Modified: trunk/SQLObject/sqlobject/main.py =================================================================== --- trunk/SQLObject/sqlobject/main.py 2005-02-20 04:45:59 UTC (rev 624) +++ trunk/SQLObject/sqlobject/main.py 2005-02-20 04:49:42 UTC (rev 625) @@ -153,6 +153,7 @@ style = None lazyUpdate = False defaultOrder = None + cacheValues = True __metaclass__ = declarative.DeclarativeMeta @@ -236,11 +237,6 @@ # will be true. It's false by default: _SO_perConnection = False - # The _cacheValues attribute controls if you cache - # values fetched from the database. We make sure - # it's set (default 1). - _cacheValues = True - _connection = None _columns = [] @@ -495,10 +491,11 @@ _idName = _sqlmeta_attr('idName', 2) _lazyUpdate = _sqlmeta_attr('lazyUpdate', 2) _defaultOrder = _sqlmeta_attr('defaultOrder', 2) + _cacheValues = _sqlmeta_attr('cacheValues', 2) def _cleanDeprecatedAttrs(cls, new_attrs): for attr in ['_table', '_lazyUpdate', '_style', '_idName', - '_defaultOrder']: + '_defaultOrder', '_cacheValues']: if new_attrs.has_key(attr): new_name = attr[1:] deprecated("'%s' is deprecated; please set the '%s' " @@ -558,7 +555,7 @@ # we'll alias that to _SO_get_columnName. This # allows a sort of super call, even though there's # no superclass that defines the database access. - if cls._cacheValues: + if cls.sqlmeta.cacheValues: # We create a method here, which is just a function # that takes "self" as the first argument. getter = eval('lambda self: self._SO_loadValue(%s)' % repr(instanceName(name))) @@ -609,7 +606,7 @@ # deal, except chopping off the "ID" ending since # we're giving the object, not the ID of the # object this time: - if cls._cacheValues: + if cls.sqlmeta.cacheValues: # self._SO_class_className is a reference # to the class in question. getter = eval('lambda self: self._SO_foreignKey(self._SO_loadValue(%r), self._SO_class_%s)' % (instanceName(name), column.foreignKey)) @@ -911,7 +908,7 @@ [(self._SO_columnDict[name].dbName, dbValue)]) - if self._cacheValues: + if self.sqlmeta.cacheValues: setattr(self, instanceName(name), value) def set(self, **kw): @@ -1127,7 +1124,7 @@ obj = cls.get(result[0], connection=connection) else: obj = cls.get(result[0]) - if not obj._cacheValues: + if not obj.sqlmeta.cacheValues: obj._SO_writeLock.acquire() try: obj._SO_selectInit(result[1:]) Modified: trunk/SQLObject/sqlobject/tests/test_basic.py =================================================================== --- trunk/SQLObject/sqlobject/tests/test_basic.py 2005-02-20 04:45:59 UTC (rev 624) +++ trunk/SQLObject/sqlobject/tests/test_basic.py 2005-02-20 04:49:42 UTC (rev 625) @@ -4,9 +4,11 @@ class TestSO1(SQLObject): name = StringCol(length=50, dbName='name_col') - _cacheValues = False passwd = StringCol(length=10) + class sqlmeta: + cacheValues = False + def _set_passwd(self, passwd): self._SO_set_passwd(passwd.encode('rot13')) |