diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-10-09 07:55:07 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-10-09 07:55:07 +0000 |
| commit | 4e7436febec1f4dc10a5b32fcc4020bea751226d (patch) | |
| tree | fb78a97e0a5f96d6a5b913cbe14b6a50f910e330 /docs/tutorials | |
| parent | e8a3613bc35083acc850f206876037a735b813ed (diff) | |
| download | pyramid-4e7436febec1f4dc10a5b32fcc4020bea751226d.tar.gz pyramid-4e7436febec1f4dc10a5b32fcc4020bea751226d.tar.bz2 pyramid-4e7436febec1f4dc10a5b32fcc4020bea751226d.zip | |
route -> static directive.
Diffstat (limited to 'docs/tutorials')
10 files changed, 17 insertions, 37 deletions
diff --git a/docs/tutorials/bfgwiki2/basiclayout.rst b/docs/tutorials/bfgwiki2/basiclayout.rst index ca72fd42a..9efee63a7 100644 --- a/docs/tutorials/bfgwiki2/basiclayout.rst +++ b/docs/tutorials/bfgwiki2/basiclayout.rst @@ -42,13 +42,10 @@ following: response. You will use mostly ``<route>`` statements in a :term:`URL dispatch` based application to map URLs to code. -#. *Lines 14-17*. Register a ``<route>`` that will match with a path - that starts with ``/static/``. This points at a bit of code - (``.views.static_view``) that will serve up static resources for - us, in this case, at ``http://localhost:6543/static/`` and below. - The ``*subpath`` token captures the remainder of the path and sets - the request :term:`subpath` to a derivation of the remainder of the - path, which is relied on by the view it mentions. With this view +#. *Lines 14-17*. Register a ``<static>`` directive that will match + any URL hat starts with ``/static/``. This will serve up static + resources for us, in this case, at + ``http://localhost:6543/static/`` and below. With this declaration, we're saying that any URL that starts with ``/static`` should go to the static view; any remainder of its path (e.g. the ``/foo`` in ``/static/foo``) will be used to compose a path to a diff --git a/docs/tutorials/bfgwiki2/definingviews.rst b/docs/tutorials/bfgwiki2/definingviews.rst index b89a2c7f7..6dbea104e 100644 --- a/docs/tutorials/bfgwiki2/definingviews.rst +++ b/docs/tutorials/bfgwiki2/definingviews.rst @@ -245,9 +245,10 @@ our package's ``templates/static`` directory: This CSS file will be accessed via e.g. ``http://localhost:6543/static/style.css`` by virtue of the -``static_view`` view we've defined in the ``views.py`` file. Any -number and type of static resources can be placed in this directory -(or subdirectories) and are just referred to by URL within templates. +``<static>`` directive we've defined in the ``configure.zcml`` file. +Any number and type of static resources can be placed in this +directory (or subdirectories) and are just referred to by URL within +templates. Mapping Views to URLs in ``configure.zcml`` =========================================== @@ -256,9 +257,7 @@ The ``configure.zcml`` file contains ``route`` declarations (and a lone ``view`` declaration) which serve to map URLs via :term:`url dispatch` to view functions. First, we’ll get rid of the existing ``route`` created by the template using the name ``home``. It’s only -an example and isn’t relevant to our application. We'll leave the -static ``view`` declaration as it is, since we are going to use it to -serve CSS. +an example and isn’t relevant to our application. We then need to add four ``route`` declarations to ``configure.zcml``. Note that the *ordering* of these declarations is very important. diff --git a/docs/tutorials/bfgwiki2/src/authorization/tutorial/configure.zcml b/docs/tutorials/bfgwiki2/src/authorization/tutorial/configure.zcml index 65b29019b..001959bb1 100644 --- a/docs/tutorials/bfgwiki2/src/authorization/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki2/src/authorization/tutorial/configure.zcml @@ -6,10 +6,9 @@ <subscriber for="repoze.bfg.interfaces.INewRequest" handler=".run.handle_teardown"/> - <route - path="/static/*subpath" + <static name="static" - view=".views.static_view" + path="templates/static" /> <route diff --git a/docs/tutorials/bfgwiki2/src/authorization/tutorial/views.py b/docs/tutorials/bfgwiki2/src/authorization/tutorial/views.py index b36ad6192..cb54d0577 100644 --- a/docs/tutorials/bfgwiki2/src/authorization/tutorial/views.py +++ b/docs/tutorials/bfgwiki2/src/authorization/tutorial/views.py @@ -5,7 +5,6 @@ from docutils.core import publish_parts from webob.exc import HTTPFound from repoze.bfg.chameleon_zpt import render_template_to_response -from repoze.bfg.view import static from repoze.bfg.security import authenticated_userid from repoze.bfg.url import route_url @@ -15,8 +14,6 @@ from tutorial.models import Page # regular expression used to find WikiWords wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)") -static_view = static('templates/static') - def view_wiki(request): return HTTPFound(location = route_url('view_page', request, pagename='FrontPage')) diff --git a/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/configure.zcml b/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/configure.zcml index f6139f85e..285184c38 100644 --- a/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/configure.zcml @@ -11,10 +11,9 @@ view=".views.my_view" /> - <route - path="/static/*subpath" + <static name="static" - view=".views.static_view" + path="templates/static" /> </configure> diff --git a/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/views.py b/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/views.py index f101b2742..a98712ad5 100644 --- a/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/views.py +++ b/docs/tutorials/bfgwiki2/src/basiclayout/tutorial/views.py @@ -1,11 +1,8 @@ from repoze.bfg.chameleon_zpt import render_template_to_response -from repoze.bfg.view import static from tutorial.models import DBSession from tutorial.models import Model -static_view = static('templates/static') - def my_view(request): dbsession = DBSession() root = dbsession.query(Model).filter(Model.name==u'root').first() diff --git a/docs/tutorials/bfgwiki2/src/models/tutorial/configure.zcml b/docs/tutorials/bfgwiki2/src/models/tutorial/configure.zcml index f6139f85e..285184c38 100644 --- a/docs/tutorials/bfgwiki2/src/models/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki2/src/models/tutorial/configure.zcml @@ -11,10 +11,9 @@ view=".views.my_view" /> - <route - path="/static/*subpath" + <static name="static" - view=".views.static_view" + path="templates/static" /> </configure> diff --git a/docs/tutorials/bfgwiki2/src/models/tutorial/views.py b/docs/tutorials/bfgwiki2/src/models/tutorial/views.py index f101b2742..a98712ad5 100644 --- a/docs/tutorials/bfgwiki2/src/models/tutorial/views.py +++ b/docs/tutorials/bfgwiki2/src/models/tutorial/views.py @@ -1,11 +1,8 @@ from repoze.bfg.chameleon_zpt import render_template_to_response -from repoze.bfg.view import static from tutorial.models import DBSession from tutorial.models import Model -static_view = static('templates/static') - def my_view(request): dbsession = DBSession() root = dbsession.query(Model).filter(Model.name==u'root').first() diff --git a/docs/tutorials/bfgwiki2/src/views/tutorial/configure.zcml b/docs/tutorials/bfgwiki2/src/views/tutorial/configure.zcml index 3a7ff7fc8..1e5207ebc 100644 --- a/docs/tutorials/bfgwiki2/src/views/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki2/src/views/tutorial/configure.zcml @@ -6,10 +6,9 @@ <subscriber for="repoze.bfg.interfaces.INewRequest" handler=".run.handle_teardown"/> - <route - path="/static/*subpath" + <static name="static" - view=".views.static_view" + path="templates/static" /> <route diff --git a/docs/tutorials/bfgwiki2/src/views/tutorial/views.py b/docs/tutorials/bfgwiki2/src/views/tutorial/views.py index f9af3d3c7..9a197bd75 100644 --- a/docs/tutorials/bfgwiki2/src/views/tutorial/views.py +++ b/docs/tutorials/bfgwiki2/src/views/tutorial/views.py @@ -5,7 +5,6 @@ from docutils.core import publish_parts from webob.exc import HTTPFound from repoze.bfg.chameleon_zpt import render_template_to_response -from repoze.bfg.view import static from repoze.bfg.url import route_url from tutorial.models import DBSession @@ -14,8 +13,6 @@ from tutorial.models import Page # regular expression used to find WikiWords wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)") -static_view = static('templates/static') - def view_wiki(request): return HTTPFound(location = route_url('view_page', request, pagename='FrontPage')) |
