From b9b2ee39c251dd68a12e717e1f6d9d02a29efe9a Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Fri, 30 Nov 2012 09:27:09 -0800 Subject: A bunch of minor tweaks to the wiki2 tutorial in docs/tutorials/wiki2 --- docs/tutorials/wiki2/basiclayout.rst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'docs/tutorials/wiki2/basiclayout.rst') diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index 4f73dc914..ed98da183 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -45,7 +45,7 @@ When you invoke the ``pserve development.ini`` command, the ``main`` function above is executed. It accepts some settings and returns a :term:`WSGI` application. (See :ref:`startup_chapter` for more about ``pserve``.) -The main function first creates a SQLAlchemy database engine using +The main function first creates a :term:`SQLAlchemy` database engine using ``engine_from_config`` from the ``sqlalchemy.`` prefixed settings in the ``development.ini`` file's ``[app:main]`` section. This will be a URI (something like ``sqlite://``): @@ -62,7 +62,7 @@ engine: :lines: 13 :language: py -``main`` subsequently initializes our SQLAlchemy declarative Base object, +``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 @@ -94,9 +94,9 @@ two arguments: ``static`` (the name), and ``static`` (the path): :language: py This registers a static resource view which will match any URL that starts -with the prefix ``/static`` (by virtue of the first argument to add_static -view). This will serve up static resources for us from within the ``static`` -directory of our ``tutorial`` package, in this case, via +with the prefix ``/static`` (by virtue of the first argument to +``add_static_view``). This will serve up static resources for us from within +the ``static`` directory of our ``tutorial`` package, in this case, via ``http://localhost:6543/static/`` and below (by virtue of the second argument to add_static_view). With this declaration, we're saying that any URL that starts with ``/static`` should go to the static view; any remainder of its @@ -114,8 +114,9 @@ used when the URL is ``/``: Since this route has a ``pattern`` equalling ``/`` it is the route that will be matched when the URL ``/`` is visited, e.g. ``http://localhost:6543/``. -``main`` next calls the ``scan`` method of the configurator, which will -recursively scan our ``tutorial`` package, looking for ``@view_config`` (and +``main`` next calls the ``scan`` method of the configurator +(:meth:`pyramid.config.Configurator.scan`), which will recursively scan our +``tutorial`` package, looking for ``@view_config`` (and other special) decorators. When it finds a ``@view_config`` decorator, a view configuration will be registered, which will allow one of our application URLs to be mapped to some code. @@ -197,7 +198,7 @@ Let's examine this in detail. First, we need some imports to support later code: :linenos: :language: py -Next we set up a SQLAlchemy "DBSession" object: +Next we set up a SQLAlchemy ``DBSession`` object: .. literalinclude:: src/basiclayout/tutorial/models.py :lines: 16 @@ -230,8 +231,9 @@ To give a simple example of a model class, we define one named ``MyModel``: :linenos: :language: py -Our example model has an ``__init__`` that takes a two arguments (``name``, -and ``value``). It stores these values as ``self.name`` and ``self.value`` +Our example model has an ``__init__`` method that takes a two arguments +(``name``, and ``value``). It stores these values as ``self.name`` and +``self.value`` within the ``__init__`` function itself. The ``MyModel`` class also has a ``__tablename__`` attribute. This informs SQLAlchemy which table to use to store the data representing instances of this class. -- cgit v1.2.3 From e90fa43a8051dfc8799596e17b72fd3d3def6516 Mon Sep 17 00:00:00 2001 From: Patricio Paez Date: Sat, 1 Dec 2012 19:43:02 -0600 Subject: Sync __init__.py in SQL wiki tutorial - Update lines and emphasized-lines - No line numbers if only a single line --- docs/tutorials/wiki2/basiclayout.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'docs/tutorials/wiki2/basiclayout.rst') diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index 4f73dc914..7b9c44bb1 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -51,15 +51,14 @@ The main function first creates a SQLAlchemy database engine using (something like ``sqlite://``): .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 12 - :linenos: + :lines: 13 :language: py ``main`` then initializes our SQLAlchemy session object, passing it the engine: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 13 + :lines: 14 :language: py ``main`` subsequently initializes our SQLAlchemy declarative Base object, @@ -71,13 +70,13 @@ 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 + :lines: 15 :language: py The next step of ``main`` is to construct a :term:`Configurator` object: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 15 + :lines: 16 :language: py ``settings`` is passed to the Configurator as a keyword argument with the @@ -90,7 +89,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: 16 + :lines: 17 :language: py This registers a static resource view which will match any URL that starts @@ -108,7 +107,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: 17 + :lines: 18 :language: py Since this route has a ``pattern`` equalling ``/`` it is the route that will @@ -121,7 +120,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: 18 + :lines: 19 :language: py Finally, ``main`` is finished configuring things, so it uses the @@ -129,7 +128,7 @@ Finally, ``main`` is finished configuring things, so it uses the :term:`WSGI` application: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 19 + :lines: 20 :language: py View Declarations via ``views.py`` -- cgit v1.2.3 From 479178179df2e3554d81d8c42d7ff46b75901c62 Mon Sep 17 00:00:00 2001 From: Patricio Paez Date: Sat, 1 Dec 2012 22:30:50 -0600 Subject: Sync models.py in SQL wiki tutorial - Update lines and emphasized-lines - No line numbers if only a single line --- docs/tutorials/wiki2/basiclayout.rst | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/tutorials/wiki2/basiclayout.rst') diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index 7b9c44bb1..934bfb52a 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -200,7 +200,6 @@ Next we set up a SQLAlchemy "DBSession" object: .. literalinclude:: src/basiclayout/tutorial/models.py :lines: 16 - :linenos: :language: py ``scoped_session`` and ``sessionmaker`` are standard SQLAlchemy helpers. -- cgit v1.2.3