In python you can simple redefine a class at will, it just works.
SQLObject, however, uses a metaclass to keep track of the SQLObject
classes in a 'registry'. This makes it, among other things, possible to
use string references to other SQLObject classes. I'm not aware of any
method to clear/override this registry during runtime. You can,
however, modify most of the metadata during runtime:
from sqlobject import *
sqlhub.processConnection = connectionForURI('sqlite:///:memory:?debug=1')
class Adventurer(SQLObject):
... name = StringCol()
...
Adventurer.createTable()
1/Query : CREATE TABLE adventurer (
id INTEGER PRIMARY KEY,
name TEXT
)
1/QueryR : CREATE TABLE adventurer (
id INTEGER PRIMARY KEY,
name TEXT
)
Adventurer.sqlmeta.table="new_table"
Adventurer.createTable()
2/Query : CREATE TABLE new_table (
id INTEGER PRIMARY KEY,
name TEXT
)
2/QueryR : CREATE TABLE new_table (
id INTEGER PRIMARY KEY,
name TEXT
)
Adventurer(name="Foo")
3/QueryIns: INSERT INTO new_table (name) VALUES ('Foo')
4/QueryOne: SELECT name FROM new_table WHERE id = (1)
4/QueryR : SELECT name FROM new_table WHERE id = (1)
<Adventurer 1 name='Foo'>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---