diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-01-03 03:39:30 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-01-03 03:39:30 +0000 |
| commit | eecdbc34962b00e35d41039af014462cf558acee (patch) | |
| tree | 784bfdf054d6f4846fb1817d1ba7b01792792dcc /docs/tutorials | |
| parent | 1dff935445ff293a7434f074c1f6bb7304174ec2 (diff) | |
| download | pyramid-eecdbc34962b00e35d41039af014462cf558acee.tar.gz pyramid-eecdbc34962b00e35d41039af014462cf558acee.tar.bz2 pyramid-eecdbc34962b00e35d41039af014462cf558acee.zip | |
Features
--------
- The ``Configurator.add_view`` method now accepts an argument named
``context``. This is an alias for the older argument named
``for_``; it is preferred over ``for_``, but ``for_`` will continue
to be supported "forever".
- The ``view`` ZCML directive now accepts an attribute named
``context``. This is an alias for the older attribute named
``for``; it is preferred over ``for``, but ``for`` will continue to
be supported "forever".
- The ``Configurator.add_route`` method now accepts an argument named
``view_context``. This is an alias for the older argument named
``view_for``; it is preferred over ``view_for``, but ``view_for``
will continue to be supported "forever".
- The ``route`` ZCML directive now accepts an attribute named
``view_context``. This is an alias for the older attribute named
``view_for``; it is preferred over ``view_for``, but ``view_for``
will continue to be supported "forever".
Documentation and Paster Templates
----------------------------------
- All uses of the ``Configurator.add_view`` method that used its
``for_`` argument now use the ``context``argument instead.
- All uses of the ``Configurator.add_route`` method that used its
``view_for`` argument now use the ``view_context``argument instead.
- All uses of the ``view`` ZCML directive that used its ``for``
attribute now use the ``context`` attribute instead.
- All uses of the ``route`` ZCML directive that used its ``view_for``
attribute now use the ``view_context`` attribute instead.
Diffstat (limited to 'docs/tutorials')
8 files changed, 44 insertions, 42 deletions
diff --git a/docs/tutorials/bfgwiki/basiclayout.rst b/docs/tutorials/bfgwiki/basiclayout.rst index 5934799b9..f0bf8ced8 100644 --- a/docs/tutorials/bfgwiki/basiclayout.rst +++ b/docs/tutorials/bfgwiki/basiclayout.rst @@ -30,12 +30,13 @@ following: #. *Line 4*. Boilerplate, the comment explains. -#. *Lines 6-10*. Register a ``<view>`` that is ``for`` a class. - ``.views.my_view`` is a *function* we write (generated by the - ``bfg_zodb`` template) that is given a ``context`` and a - ``request`` and which returns a dictionary. The ``renderer`` tag - indicates that the ``templates/mytemplate.pt`` template should be - used to turn the dictionary returned by the view into a response. +#. *Lines 6-10*. Register a ``<view>`` that names a ``context`` type + that is a class. ``.views.my_view`` is a *function* we write + (generated by the ``bfg_zodb`` template) that is given a + ``context`` object and a ``request`` and which returns a + dictionary. The ``renderer`` tag indicates that the + ``templates/mytemplate.pt`` template should be used to turn the + dictionary returned by the view into a response. ``templates/mytemplate.pt`` is a *relative* path: it names the ``mytemplate.pt`` file which lives in the ``templates`` subdirectory of the directory in which this ``configure.zcml`` diff --git a/docs/tutorials/bfgwiki/src/authorization/tutorial/login.py b/docs/tutorials/bfgwiki/src/authorization/tutorial/login.py index d9d65bdca..08b3db359 100644 --- a/docs/tutorials/bfgwiki/src/authorization/tutorial/login.py +++ b/docs/tutorials/bfgwiki/src/authorization/tutorial/login.py @@ -9,7 +9,7 @@ from repoze.bfg.security import forget from tutorial.models import Wiki from tutorial.security import USERS -@bfg_view(for_=Wiki, name='login', renderer='templates/login.pt') +@bfg_view(context=Wiki, name='login', renderer='templates/login.pt') def login(context, request): login_url = model_url(context, request, 'login') referrer = request.url @@ -36,7 +36,7 @@ def login(context, request): password = password, ) -@bfg_view(for_=Wiki, name='logout') +@bfg_view(context=Wiki, name='logout') def logout(context, request): headers = forget(request) return HTTPFound(location = model_url(context, request), diff --git a/docs/tutorials/bfgwiki/src/authorization/tutorial/views.py b/docs/tutorials/bfgwiki/src/authorization/tutorial/views.py index 26a44fcda..17ca01566 100644 --- a/docs/tutorials/bfgwiki/src/authorization/tutorial/views.py +++ b/docs/tutorials/bfgwiki/src/authorization/tutorial/views.py @@ -14,11 +14,11 @@ from tutorial.models import Wiki # regular expression used to find WikiWords wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)") -@bfg_view(for_=Wiki, permission='view') +@bfg_view(context=Wiki, permission='view') def view_wiki(context, request): return HTTPFound(location = model_url(context, request, 'FrontPage')) -@bfg_view(for_=Page, renderer='templates/view.pt', permission='view') +@bfg_view(context=Page, renderer='templates/view.pt', permission='view') def view_page(context, request): wiki = context.__parent__ @@ -41,7 +41,7 @@ def view_page(context, request): return dict(page = context, content = content, edit_url = edit_url, logged_in = logged_in) -@bfg_view(for_=Wiki, name='add_page', renderer='templates/edit.pt', +@bfg_view(context=Wiki, name='add_page', renderer='templates/edit.pt', permission='edit') def add_page(context, request): name = request.subpath[0] @@ -61,7 +61,7 @@ def add_page(context, request): return dict(page = page, save_url = save_url, logged_in = logged_in) -@bfg_view(for_=Page, name='edit_page', renderer='templates/edit.pt', +@bfg_view(context=Page, name='edit_page', renderer='templates/edit.pt', permission='edit') def edit_page(context, request): if 'form.submitted' in request.params: diff --git a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml index e15d3a65d..04e7d908d 100644 --- a/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki/src/basiclayout/tutorial/configure.zcml @@ -4,7 +4,7 @@ <include package="repoze.bfg.includes" /> <view - for=".models.MyModel" + context=".models.MyModel" view=".views.my_view" renderer="templates/mytemplate.pt" /> diff --git a/docs/tutorials/bfgwiki/src/models/tutorial/configure.zcml b/docs/tutorials/bfgwiki/src/models/tutorial/configure.zcml index 867b9020c..149eff13d 100644 --- a/docs/tutorials/bfgwiki/src/models/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki/src/models/tutorial/configure.zcml @@ -4,7 +4,7 @@ <include package="repoze.bfg.includes" /> <view - for=".models.Wiki" + context=".models.Wiki" view=".views.my_view" renderer="templates/mytemplate.pt" /> diff --git a/docs/tutorials/bfgwiki/src/viewdecorators/tutorial/views.py b/docs/tutorials/bfgwiki/src/viewdecorators/tutorial/views.py index a5d8f6b6a..08489f4ef 100644 --- a/docs/tutorials/bfgwiki/src/viewdecorators/tutorial/views.py +++ b/docs/tutorials/bfgwiki/src/viewdecorators/tutorial/views.py @@ -11,11 +11,11 @@ from tutorial.models import Wiki # regular expression used to find WikiWords wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)") -@bfg_view(for_=Wiki) +@bfg_view(context=Wiki) def view_wiki(context, request): return HTTPFound(location = model_url(context, request, 'FrontPage')) -@bfg_view(for_=Page, renderer='templates/view.pt') +@bfg_view(context=Page, renderer='templates/view.pt') def view_page(context, request): wiki = context.__parent__ @@ -34,7 +34,7 @@ def view_page(context, request): edit_url = model_url(context, request, 'edit_page') return dict(page = context, content = content, edit_url = edit_url) -@bfg_view(for_=Wiki, name='add_page', renderer='templates/edit.pt') +@bfg_view(context=Wiki, name='add_page', renderer='templates/edit.pt') def add_page(context, request): name = request.subpath[0] if 'form.submitted' in request.params: @@ -50,7 +50,7 @@ def add_page(context, request): page.__parent__ = context return dict(page = page, save_url = save_url) -@bfg_view(for_=Page, name='edit_page', renderer='templates/edit.pt') +@bfg_view(context=Page, name='edit_page', renderer='templates/edit.pt') def edit_page(context, request): if 'form.submitted' in request.params: context.data = request.params['body'] diff --git a/docs/tutorials/bfgwiki/src/views/tutorial/configure.zcml b/docs/tutorials/bfgwiki/src/views/tutorial/configure.zcml index 038677bfc..d265d63e4 100644 --- a/docs/tutorials/bfgwiki/src/views/tutorial/configure.zcml +++ b/docs/tutorials/bfgwiki/src/views/tutorial/configure.zcml @@ -9,25 +9,25 @@ /> <view - for=".models.Wiki" + context=".models.Wiki" view=".views.view_wiki" /> <view - for=".models.Wiki" + context=".models.Wiki" name="add_page" view=".views.add_page" renderer="templates/edit.pt" /> <view - for=".models.Page" + context=".models.Page" view=".views.view_page" renderer="templates/view.pt" /> <view - for=".models.Page" + context=".models.Page" name="edit_page" view=".views.edit_page" renderer="templates/edit.pt" diff --git a/docs/tutorials/bfgwiki/viewdecorators.rst b/docs/tutorials/bfgwiki/viewdecorators.rst index 8cc220097..3360adc1a 100644 --- a/docs/tutorials/bfgwiki/viewdecorators.rst +++ b/docs/tutorials/bfgwiki/viewdecorators.rst @@ -24,9 +24,10 @@ We'll use it to decorate our ``view_wiki``, ``view_page``, The :class:`repoze.bfg.view.bfg_view` callable accepts a number of arguments: -``for_`` +``context`` - The model type which this view is "for", in our case a class. + The model type which the :term:`context` of our view will be, in our + case a class. ``name`` @@ -49,18 +50,18 @@ The decorator above the ``view_wiki`` function will be: .. code-block:: python :linenos: - @bfg_view(for_=Wiki) + @bfg_view(context=Wiki) -This indicates that the view is "for" the Wiki class and has the -*empty* view_name (indicating the :term:`default view` for the Wiki -class). After injecting this decorator, we can now *remove* the -following from our ``configure.zcml`` file: +This indicates that the view is for the Wiki class and has the *empty* +view_name (indicating the :term:`default view` for the Wiki class). +After injecting this decorator, we can now *remove* the following from +our ``configure.zcml`` file: .. code-block:: xml :linenos: <view - for=".models.Wiki" + context=".models.Wiki" view=".views.view_wiki" /> @@ -75,18 +76,18 @@ The decorator above the ``view_page`` function will be: .. code-block:: python :linenos: - @bfg_view(for_=Page, renderer='templates/view.pt') + @bfg_view(context=Page, renderer='templates/view.pt') -This indicates that the view is "for" the Page class and has the -*empty* view_name (indicating the :term:`default view` for the Page -class). After injecting this decorator, we can now *remove* the -following from our ``configure.zcml`` file: +This indicates that the view is for the Page class and has the *empty* +view_name (indicating the :term:`default view` for the Page class). +After injecting this decorator, we can now *remove* the following from +our ``configure.zcml`` file: .. code-block:: xml :linenos: <view - for=".models.Page" + context=".models.Page" view=".views.view_page" renderer="templates/view.pt" /> @@ -102,9 +103,9 @@ The decorator above the ``add_page`` function will be: .. code-block:: python :linenos: - @bfg_view(for_=Wiki, name='add_page', renderer='templates/edit.pt') + @bfg_view(context=Wiki, name='add_page', renderer='templates/edit.pt') -This indicates that the view is "for" the Wiki class and has the +This indicates that the view is for the Wiki class and has the ``add_page`` view_name. After injecting this decorator, we can now *remove* the following from our ``configure.zcml`` file: @@ -112,7 +113,7 @@ This indicates that the view is "for" the Wiki class and has the :linenos: <view - for=".models.Wiki" + context=".models.Wiki" name="add_page" view=".views.add_page" renderer="templates/edit.pt" @@ -129,9 +130,9 @@ The decorator above the ``edit_page`` function will be: .. code-block:: python :linenos: - @bfg_view(for_=Page, name='edit_page', renderer='templates/edit.pt') + @bfg_view(context=Page, name='edit_page', renderer='templates/edit.pt') -This indicates that the view is "for" the Page class and has the +This indicates that the view is for the Page class and has the ``edit_page`` view_name. After injecting this decorator, we can now *remove* the following from our ``configure.zcml`` file: @@ -139,7 +140,7 @@ This indicates that the view is "for" the Page class and has the :linenos: <view - for=".models.Page" + context=".models.Page" name="edit_page" view=".views.edit_page" renderer="templates/edit.pt" |
