Permalink
Browse files

Changes to support #481.

- The ``alchemy`` scaffold now shows an informative error message in the
  browser if the person creating the project forgets to run the
  initialization script.

- The ``alchemy`` scaffold initialization script is now called
  ``initialize_<projectname>_db`` instead of ``populate_<projectname>``.
  • Loading branch information...
1 parent 0da8d19 commit a678380044bdb762fbff7559dc2f9b7e671e5337 @mcdonc mcdonc committed Mar 14, 2012
View
@@ -7,6 +7,16 @@ Bug Fixes
- ``config.add_view(<aninstancemethod>)`` raised AttributeError involving
``__text__``. See https://github.com/Pylons/pyramid/issues/461
+Scaffolds
+---------
+
+- The ``alchemy`` scaffold now shows an informative error message in the
+ browser if the person creating the project forgets to run the
+ initialization script.
+
+- The ``alchemy`` scaffold initialization script is now called
+ ``initialize_<projectname>_db`` instead of ``populate_<projectname>``.
+
1.3b2 (2012-03-02)
==================
@@ -1,11 +1,34 @@
+from pyramid.response import Response
from pyramid.view import view_config
+from sqlalchemy.exc import DBAPIError
+
from .models import (
DBSession,
MyModel,
)
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
- one = DBSession.query(MyModel).filter(MyModel.name=='one').first()
+ try:
+ one = DBSession.query(MyModel).filter(MyModel.name=='one').first()
+ except DBAPIError:
+ return Response(conn_err_msg, content_type='text/plain', status_int=500)
return {'one':one, 'project':'{{project}}'}
+
+conn_err_msg = """\
+Pyramid is having a problem using your SQL database. The problem
+might be caused by one of the following things:
+
+1. You may need to run the "initialize_{{project}}_db" script
+ to initialize your database tables. Check your virtual
+ environment's "bin" directory for this script and try to run it.
+
+2. Your database server may not be running. Check that the
+ database server referred to by the "sqlalchemy.url" setting in
+ your "development.ini" file is running.
+
+After you fix the problem, please restart the Pyramid application to
+try it again.
+"""
+
@@ -39,7 +39,7 @@ setup(name='{{project}}',
[paste.app_factory]
main = {{package}}:main
[console_scripts]
- populate_{{project}} = {{package}}.scripts.populate:main
+ initialize_{{project}}_db = {{package}}.scripts.initializedb:main
""",
)

0 comments on commit a678380

Please sign in to comment.