Ticket #1620 (closed defect: fixed)
TG 1.0.4 tries to import SQLObject even when not needed
| Reported by: | chrisz | Owned by: | anonymous |
|---|---|---|---|
| Priority: | high | Milestone: | 1.0.4 |
| Component: | TurboGears | Version: | 1.0.4.3 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I have installed TurboGears 1.0.4b2 with the intent of creating SQLAlchemy projects only, so I have not installed SQLObject. However, when I quickstart an SQLAlchemy project (with the -s option) and then try to
tg-admin sql create
TG complains about the missing SQLObject, even thought it does not need it:
File ".../tg-admin-script.py", line 8, in <module>
load_entry_point('TurboGears==1.0.4b2', 'console_scripts', 'tg-admin')()
File ".../turbogears/command/base.py", line 313, in main
command = entrypoint.load()
File ".../pkg_resources.py", line 1912, in load
File ".../turbogears/command/i18n.py", line 23, in <module>
from turbogears.toolbox.admi18n import pygettext, msgfmt, catalog
File ".../turbogears/toolbox/__init__.py", line 1, in <module>
from base import Toolbox
File ".../turbogears/toolbox/base.py", line 11, in <module>
import designer
File "../turbogears/toolbox/designer/__init__.py", line 9, in <module>
import sqlobject
ImportError: No module named sqlobject
TurboGears should run without SQLObject being installed if you don't use it.
Change History
comment:3 Changed 5 years ago by chrisz
- Status changed from closed to reopened
- Version changed from 1.0.4b2 to 1.0.4.3
- Resolution fixed deleted
- Summary changed from TG 1.0.4 tries to importing SQLObject even when not needed to TG 1.0.4 tries to import SQLObject even when not needed
Seems not to be completely solved yet. I should be possible to create and run projects without any database support (and without SQLObject or SQLAlchemy being installed).
When I run tg-admin toolbox without sqlobject being installed, I get
...
File "...\turbogears\toolbox\catwalk\__init__.py", line 12, in <module>
import sqlobject
ImportError: No module named sqlobject
Also, when I run tg-admin quickstart foo, I get
...\turbogears\toolbox\designer\__init_
_.py:15: UserWarning: SQLObject is missing, toolbox designer won't work
warnings.warn("SQLObject is missing, toolbox designer won't work")
comment:4 Changed 5 years ago by faide
Yeah! I get my excuse to postpone the 1.0.4.4 release to tomorrow... :)
comment:5 Changed 5 years ago by Chris Arndt
To solve the second issue in the comment above, the quickstart template for controllers.py needs to be changed on line 4 to:
#if $identity == 'sqlobject'
(Not tested)
comment:6 Changed 5 years ago by chrisz
The SA/SO check in the quickstart template for controllers is yet a third issue. I believe your fix for that is ok, but in addition I would move it from controllers.py to the start script where it is less distracting - controllers.py and model.py should look as simple and clean as possible.
The second issue mentioned above comes from toolbox/designer/init.py which seems to be loaded too early. I think it is an unnecessary warning anyway. It would suffice if that message pops up when you click on the designer or catwalk in the toolbox.
comment:7 Changed 5 years ago by chrisz
The second issue happens because all entry points under turbogears.command are already loaded when you run tg-admin (even tg-admin --help). This is probably only done in order to gather the help texts. As part of the commands, toolbox is loaded, and toolbox in turn imports toolbox.designer, which then prints that warning.
comment:8 Changed 5 years ago by chrisz
In r4201, moved the SA/SO checks from controller to model, plus check in startup if identity is used. Simplified the checks - I think the error raised by require() is meaningful enough (even more meaningful since it names the required version).
The tg-admin issues still need to be solved.