#1036: Web app returns HTTP 500 error if sqlalchemy is present
------------------------+---------------------------------------------------
Reporter: barryh | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 0.9a6
Severity: normal | Keywords: sqlalchemy 500 quickstart tutorial
------------------------+---------------------------------------------------
I recently encountered an issue with TurboGears 0.9a6 where a sample
application created via 'tg-admin quickstart' would consistently return an
HTTP 500 error upon attempting to open the default page via a web browser
after successfully starting it up. This instance of TurboGears is running
on an i386 Debian sid installation.
== Issue ==
A sample application is created successfully:
{{{
$ tg-admin quickstart
Enter project name: Wiki 20
Enter package name [wiki20]:
Do you need Identity (usernames/passwords) in this project? [no]
Selected and implied templates:
TurboGears#tgbase tg base template
TurboGears#turbogears web framework
Variables:
identity: none
package: wiki20
project: Wiki-20
Creating template tgbase
Creating directory ./Wiki-20
...
Copying start-+package+.py_tmpl to ./Wiki-20/start-wiki20.py
Running /usr/bin/python2.4 setup.py egg_info
Adding TurboGears to paster_plugins.txt
running egg_info
writing requirements to Wiki_20.egg-info/requires.txt
writing Wiki_20.egg-info/PKG-INFO
writing top-level names to Wiki_20.egg-info/top_level.txt
reading manifest file 'Wiki_20.egg-info/SOURCES.txt'
writing manifest file 'Wiki_20.egg-info/SOURCES.txt'
}}}
After installation, the application is initialized but returns an HTTP 500
error when opened in a browser. The trace information displayed on the
500 error page is as follows:
= 500 Internal error =
The server encountered an unexpected condition which prevented it from
fulfilling the request.
{{{
Page handler: <bound method Root.index of <wiki20.controllers.Root object
at 0xa73364ac>>
Traceback (most recent call last):
File "/var/lib/python-support/python2.4/cherrypy/_cphttptools.py", line
105, in _run
self.main()
File "/var/lib/python-support/python2.4/cherrypy/_cphttptools.py", line
254, in main
body = page_handler(*virtual_path, **self.params)
File "<string>", line 3, in index
File "/var/lib/python-support/python2.4/turbogears/controllers.py", line
273, in expose
output = database.run_with_transaction(
File "/var/lib/python-support/python2.4/turbogears/database.py", line
220, in run_with_transaction
sqlalchemy.objectstore.clear()
AttributeError: 'module' object has no attribute 'objectstore'
}}}
Powered by CherryPy 2.2.1
It occurred to me that I had installed the python-sqlalchemy Debian
package (currently at 0.2.5) for some other work, so on a whim I purged it
from the system. After purging it, the application started just fine and
ran without errors.
It appears that the problematic code is found in
<svnco>/turbogears/database.py is the culprit, in lines 11-30 of the 0.9a6
tag:
{{{
# Provide support for sqlalchemy
try:
import sqlalchemy
from sqlalchemy.ext.proxy import AutoConnectEngine
# declare the PackageEngine class
class PackageEngine(AutoConnectEngine):
'''
An AutoConnectEngine that looks for the dburi based on a package
name.
'''
def __init__(self, package_name, *args, **kwargs):
def lookup_dburi():
uri= turbogears.config.get( "%s.sqlalchemy.dburi" %
package_name
,
None )
return uri or turbogears.config.get( "sqlalchemy.dburi",
None )
AutoConnectEngine.__init__(self, lookup_dburi, *args,
**kwargs)
except ImportError:
sqlalchemy= None
}}}
I am not sure whether the issue is the presence of sqlalchemy altogether,
or simply that the version currently in the Debian repository is not
appropriate for TurboGears to use. Another possibility might be that the
absence of a sqlalchemy.dburi setting in dev.cfg is producing an
undesirable outcome.
== Steps to Reproduce ==
I can reliably reproduce the issue via the following steps:
1.) Reinstall the python-sqlalchemy package: {{{$ apt-get install python-
sqlalchemy}}}
2.) Restart the functioning sample application instance: {{{$ python2.4
start-wiki20.py}}}
3.) Point a browser to http://localhost:8080/ -- the 500 error appears
4.) Remove the python-sqlalchemy package: {{{$ dpkg -r python-
sqlalchemy}}}
5.) Restart the functioning sample application instance: {{{$ python2.4
start-wiki20.py}}}
6.) Point a browser to http://localhost:8080/ -- the page renders normally
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1036>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" 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-tickets
-~----------~----~----~----~------~----~------~--~---