wiki:TGAdminShellHack
Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Note

The information on this page is obsolete, incomplete or incorrect and left here only for reference and has not been ported to the new documentation wiki.

Please refer to the TurboGears documentation wiki for up-to-date documentation.

Why?

Where you one of those people that luv the .sql file and luv to drop everything and recreate it? do you need to provide resonable defaults with your instalation? do you want to kill yourself after exiting tg-admin shell and forgot to run hub.commit?

then this is what you need.

The Script

The link refers to the actual code kevin but in, which is the base for mine (the one I had before was so ugly that doesn't deserve to live) Eventually I'll integrate this as a feature to tg-admin so that's why I have it there. although I could't figure out how to call that code without the testcase being executed.

data.sql.py

import turbogears
import sqlobject
from sqlobject.inheritance import InheritableSQLObject
import inspect

#maybe use http://trac.turbogears.org/turbogears/browser/branches/1.0/turbogears/testutil.py#L59

#~ delete old model and create it again.
for item in turbogears.util.get_model().__dict__.values(): 
    if inspect.isclass(item) and issubclass(item,sqlobject.SQLObject) and \
    item != sqlobject.SQLObject and item != InheritableSQLObject: 
        item.dropTable(ifExists=True)
        item.createTable()


#ALWAYS commit at the end
hub.commit()

how to run it

tg-admin shell < data.sql.py