diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-12-25 06:44:37 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-12-25 06:44:37 +0000 |
| commit | 0ac7b075f76b3989fe9eb763b73bab827c9deccd (patch) | |
| tree | 50c8d7d38837cb468af45ee90e34efec21bf3e73 /docs | |
| parent | a0169ff21b5cd7446bf0289bffdb52de8dc61290 (diff) | |
| download | pyramid-0ac7b075f76b3989fe9eb763b73bab827c9deccd.tar.gz pyramid-0ac7b075f76b3989fe9eb763b73bab827c9deccd.tar.bz2 pyramid-0ac7b075f76b3989fe9eb763b73bab827c9deccd.zip | |
Fix syntax errors found via manuel, and add manuel-style markers to prevent
untestable code blocks from being tested.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/api/chameleon_text.rst | 5 | ||||
| -rw-r--r-- | docs/api/chameleon_zpt.rst | 5 | ||||
| -rw-r--r-- | docs/designdefense.rst | 8 | ||||
| -rw-r--r-- | docs/narr/configuration.rst | 6 | ||||
| -rw-r--r-- | docs/narr/events.rst | 1 | ||||
| -rw-r--r-- | docs/narr/hooks.rst | 2 | ||||
| -rw-r--r-- | docs/narr/models.rst | 10 | ||||
| -rw-r--r-- | docs/narr/resources.rst | 5 | ||||
| -rw-r--r-- | docs/narr/scanning.rst | 1 | ||||
| -rw-r--r-- | docs/narr/security.rst | 4 | ||||
| -rw-r--r-- | docs/narr/templates.rst | 1 | ||||
| -rw-r--r-- | docs/narr/urldispatch.rst | 3 | ||||
| -rw-r--r-- | docs/narr/views.rst | 9 | ||||
| -rw-r--r-- | docs/narr/webob.rst | 1 | ||||
| -rw-r--r-- | docs/tutorials/bfgwiki/authorization.rst | 5 | ||||
| -rw-r--r-- | docs/tutorials/bfgwiki/viewdecorators.rst | 5 | ||||
| -rw-r--r-- | docs/tutorials/bfgwiki2/authorization.rst | 5 | ||||
| -rw-r--r-- | docs/tutorials/gae/index.rst | 6 | ||||
| -rw-r--r-- | docs/whatsnew-1.1.rst | 3 |
19 files changed, 66 insertions, 19 deletions
diff --git a/docs/api/chameleon_text.rst b/docs/api/chameleon_text.rst index f56caeda9..51e5fc58c 100644 --- a/docs/api/chameleon_text.rst +++ b/docs/api/chameleon_text.rst @@ -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 diff --git a/docs/api/chameleon_zpt.rst b/docs/api/chameleon_zpt.rst index cd5f0ac65..0971daca3 100644 --- a/docs/api/chameleon_zpt.rst +++ b/docs/api/chameleon_zpt.rst @@ -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 diff --git a/docs/designdefense.rst b/docs/designdefense.rst index 9c6e2eb39..e4ce4f56d 100644 --- a/docs/designdefense.rst +++ b/docs/designdefense.rst @@ -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: @@ -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: @@ -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) @@ -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: diff --git a/docs/narr/configuration.rst b/docs/narr/configuration.rst index e56d9f1d1..3183d278a 100644 --- a/docs/narr/configuration.rst +++ b/docs/narr/configuration.rst @@ -326,6 +326,7 @@ this particular :mod:`repoze.bfg` application. Beginning Configuration ~~~~~~~~~~~~~~~~~~~~~~~ +.. ignore-next-block .. code-block:: python :linenos: @@ -344,6 +345,7 @@ associated with the configurator to become "current". Adding Configuration ~~~~~~~~~~~~~~~~~~~~ +.. ignore-next-block .. code-block:: python :linenos: @@ -445,6 +447,7 @@ ends with ``/goodbye``. Ending Configuration ~~~~~~~~~~~~~~~~~~~~ +.. ignore-next-block .. code-block:: python :linenos: @@ -462,6 +465,7 @@ associated with the configurator. WSGI Application Creation ~~~~~~~~~~~~~~~~~~~~~~~~~ +.. ignore-next-block .. code-block:: python :linenos: @@ -493,6 +497,7 @@ when it visits the URL with the path info ``/goodbye``. WSGI Application Serving ~~~~~~~~~~~~~~~~~~~~~~~~ +.. ignore-next-block .. code-block:: python :linenos: @@ -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: diff --git a/docs/narr/events.rst b/docs/narr/events.rst index 6dac04add..c257ddb86 100644 --- a/docs/narr/events.rst +++ b/docs/narr/events.rst @@ -115,6 +115,7 @@ file: Or imperatively via the :meth:`repoze.bfg.configuration.Configurator.add_subscriber` method: +.. ignore-next-block .. code-block:: python :linenos: diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 862019209..f8ad29832 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -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. """ diff --git a/docs/narr/models.rst b/docs/narr/models.rst index 5002101d5..fdd8af9bc 100644 --- a/docs/narr/models.rst +++ b/docs/narr/models.rst @@ -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 @@ -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 diff --git a/docs/narr/resources.rst b/docs/narr/resources.rst index ea16c814a..91e4aee92 100644 --- a/docs/narr/resources.rst +++ b/docs/narr/resources.rst @@ -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: @@ -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: @@ -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: @@ -173,6 +176,7 @@ For example: Individual subdirectories within a package can also be overridden: +.. ignore-next-block .. code-block:: python :linenos: @@ -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: diff --git a/docs/narr/scanning.rst b/docs/narr/scanning.rst index 1276c058d..a7f47efd4 100644 --- a/docs/narr/scanning.rst +++ b/docs/narr/scanning.rst @@ -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: diff --git a/docs/narr/security.rst b/docs/narr/security.rst index f88456730..5cebd9792 100644 --- a/docs/narr/security.rst +++ b/docs/narr/security.rst @@ -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() @@ -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: diff --git a/docs/narr/templates.rst b/docs/narr/templates.rst index c8778ffdf..1ea8da369 100644 --- a/docs/narr/templates.rst +++ b/docs/narr/templates.rst @@ -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: diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index 4299faba7..ac604e347 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -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: @@ -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 @@ -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 diff --git a/docs/narr/views.rst b/docs/narr/views.rst index 13b73b28e..a073bb6d8 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -651,6 +651,7 @@ purpose. An example might reside in a bfg application module ``views.py``: +.. ignore-next-block .. code-block:: python :linenos: @@ -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: @@ -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: @@ -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): @@ -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: diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst index 2886190f5..8dbdef6f2 100644 --- a/docs/narr/webob.rst +++ b/docs/narr/webob.rst @@ -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 diff --git a/docs/tutorials/bfgwiki/authorization.rst b/docs/tutorials/bfgwiki/authorization.rst index 8d3f08d6a..cb0f8439e 100644 --- a/docs/tutorials/bfgwiki/authorization.rst +++ b/docs/tutorials/bfgwiki/authorization.rst @@ -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: diff --git a/docs/tutorials/bfgwiki/viewdecorators.rst b/docs/tutorials/bfgwiki/viewdecorators.rst index a1b2810d8..265adac4f 100644 --- a/docs/tutorials/bfgwiki/viewdecorators.rst +++ b/docs/tutorials/bfgwiki/viewdecorators.rst @@ -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: @@ -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: @@ -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: @@ -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: @@ -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 diff --git a/docs/tutorials/bfgwiki2/authorization.rst b/docs/tutorials/bfgwiki2/authorization.rst index 9aeb98505..df93cb454 100644 --- a/docs/tutorials/bfgwiki2/authorization.rst +++ b/docs/tutorials/bfgwiki2/authorization.rst @@ -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) diff --git a/docs/tutorials/gae/index.rst b/docs/tutorials/gae/index.rst index e24866c77..8d7f89311 100644 --- a/docs/tutorials/gae/index.rst +++ b/docs/tutorials/gae/index.rst @@ -186,7 +186,7 @@ system. HTTPError: HTTP Error 400: Bad Request Rolling back the update. Error 400: --- begin server output --- - Max number of files and blobs is 1000. + Max number of files and blobs is 3000. --- end server output --- If you do experience this error, you will be able to get around @@ -243,7 +243,7 @@ First, see which packages are available for zipping: .. code-block:: bash :linenos: - $ bin/pip zip -l + $ bin/pip zip -l This shows your zipped packages (by default, none) and your unzipped packages. You can zip a package like so: @@ -251,7 +251,7 @@ packages. You can zip a package like so: .. code-block:: bash :linenos: - $ bin/pip zip pytz-2009g-py2.5.egg + $ bin/pip zip pytz-2009g-py2.5.egg Note that it requires the whole egg file name. For a BFG app, the following packages are good candidates to be zipped. diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst index d88e424ce..c2573ae55 100644 --- a/docs/whatsnew-1.1.rst +++ b/docs/whatsnew-1.1.rst @@ -59,6 +59,7 @@ name` could be spelled via a ``@bfg_view`` decorator with a different ``for_`` parameter. The view ultimately chosen would be based on the :term:`context` type based on the ``for_`` attribute like so: +.. ignore-next-block .. code-block:: python from webob import Response @@ -90,6 +91,7 @@ implies that the view will be called when the class or interface mentioned as ``containment`` is present with respect to any instance in the :term:`lineage` of the context: +.. ignore-next-block .. code-block:: python from webob import Response @@ -400,6 +402,7 @@ You can generate a URL to a resource which lives within the ``templates/static`` subdirectory using the ``static_url`` API like so: +.. ignore-next-block .. code-block:: python :linenos: |
