Skip to content

Commit

Permalink
Fix syntax errors found via manuel, and add manuel-style markers to p…
Browse files Browse the repository at this point in the history
…revent

untestable code blocks from being tested.
  • Loading branch information
Chris McDonough committed Dec 25, 2009
1 parent a0169ff commit 0ac7b07
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 19 deletions.
5 changes: 3 additions & 2 deletions docs/api/chameleon_text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ view file, use the ``as`` feature of the Python import statement,
e.g.:

.. code-block:: python
:linenos:
from repoze.chameleon_zpt import render_template as zpt_render
from repoze.chameleon_text import render_template as text_render
from repoze.bfg.chameleon_zpt import render_template as zpt_render
from repoze.bfg.chameleon_text import render_template as text_render
5 changes: 3 additions & 2 deletions docs/api/chameleon_zpt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ view file, use the ``as`` feature of the Python import statement,
e.g.:

.. code-block:: python
:linenos:
from repoze.chameleon_zpt import render_template as zpt_render
from repoze.chameleon_text import render_template as text_render
from repoze.bfg.chameleon_zpt import render_template as zpt_render
from repoze.bfg.chameleon_text import render_template as text_render
8 changes: 7 additions & 1 deletion docs/designdefense.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ registry" is not particularly pretty or intuitive, and sometimes it's
just plain obtuse. Likewise, the conceptual load on a casual source
code reader of code that uses the ZCA global API is somewhat high.
Consider a ZCA neophyte reading the code that performs a typical
"unnamed utility" lookup using the ``zope.component.getUtility``
"unnamed utility" lookup using the :func:`zope.component.getUtility`
global API:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -109,6 +110,7 @@ which returns the userid present in the current request or ``None`` if
no userid is present in the current request. The application
developer calls it like so:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -695,9 +697,12 @@ associated "urlconf" such as ``r'^polls/(?P<poll_id>\d+)/$``:
Zope, likewise allows you to add arbitrary keyword and positional
arguments to any method of a model object found via traversal:

.. ignore-next-block
.. code-block:: python
:linenos:
from persistent import Persistent
class MyZopeObject(Persistent):
def aview(self, a, b, c=None):
return '%s %s %c' % (a, b, c)
Expand Down Expand Up @@ -1093,6 +1098,7 @@ instance:
Some folks understandably don't want to think about the submodule
organization, and would rather be able to do:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
6 changes: 6 additions & 0 deletions docs/narr/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ this particular :mod:`repoze.bfg` application.
Beginning Configuration
~~~~~~~~~~~~~~~~~~~~~~~

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -344,6 +345,7 @@ associated with the configurator to become "current".
Adding Configuration
~~~~~~~~~~~~~~~~~~~~

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -445,6 +447,7 @@ ends with ``/goodbye``.
Ending Configuration
~~~~~~~~~~~~~~~~~~~~

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -462,6 +465,7 @@ associated with the configurator.
WSGI Application Creation
~~~~~~~~~~~~~~~~~~~~~~~~~

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -493,6 +497,7 @@ when it visits the URL with the path info ``/goodbye``.
WSGI Application Serving
~~~~~~~~~~~~~~~~~~~~~~~~

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -750,6 +755,7 @@ just spelling things differently, using XML instead of Python.
In our previously defined application, in which we added view
configurations imperatively, we saw this code:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
1 change: 1 addition & 0 deletions docs/narr/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ file:
Or imperatively via the
:meth:`repoze.bfg.configuration.Configurator.add_subscriber` method:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
2 changes: 2 additions & 0 deletions docs/narr/hooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ The API that must be implemented by a class that provides
.. code-block:: python
:linenos:
from zope.interface import Interface
class IContextURL(Interface):
""" An adapter which deals with URLs related to a context.
"""
Expand Down
10 changes: 5 additions & 5 deletions docs/narr/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ interface (as opposed to its class). To do so, use the
self.author = author
self.created = datetime.datetime.now()
entry = BlogEntry()
directlyProvides(IBlogEntry, entry)
entry = BlogEntry('title', 'body', 'author')
directlyProvides(entry, IBlogEntry)
If a model object already has instance-level interface declarations
that you don't want to disturb, use the
Expand All @@ -124,9 +124,9 @@ that you don't want to disturb, use the
self.author = author
self.created = datetime.datetime.now()
entry = BlogEntry()
directlyProvides(IBlogEntry1, entry)
alsoProvides(IBlogEntry2, entry)
entry = BlogEntry('title', 'body', 'author')
directlyProvides(entry, IBlogEntry1)
alsoProvides(entry, IBlogEntry2)
See the :ref:`views_chapter` for more information about why providing
models with an interface can be an interesting thing to do with regard
Expand Down
5 changes: 5 additions & 0 deletions docs/narr/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ example, the application might address the resource named
``templates/some_template.pt`` using that API within a ``views.py``
file inside a ``myapp`` package:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -150,6 +151,7 @@ An individual call to
:meth:`repoze.bfg.configuration.Configurator.override_resource` can
override a single resource. For example:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -165,6 +167,7 @@ optional. If they are not specified, the override attempts to resolve
every lookup into a package from the directory of another package.
For example:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -173,6 +176,7 @@ For example:
Individual subdirectories within a package can also be overridden:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -203,6 +207,7 @@ construction file resides (or the ``package`` argument to the
:class:`repoze.bfg.configuration.Configurator` class construction).
For example:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
1 change: 1 addition & 0 deletions docs/narr/scanning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ this is best represented as the scanner translating the arguments to
:meth:`repoze.bfg.configuration.Configurator.add_view` method,
effectively:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
4 changes: 3 additions & 1 deletion docs/narr/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ application setup to specify an authentication policy.

