Objects cannot be deleted when the connection is created with
cache=False due to a bug in the cache system. Here's the traceback:
-----
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/home/matt/python-ext//lib/python2.2/site-packages/SQLObject/SQLObject.py", line 926, in delete
obj.destroySelf()
File
"/home/matt/python-ext//lib/python2.2/site-packages/SQLObject/SQLObject.py", line 922, in destroySelf
self._connection.cache.purge(self.id, self.__class__)
File
"/home/matt/python-ext//lib/python2.2/site-packages/SQLObject/Cache.py",
line 173, in purge
self.caches[cls.__name__].purge(id)
File
"/home/matt/python-ext//lib/python2.2/site-packages/SQLObject/Cache.py",
line 131, in purge
if self.cache.has_key(id):
AttributeError: 'CacheFactory' object has no attribute 'cache'
-----
Obviously, the problem is that purge() does not check the doCache flag
before accessing the missing self.cache attribute. The fix is easy
enough but the same check may need applying to a couple of other methods
as well: expire and clear.
A better solution than the doCache flag may be to make self.cache a null
object, in this case a dictionary-like object that does nothing but
pretend to be empty. The current doCache knowledge is then limited to
the constructor and the other methods don't need to worry.
Cheers, Matt
--
Matt Goodall, Pollenation Internet Ltd
w: http://www.pollenation.net
e: ma...@po...
|