Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion running scripts using pylons models
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
WSobczuk  
View profile   Translate to Translated (View Original)
 More options 29 June 2007, 22:32
From: WSobczuk <WSobc...@gmail.com>
Date: Fri, 29 Jun 2007 14:32:14 -0700
Local: Fri 29 June 2007 22:32
Subject: running scripts using pylons models
Hello,

I just wasted around 5 hours trying to figure out how to run a job
that would use pylons models/config.  I finally did it so I'm
submitting this script here and hoping that it will be somehow
integrated into pylons and the documentation.  I hope that as a result
it will save other peoples time and make pylons a better experience.

Regards,

from sqlalchemy import *
import leisurenow.models as model
from paste.deploy import appconfig, config, CONFIG
import sys

config_file = sys.argv[1]
package = sys.argv[2]
func = sys.argv[3]

conf = appconfig('config:'+config_file)
conf.update(dict(app_conf=conf.local_conf,
global_conf=conf.global_conf))
CONFIG.push_process_config(conf)
if not conf.has_key('sqlalchemy.dburi'):
     raise KeyError("No sqlalchemy database config found!")
print "Connecting to database %s..."%repr(conf['sqlalchemy.dburi'])
engine = create_engine(conf['sqlalchemy.dburi'])
model.meta.connect(engine)

pkg = __import__(package, globals(), locals(), [func])
getattr(pkg, func)()


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google