The issue is related to the fact that you probably also have two
different DBSession to connect to the two different engines and that
some entities are available on an engine and some are not. So it tries
to fetch everything from the DBSession that has been passes as the
argument to the Admin controller failing to find some tables.

To solve this you must mount two separate admin controllers.
To the first admin controller pass as the first argument a list of the
models that are available on the first session and the first session
as the second arguments.
To the second admin pass the list of the models available on the other
session and the other session.

Like:
    admin1 = AdminController([User, Group, Permission], DBSession,
config_type=TGAdminConfig)
    admin2 = AdminController([This, That], DBSession2,
config_type=TGAdminConfig)



On Wed, Nov 23, 2011 at 6:46 PM, alonn <[email protected]> wrote:
> when connecting to 2 db( one sqllite for tg2 auth and the second
> mssql)
> I commented out the sqlalchemy.url in development.ini and instead
> wrote 2 lines: sqlalchemy.first.url and sqlalchemy.second.url
> I also changed app_cfg and model.__init__ according to the docs - so
> everything finally worked - but!
> when I run paster setup-app development.ini in the end I get a
> "keyerror:sqlalchemy.url" .I think this is called from schema.py who
> ends with:
> try:
>        main(argv=['version_control'], url=config['sqlalchemy.url'],
> repository='migration', name='migration')
>    except DatabaseAlreadyControlledError:
>        print 'Database already under version control'
> and some of the information isn't loaded to sqllite (like users and
> passwords)
>
> when I manually change the sqlalchemy.url to sqlalchemy.first.url -
> everything works fine except for tg2 admin screen where when I try to
> enter the class mapped to the second db (not users,groups etc) I get
> an error
>
> OperationalError: (OperationalError) no such table:..
> where the traceback is :
> Module weberror.evalexception:431 in respond          view
>>>  app_iter = self.application(environ, detect_start_response)
> Module tg.configuration:825 in remover          view
>>>  return app(environ, start_response)
> Module repoze.tm:24 in __call__          view
>>>  result = self.application(environ, save_status_and_headers)
> Module repoze.who.middleware:107 in __call__          view
>>>  app_iter = app(environ, wrapper.wrap_start_response)
> Module tw.core.middleware:46 in __call__          view
>>>  return self.wsgi_app(environ, start_response)
> Module tw.core.middleware:72 in wsgi_app          view
>>>  resp = req.get_response(self.application)
> Module webob.request:1053 in get_response          view
>>>  application, catch_exc_info=False)
> Module webob.request:1022 in call_application          view
>>>  app_iter = application(self.environ, start_response)
> Module tw.core.resource_injector:70 in _injector          view
>>>  resp = req.get_response(app)
> Module webob.request:1053 in get_response          view
>>>  application, catch_exc_info=False)
> Module webob.request:1022 in call_application          view
>>>  app_iter = application(self.environ, start_response)
> Module beaker.middleware:73 in __call__          view
>>>  return self.app(environ, start_response)
> Module beaker.middleware:152 in __call__          view
>>>  return self.wrap_app(environ, session_start_response)
> Module routes.middleware:131 in __call__          view
>>>  response = self.app(environ, start_response)
> Module pylons.wsgiapp:107 in __call__          view
>>>  response = self.dispatch(controller, environ, start_response)
> Module pylons.wsgiapp:312 in dispatch          view
>>>  return controller(environ, start_response)
> Module priorityagent.lib.base:31 in __call__          view
>>>  return TGController.__call__(self, environ, start_response)
> Module pylons.controllers.core:211 in __call__          view
>>>  response = self._dispatch_call()
> Module pylons.controllers.core:162 in _dispatch_call          view
>>>  response = self._inspect_call(func)
> Module pylons.controllers.core:105 in _inspect_call          view
>>>  result = self._perform_call(func, args)
> Module tg.controllers.dispatcher:254 in _perform_call          view
>>>  r = self._call(func, params, remainder=remainder)
> Module tg.controllers.decoratedcontroller:116 in _call          view
>>>  output = controller(*remainder, **dict(params))
> Module tgext.crud.controller:119 in get_all          view
>>>  values = self.table_filler.get_value(**kw)
> Module sprox.fillerbase:191 in get_value          view
>>>  count, objs = self._do_get_provider_count_and_objs(**kw)
> Module sprox.fillerbase:173 in
> _do_get_provider_count_and_objs          view
>>>  count, objs = self.__provider__.query(self.__entity__, limit, offset, 
>>> self.__limit_fields__, order_by, desc)
> Module sprox.sa.provider:397 in query          view
>>>  count = query.count()
> Module sqlalchemy.orm.query:2375 in count          view
>>>  return self.from_self(col).scalar()
> Module sqlalchemy.orm.query:2020 in scalar          view
>>>  ret = self.one()
> Module sqlalchemy.orm.query:1989 in one          view
>>>  ret = list(self)
> Module sqlalchemy.orm.query:2032 in __iter__          view
>>>  return self._execute_and_instances(context)
> Module sqlalchemy.orm.query:2047 in _execute_and_instances
> view
>>>  result = conn.execute(querycontext.statement, self._params)
> Module sqlalchemy.engine.base:1399 in execute          view
>>>  params)
> Module sqlalchemy.engine.base:1532 in _execute_clauseelement
> view
>>>  compiled_sql, distilled_params
> Module sqlalchemy.engine.base:1640 in _execute_context          view
>>>  context)
> Module sqlalchemy.engine.base:1633 in _execute_context          view
>>>  context)
> Module sqlalchemy.engine.default:330 in do_execute          view
>>>  cursor.execute(statement, parameters)
> OperationalError: (OperationalError) no such table: SOMETABLE u'SELECT
> count(*) AS count_1 \nFROM (SELECT "SOMETABLE "."EVENTCODE" AS
> "SOMETABLE _EVENTCODE" \nFROM "SOMETABLE ") AS anon_1' ()
>
> be glad to any help with this
>
> --
> 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?hl=en.
>
>

-- 
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?hl=en.

Reply via email to