Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1.4-branch'

  • Loading branch information...
commit f55cec52d3a2a64345ac2bce30c26ab274c8baea 2 parents 3c05fb0 + 098599b
@mcdonc mcdonc authored
View
9 CHANGES.txt
@@ -19,6 +19,15 @@ Features
token in the request's session, the view will be permitted to execute.
Otherwise, it will not be permitted to execute.
+- Add ``Base.metadata.bind = engine`` to alchemy template, so that tables
+ defined imperatively will work.
+
+Documentation
+-------------
+
+- update wiki2 SQLA tutorial with the changes required after inserting
+ ``Base.metadata.bind = engine`` into the alchemy scaffold.
+
1.4a1 (2012-09-16)
==================
View
8 docs/tutorials/wiki2/authorization.rst
@@ -112,7 +112,7 @@ parameter to our :term:`Configurator` constructor, that points to
the class we created above:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 19-20
+ :lines: 23-24
:linenos:
:emphasize-lines: 2
:language: python
@@ -144,7 +144,7 @@ add these import statements:
Now add those policies to the configuration:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 16-22
+ :lines: 20-26
:linenos:
:emphasize-lines: 1-3,6-7
:language: python
@@ -206,7 +206,7 @@ Go back to ``tutorial/tutorial/__init__.py`` and add these two
routes:
.. literalinclude:: src/authorization/tutorial/__init__.py
- :lines: 25-26
+ :lines: 29-30
:linenos:
:language: python
@@ -333,7 +333,7 @@ when we're done:
.. literalinclude:: src/authorization/tutorial/__init__.py
:linenos:
- :emphasize-lines: 2-3,7,16-18,20-22,25-26
+ :emphasize-lines: 2-3,7,23-24,20-26,29-30
:language: python
(Only the highlighted lines need to be added.)
View
28 docs/tutorials/wiki2/basiclayout.rst
@@ -51,21 +51,33 @@ The main function first creates a SQLAlchemy database engine using
(something like ``sqlite://``):
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 9
+ :lines: 12
:linenos:
:language: py
-``main`` then initializes our SQL database using SQLAlchemy, passing it the
+``main`` then initializes our SQLAlchemy session object, passing it the
engine:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 10
+ :lines: 13
+ :language: py
+
+``main`` subsequently initializes our SQLAlchemy declarative Base object,
+assigning the engine we created to the ``bind`` attribute of it's
+``metadata`` object. This allows table definitions done imperatively
+(instead of declaratively, via a class statement) to work. We won't use any
+such tables in our application, but if you add one later, long after you've
+forgotten about this tutorial, you won't be left scratching your head when it
+doesn't work.
+
+ .. literalinclude:: src/basiclayout/tutorial/__init__.py
+ :lines: 14
:language: py
The next step of ``main`` is to construct a :term:`Configurator` object:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 11
+ :lines: 15
:language: py
``settings`` is passed to the Configurator as a keyword argument with the
@@ -78,7 +90,7 @@ deployment-related values such as ``pyramid.reload_templates``,
two arguments: ``static`` (the name), and ``static`` (the path):
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 12
+ :lines: 16
:language: py
This registers a static resource view which will match any URL that starts
@@ -96,7 +108,7 @@ via the :meth:`pyramid.config.Configurator.add_route` method that will be
used when the URL is ``/``:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 13
+ :lines: 17
:language: py
Since this route has a ``pattern`` equalling ``/`` it is the route that will
@@ -109,7 +121,7 @@ view configuration will be registered, which will allow one of our
application URLs to be mapped to some code.
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 14
+ :lines: 18
:language: py
Finally, ``main`` is finished configuring things, so it uses the
@@ -117,7 +129,7 @@ Finally, ``main`` is finished configuring things, so it uses the
:term:`WSGI` application:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
- :lines: 15
+ :lines: 19
:language: py
View Declarations via ``views.py``
View
2  docs/tutorials/wiki2/definingviews.rst
@@ -342,7 +342,7 @@ something like:
.. literalinclude:: src/views/tutorial/__init__.py
:linenos:
:language: python
- :emphasize-lines: 13-16
+ :emphasize-lines: 17-20
(The highlighted lines are the ones that need to be added or edited.)
View
6 docs/tutorials/wiki2/src/authorization/tutorial/__init__.py
@@ -6,13 +6,17 @@
from tutorial.security import groupfinder
-from .models import DBSession
+from .models import (
+ DBSession,
+ Base,
+ )
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
+ Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder)
authz_policy = ACLAuthorizationPolicy()
View
6 docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py
@@ -1,13 +1,17 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
-from .models import DBSession
+from .models import (
+ DBSession,
+ Base,
+ )
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
+ Base.metadata.bind = engine
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
View
6 docs/tutorials/wiki2/src/models/tutorial/__init__.py
@@ -1,13 +1,17 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
-from .models import DBSession
+from .models import (
+ DBSession,
+ Base,
+ )
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
+ Base.metadata.bind = engine
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
View
6 docs/tutorials/wiki2/src/tests/tutorial/__init__.py
@@ -6,13 +6,17 @@
from tutorial.security import groupfinder
-from .models import DBSession
+from .models import (
+ DBSession,
+ Base,
+ )
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
+ Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=groupfinder)
authz_policy = ACLAuthorizationPolicy()
View
6 docs/tutorials/wiki2/src/views/tutorial/__init__.py
@@ -1,13 +1,17 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
-from .models import DBSession
+from .models import (
+ DBSession,
+ Base,
+ )
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
+ Base.metadata.bind = engine
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('view_wiki', '/')
View
6 pyramid/scaffolds/alchemy/+package+/__init__.py
@@ -1,13 +1,17 @@
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
-from .models import DBSession
+from .models import (
+ DBSession,
+ Base,
+ )
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
+ Base.metadata.bind = engine
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')

0 comments on commit f55cec5

Please sign in to comment.
Something went wrong with that request. Please try again.