I think both ideas are of value. An exec command for running scripts, and a special module-level function in model.py that is run automatically by sql create.
An alternative to a single module-level function would be a special method on each model that is responsible for populating itself, perhaps "post_create(self)" or something. Sql create could just call that method of each model after all the tables have been created. I don't personally have a use for the exec command if sql create can be made to populate my tables, but I think someone somewhere might have a use for it. Just my $0.02. Krys Kevin Dangoor wrote: >On 10/1/05, xtian <[EMAIL PROTECTED]> wrote: > > >>I've been playing around with my data model, making changes to the >>structure, dropping and recreating tables, and I've found it handy to >>be able to run an initial data script in the context of the model >>classes. >> >>Something like: >>turbogears-admin shell <filename to execute> >> >>I've implemented this in mine - just by changing the last part of >>command.Shell.run to be: >> >> if len(sys.argv) == 2: >> # execute the initial data file >> datafile = sys.argv[1] >> execfile(datafile, globals(), locals) >> else: >> import code >> code.interact(local=locals) >> >> > >I'd probably make it a new command like "exec" or "run" or something, >since it's not actually dropping you into the shell. Even better might >be an option for sql create to run this after creating the database. >(I assume you're using this to populate a fresh database while testing >things?) > >Kevin > > >