For example:

.. ignore-next-block
.. code-block:: python
:linenos:
from repoze.bfg.configuration import Configurator
from repoze.bfg.authentication import AuthTktAutenticationPolicy
from repoze.bfg.authentication import AuthTktAuthenticationPolicy
from repoze.bfg.authorization import ACLAuthorizationPolicy
authentication_policy = AuthTktAuthenticationPolicy('seekrit')
authorization_policy = ACLAuthorizationPolicy()
Expand Down Expand Up @@ -124,6 +125,7 @@ The equivalent view registration including the 'add' permission name
may be performed via the ``bfg_view`` decorator within the "views"
module of your project's package

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
1 change: 1 addition & 0 deletions docs/narr/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ then return that string as the body of a :term:`WebOb`
<http://www.makotemplates.org/>`_ installed, here's an example of
using Mako from within a :mod:`repoze.bfg` :term:`view`:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
3 changes: 3 additions & 0 deletions docs/narr/urldispatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The :meth:`repoze.bfg.configuration.Configurator.add_route` method
adds a single :term:`route configuration` to the :term:`application
registry`. Here's an example:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -638,6 +639,7 @@ based on route paths. For example, if you've configured a route in
ZCML with the ``name`` "foo" and the ``path`` ":a/:b/:c", you might do
this.

.. ignore-next-block
.. code-block:: python
from repoze.bfg.url import route_url
Expand Down Expand Up @@ -730,6 +732,7 @@ SQLAlchemy, and you'd like the current SQLAlchemy database session to
be removed after each request. Put the following in the
``mypackage.run`` module:

.. ignore-next-block
.. code-block:: python
from mypackage.sql import DBSession
Expand Down
9 changes: 7 additions & 2 deletions docs/narr/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ purpose.

An example might reside in a bfg application module ``views.py``:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -659,9 +660,9 @@ An example might reside in a bfg application module ``views.py``:
from repoze.bfg.chameleon_zpt import render_template_to_response
@bfg_view(name='my_view', request_method='POST', for_=MyModel,
permission='read')
permission='read', renderer='templates/my.pt')
def my_view(request):
return render_template_to_response('templates/my.pt')
return {'a':1}
Using this decorator as above replaces the need to add this ZCML to
your application registry:
Expand All @@ -675,10 +676,12 @@ your application registry:
name="my_view"
permission="read"
request_method="POST"
renderer="templates/my.pt"
/>
Or replaces the need to add this imperative configuration stanza:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -759,6 +762,7 @@ All arguments may be omitted. For example:
:linenos:
from webob import Response
from repoze.bfg.view import bfg_view
@bfg_view()
def my_view(request):
Expand Down Expand Up @@ -1614,6 +1618,7 @@ filesystem at ``/path/to/static/dir`` mounted at the URL path
:mod:`repoze.bfg.view` 's ``static`` class inside a ``static.py`` file
in your application root as below.

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
1 change: 1 addition & 0 deletions docs/narr/webob.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ the error. For instance, ``webob.exc.HTTPNotFound``. It subclasses
``Response``, so you can manipulate the instances in the same way. A
typical example is:

.. ignore-next-block
.. code-block:: python
from webob.exc import HTTPNotFound
Expand Down
5 changes: 4 additions & 1 deletion docs/tutorials/bfgwiki/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,18 @@ Then we need to change each of our ``view_page``, ``edit_page`` and
``add_page`` views in ``views.py`` to pass a "logged in" parameter
into its template. We'll add something like this to each view body:

.. ignore-next-block
.. code-block:: python
:linenos:
from repoze.bfg.security import authenticated_userid
logged_in = authenticated_userid(request)
We'll then change the return value of each view that has an associated
``renderer`` to pass the `resulting `logged_in`` value to the
template, e.g.:
template. For example:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down
5 changes: 4 additions & 1 deletion docs/tutorials/bfgwiki/viewdecorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The ``view_wiki`` view function

The decorator above the ``view_wiki`` function will be:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -70,6 +71,7 @@ The ``view_page`` view function

The decorator above the ``view_page`` function will be:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -96,6 +98,7 @@ The ``add_page`` view function

The decorator above the ``add_page`` function will be:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand All @@ -122,6 +125,7 @@ The ``edit_page`` view function

The decorator above the ``edit_page`` function will be:

.. ignore-next-block
.. code-block:: python
:linenos:
Expand Down Expand Up @@ -195,7 +199,6 @@ On Windows:

.. code-block:: bat
c:\bigfntut\tutorial> ..\Scripts\python setup.py test -q
Hopefully nothing will have changed. The expected result looks
Expand Down
5 changes: 4 additions & 1 deletion docs/tutorials/bfgwiki2/authorization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,21 @@ Then we need to change each of our ``view_page``, ``edit_page`` and
``add_page`` views in ``views.py`` to pass a "logged in" parameter to
its template. We'll add something like this to each view body:

.. ignore-next-block
.. code-block:: python
:linenos:
from repoze.bfg.security import authenticated_userid
logged_in = authenticated_userid(request)
We'll then change the return value of these views to pass the
`resulting `logged_in`` value to the template, e.g.:

.. ignore-next-block
.. code-block:: python
:linenos:
return dict(page = page,
return dict(page = context,
content = content,
logged_in = logged_in,
edit_url = edit_url)
Expand Down
Loading

0 comments on commit 0ac7b07

Please sign in to comment.