#11 Reloading class-module fails

closed-wont-fix
nobody
General (125)
5
2005-09-20
2003-10-04
Anonymous
No

When i define a class inherited from SQLObject in a
module & reload this module i get an exception.

e.g.
| class Person3(SQLObject):
| _cacheValues = False
| _fromDatabase = True

import thefile
reload(thefile)

File
"/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py",
line 151, in __new__
assert not classRegistry.get(registry,
{}).has_key(className), "A database object by the name
%s has already been created" % repr(className)
AssertionError: A database object by the name 'Person3'
has already been created

Discussion

  • Logged In: YES
    user_id=18730

    this bug makes it very hard to use SQLObject together with
    zope. (you have to restart zope everytime you do changes to
    your code when reloading doesn't work :/)

    the comment to the assert statement says: 'needSet stuff
    (see top of module) would get messed up if more than one
    SQLObject class has the same name.'

    is this a problem too, if the new created class is in fact
    the same as the old one? (i don't care if i have to restart
    zope each time i make changes to my database-objects, all i
    want is not having to restart zope _every_ time i make
    changes to my code).

     
  • Ian Bicking
    Ian Bicking
    2005-09-20

    • status: open --> closed
     
  • Ian Bicking
    Ian Bicking
    2005-09-20

    • status: closed --> closed-wont-fix
     
  • Ian Bicking
    Ian Bicking
    2005-09-20

    Logged In: YES
    user_id=210337

    SQLObject classes can't be reloaded, because the old class
    definition remains in memory and there will still be old
    associations to the old class, causing intractibly obscure
    and hard-to-understand bugs.