On 4/21/06,
Jason Chu <[EMAIL PROTECTED]> wrote:
On Fri, 21 Apr 2006 03:14:41 -0700
"jasp" <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a simple database using the identity tables.
> I want my application to populate the database with some Permissions
> and Groups.
> I know this is possible with either catwalk or the tg-admin shell, but
> both options are not really suited for my needs, since I'll be
> dropping and creating my database a lot, I don't want to manually
> have to add all the permissions and groups the whole time.
>
> What I basicly need is a tg-admin sql populate option which i can feed
> a python script.
> It is possible to do a tg-admin sql execute, but you have to feed it
> raw sql data, which seems strange to me because the whole point of
> SQLObject is not to deal with the raw SQL anymore.
>
> Offcourse I'm not the first person with this problem.
> For example here is a nice thread discussing the problem:
> http://groups.google.com/group/turbogears/browse_thread/thread/ed11050d4675270a/0eb7cd25f5d5f037?q=populate&rnum=2#0eb7cd25f5d5f037
> I like the approaches in this thread better, but it seems no one
> really implemented this.
>
> I understand this is more an SQLObject thing then it is a Turbogears
> thing. There are also people asking this question on the SQLObject
> mailing list, but there seems to be not much response.
> http://pythonpaste.org/archives/message/20060110.053805.667013b9.en.html
>
> Since I think this is quite basic functionality, So I find it strange
> there is not a straightforward solution.
> I could patch my tg-admin shell to latest svn version, and use that,
> but I would really like it to happen automaticly when I run tg-admin
> sql create. Aren't there any hooks for this?
>
> The only work-around I can think of, is to use the cherrypy hooks for
> server startup, and then populate the db if no groups or permissions
> are found. A post_sql_create method in model.py would be much much
> nicer though.
>
> Thanx,
>
> Jasp.
We ended up writing a test-data.sh script that's really just a python
script. It's of this form:
#!/bin/sh
tg-admin shell << EOF
<a bunch of python commands to create objects>
hub.commit()
EOF
Then a simple 'rm old-db.db; tg-admin sql create; ./test-data.sh'
removes and creates the db with data in it.
The output of test-data.sh isn't pretty, but it doesn't have to be,
right?
Jason
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

