Impossible to reproduce example "Using Multiple Databases"

27 views
Skip to first unread message

Max Snow

unread,
Apr 14, 2017, 7:42:53 AM4/14/17
to TurboGears
Hi.
I tried to reproduce example shown here: http://turbogears.readthedocs.io/en/latest/cookbook/multiple-databases.html#using-multiple-databases-in-turbogears
I did steps word to word.
After everything done I execute "gearbox setup-app" and the result is:
----
Traceback (most recent call last):
  File "/home/tg2env/site-packages/gearbox/main.py", line 167, in _run_subcommand
    return cmd.run(parsed_args)
  File "/home/tg2env/site-packages/gearbox/command.py", line 31, in run
    self.take_action(parsed_args)
  File "/home/tg2env/site-packages/gearbox/commands/setup_app.py", line 53, in take_action
    self._setup_config(dist, config_file, section, {}, verbosity=self.app.options.verbose_level)
  File "/home/tg2env/site-packages/gearbox/commands/setup_app.py", line 93, in _setup_config
    self._call_setup_app(mod.setup_app, filename, section, vars)
  File "/home/tg2env/site-packages/gearbox/commands/setup_app.py", line 108, in _call_setup_app
    func(None, conf, vars)
  File "/home/MyProject/myproj/websetup/__init__.py", line 18, in setup_app
    load_environment(conf.global_conf, conf.local_conf)
  File "/home/tg2env/site-packages/tg/configuration/app_config.py", line 920, in load_environment
    self._setup_persistence(app_config)
  File "/home/tg2env/site-packages/tg/configuration/app_config.py", line 688, in _setup_persistence
    self._setup_sqlalchemy(conf)
  File "/home/tg2env/site-packages/tg/configuration/app_config.py", line 783, in _setup_sqlalchemy
    engine = engine_from_config(conf, 'sqlalchemy.')
  File "/home/tg2env/site-packages/sqlalchemy/engine/__init__.py", line 427, in engine_from_config
    url = options.pop('url')
KeyError: 'url'

----
I need 2 databases to split auth and common stuff (to prevent access to users' password hashes).

Some things I did on my own (I'm not sure I was correct):

1) Inside 'myapp/config/app_cfg.py' I used ...
----
class MultiDBAppConfig(AppConfig):
    def _setup_sqlalchemy(self, conf):

----
... instead of ...
----
class MultiDBAppConfig(AppConfig):
    def setup_sqlalchemy(self):

----
2) I made changes inside 'myapp/websetup/schema.py => def setup_schema' instead of 'myapp/websetup.py => def setup_app'

If I did something wrong, please let me know.
If I did everything right, could You please correct this part of documentation? Or maybe I read instructions from wrong source?

Best Regards,
Maxim.

Alessandro Molina

unread,
Apr 14, 2017, 11:13:55 AM4/14/17
to TurboGears
The documentation in that paragraph it's in "rough" state and depends heavily on TG internals, so it's something that can break easily on any new release and it's allowed "at your own risk". I promise I'll update that paragraph to make it work with TG2.3 during the weekend so you can check that your changes match with the required ones.

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+unsubscribe@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Alessandro Molina

unread,
Apr 15, 2017, 6:23:55 PM4/15/17
to TurboGears
The development branch of documentation should cover all the required changes for multiple databases support: http://turbogears.readthedocs.io/en/development/cookbook/multiple-databases.html#using-multiple-databases-in-turbogears

Max Snow

unread,
Apr 17, 2017, 3:24:02 AM4/17/17
to TurboGears
New documentation contains more than I expected.
Thank You very much!

воскресенье, 16 апреля 2017 г., 1:23:55 UTC+3 пользователь Alessandro Molina написал:
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages