Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch '1.3-branch'
  • Loading branch information
mcdonc committed Mar 14, 2012
2 parents 3494279 + a678380 commit 4d22adc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
10 changes: 10 additions & 0 deletions CHANGES.txt
Expand Up @@ -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)
==================

Expand Down
14 changes: 0 additions & 14 deletions pyramid/scaffolds/__init__.py
@@ -1,6 +1,5 @@
import binascii
import os
import sys

from pyramid.compat import native_

Expand Down Expand Up @@ -51,16 +50,3 @@ class ZODBProjectTemplate(PyramidTemplate):
class AlchemyProjectTemplate(PyramidTemplate):
_template_dir = 'alchemy'
summary = 'Pyramid SQLAlchemy project using url dispatch'
def post(self, command, output_dir, vars): # pragma: no cover
val = PyramidTemplate.post(self, command, output_dir, vars)
vars = vars.copy()
vars['output_dir'] = output_dir
vars['pybin'] = os.path.join(sys.exec_prefix, 'bin')
self.out('')
self.out('Please run the "populate_%(project)s" script to set up the '
'SQL database after\ninstalling (but before starting) the '
'application.\n\n For example:\n\ncd %(output_dir)s\n'
'%(pybin)s/python setup.py develop\n'
'%(pybin)s/populate_%(project)s development.ini'
% vars)
return val
25 changes: 24 additions & 1 deletion pyramid/scaffolds/alchemy/+package+/views.py_tmpl
@@ -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.
"""

2 changes: 1 addition & 1 deletion pyramid/scaffolds/alchemy/setup.py_tmpl
Expand Up @@ -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 4d22adc

Please sign in to comment.