I have a little script called "import_models.py" in the root of my
project directory:

from turbogears import update_config
update_config(configfile="dev.cfg", modulename="iplctg.config")
from iplctg.model import *

"iplctg" is the name of my project; just substitute your own.

Then all I have to do is "from import_models import *" and I have my
whole data model loaded in.  I you want to avoid namespace collisions,
you can do "import import_models as xyz" and then you can do, e.g.
xyz.MyDataModelClass.get(1).

Hope that's useful!

-Ansel


On Mar 21, 1:29 am, "Ram Yalamanchili" <[EMAIL PROTECTED]> wrote:
> Hey,
>
> I would like to run my own scripts for example to populate my database
> with fake information, etc. for testing. This I could do thru some db
> sql but i would rather prefer writing a python script whith just calls
> the functions and objects in my model/TG project.
>
> Anyone know how i can make my script run in a TG context? just like
> how tg-admin shell is running?
>
> thanks.
> Ram


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to