title: Run Pylons controller as separate app?
body: <p>I have a Pylons app where I would like to move some of the logic to a separate batch process.   I've been running it under the main app for testing, but it is going to be doing a lot of work in the database, and I'd like it to be a separate process that will be running in the background constantly.   The main pylons app will submit jobs into the database, and the new process will do the work requested in each job.</p>
  
  <p>How can I launch a controller as a stand alone script?</p>
  
  <p>I currently have:</p>
  
  <pre><code>from warehouse2.controllers import importServer
  importServer.runServer(60)
  </code></pre>
  
  <p>and in the controller file, but not part of the controller class:</p>
  
  <pre><code>def runServer(sleep_secs):
      try:
          imp = ImportserverController()
          while(True):
              imp.runImport()
              sleepFor(sleep_secs)
  
      except Exception, e:
          log.info("Unexpected error: %s" % sys.exc_info()[0])
          log.info(e)
  </code></pre>
  
  <p>But starting ImportServer.py on the command line results in:</p>
  
  <pre><code>2008-09-25 12:31:12.687000 Could not locate a bind configured on mapper Mapper|I
  mportJob|n_imports, SQL expression or this Session
  </code></pre>