Hi,

I did a similar script, but I use trickiness and imports to get the
context. :-)

I like you way better, so I vote +1 for this idea.

Krys

xtian 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)
>
>And the initial data file would have something like:
>
>fred = Author(name="fred", email="[EMAIL PROTECTED]")
>first = Item(title="First post!", slug='first_post', body='This is my
>first blog entry', author=fred)
>
>.. to create all your base data without requiring any trickiness or
>imports to get the right context.
>
>Does this seem like something other people could use? I guess more
>thought could go into tying this into application deployment and such,
>as well as whether that's the best way to indicate the data file to
>use.
>
>Cheers,
>xtian
>
>
>  
>

Reply via email to