title: SQLalchemy issue when extending Pyramid application
body: <p>I have a "Main Application", and in this application I have the following in the <em>init</em>.py file:</p>
  
  <pre><code>def main(global_config, **settings):
      # various config settings
      config.include(site_configs)
  
  def site_configs(config):
      config.add_route('portfolio', '/portfolio', 
      view='mainapp.views.portfolio',   
      view_renderer='/site/portfolio.mako')
  </code></pre>
  
  <p>And in the views.py I have:</p>
  
  <pre><code>def portfolio(request):
      ## some code here
      project_records = dbsession.query(projects).from_statement(
          'SELECT * FROM projects ORDER by id DESC').all()
  
  return {'project_records': project_records}
  </code></pre>
  
  <p>And then I have a new application, which I want to extend.</p>
  
  <p>So in the <strong>init</strong>.py I have done:</p>
  
  <pre><code>from mainapp import site_configs
  
  def main(global_config, **settings):
      # various config settings
      config.include(site_configs)
  </code></pre>
  
  <p>But when I run this new application, I get the following error (full traceback at the bottom of this message):</p>
  
  <pre><code>UnboundExecutionError: Could not locate a bind configured on mapper 
  Mapper|projects|projects, SQL expression or this Session
  </code></pre>
  
  <p>The sqlalchemy engine has been properly set up in both applications. </p>
  
  <p>Also what I want to do is use the database in the new application and not the one in the original main application.</p>
  
  <pre><code>----------------------------
  Full Traceback
  ----------------------------
  
  URL: http://127.0.0.1:6543/portfolio
  Module weberror.evalexception:431 in respond         view
  &gt;&gt;  app_iter = self.application(environ, detect_start_response)
  Module repoze.tm:23 in __call__         view
  &gt;&gt;  result = self.application(environ, save_status_and_headers)
  Module pyramid.router:158 in __call__         view
  &gt;&gt;  response = view_callable(context, request)
  Module pyramid.config:2824 in _rendered_view         view
  &gt;&gt;  response = wrapped_view(context, request)
  Module pyramid.config:2916 in _requestonly_view         view
  &gt;&gt;  response = view(request)
  Module mainapp.views:62 in portfolio         view
  &gt;&gt;  project_records = dbsession.query(projects).from_statement('SELECT * FROM projects ORDER by id DESC').all()
  Module sqlalchemy.orm.query:1579 in all         view
  &gt;&gt;  return list(self)
  Module sqlalchemy.orm.query:1689 in __iter__         view
  &gt;&gt;  return self._execute_and_instances(context)
  Module sqlalchemy.orm.query:1694 in _execute_and_instances         view
  &gt;&gt;  mapper=self._mapper_zero_or_none())
  Module sqlalchemy.orm.session:717 in execute         view
  &gt;&gt;  engine = self.get_bind(mapper, clause=clause, **kw)
  Module sqlalchemy.orm.session:853 in get_bind         view
  &gt;&gt;  ', '.join(context)))
  </code></pre>