title: Code auto-reload in pyramid
body: <p>I got the templates to reload dynamically but the controller code does not; I have to kill and restart the process. Listed below is the code I run; I run it as <code>python app.py</code>. </p>
  
  <p>What have I misconfigured and how do I get the code to reload dynamically?</p>
  
  <pre><code>if __name__ == '__main__':
      # configuration settings
      settings = {}
      settings['reload_all'] = True
      settings['debug_all'] = True
      settings['mako.directories'] = os.path.join(here, 'templates')
      #settings['db'] = os.path.join(here, 'tasks.db')
      # session factory
      session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
      # configuration setup
      config = Configurator(settings=settings, session_factory=session_factory)
      # routes setup
      #config.add_route('list', '/')
      #config.add_route('new', '/new')
      #config.add_route('close', '/close/{id}')
  
      #config.add_route('hello', '/hello')
      config.add_route('meta', '/m/{mid}')
      # static view setup
      config.add_static_view('static', os.path.join(here, 'static'))
      # scan for @view_config and @subscriber decorators
  
      connection = pymongo.Connection()
      def add_db(request):
          #db = config.registry.db[db_url.path[1:]]
          #if db_url.username and db_url.password:
              #db.authenticate(db_url.username, db_url.password)
          db = connection["bricwall_pyramid"]["bricwall"]
          return db
  
      #def add_fs(request):
         #return GridFS(request.db)
  
      config.add_request_method(add_db, 'db', reify=True)
      #config.add_request_method(add_fs, 'fs', reify=True)
  
      config.scan()
      # serve app
      app = config.make_wsgi_app()
      server = make_server('0.0.0.0', 8080, app)
      server.serve_forever()
  </code></pre>