summaryrefslogtreecommitdiff
path: root/docs/narr/views.rst
AgeCommit message (Collapse)Author
2009-11-22Rendering tweaks.Chris McDonough
2009-11-14Spellcheck.Chris McDonough
2009-11-02- "What's New in ``repoze.bfg`` 1.1" document added to narrativeChris McDonough
documentation. - Minor typo fixes.
2009-10-22(no commit message)Chris McDonough
2009-10-22It's an envvar.Chris McDonough
2009-10-22Added ``path_info`` predicate (regex-filters on the corresponding HTTP header).Malthe Borch
2009-10-19Better disambiguation of predicate vs. non-predicate attributes.Chris McDonough
2009-10-19- Call out predicate attributes of ZCML directive within "Views"Chris McDonough
chapter.
2009-10-18Add filesystem analogy.Chris McDonough
2009-10-18- The ``@bfg_view`` decorator can now be used against a class method::Chris McDonough
from webob import Response from repoze.bfg.view import bfg_view class MyView(object): def __init__(self, context, request): self.context = context self.request = request @bfg_view(name='hello') def amethod(self): return Response('hello from %s!' % self.context) When the bfg_view decorator is used against a class method, a view is registered for the *class* (it's a "class view" where the "attr" happens to be the method they're attached to), so the view class must have a suitable constructor.
2009-10-18- More than one ``@bfg_view`` decorator may now be stacked on top ofChris McDonough
any number of others. Each invocation of the decorator registers a single view. For instance, the following combination of decorators and a function will register two views:: from repoze.bfg.view import bfg_view @bfg_view(name='edit') @bfg_view(name='change') def edit(context, request): pass This makes it possible to associate more than one view configuration for a single callable without requiring ZCML.
2009-10-14- Add ``xhr``, ``accept``, and ``header`` view configurationChris McDonough
predicates to ZCML view declaration, ZCML route declaration, and ``bfg_view`` decorator. See the ``Views`` narrative documentation chapter for more information about these predicates.
2009-10-10More renderer conversions.Chris McDonough
2009-09-30- Describe "request-only" view calling conventions inside theChris McDonough
urldispatch narrative chapter, where it's most helpful.
2009-09-30- The import of ``repoze.bfg.view.NotFound`` is deprecated in favor ofChris McDonough
``repoze.bfg.exceptions.NotFound``. The old location still functions, but emits a deprecation warning. - The import of ``repoze.bfg.security.Unauthorized`` is deprecated in favor of ``repoze.bfg.exceptions.Forbidden``. The old location still functions but emits a deprecation warning. The rename from ``Unauthorized`` to ``Forbidden`` brings parity to the the name of the exception and the system view it invokes when raised. - New ``repoze.bfg.exceptions`` module was created to house exceptions that were previously sprinkled through various modules. - An ``exceptions`` API chapter was added, documenting the new ``repoze.bfg.exceptions`` module.
2009-09-21Fix docs after updates.Chris McDonough
2009-09-17- Add a ``repoze.bfg.url.static_url`` API which is capable ofChris McDonough
generating URLs to static resources defined by the ``<static>`` ZCML directive. See the "Views" narrative chapter's section titled "Generating Static Resource URLs" for more information.
2009-09-17- Add a ``string`` renderer. This renderer converts a non-ResponseChris McDonough
return value of any view callble into a string. It is documented in the "Views" narrative chapter.
2009-09-16Excise "page" vernacular.Chris McDonough
2009-09-16Review and edit views chapter.Chris McDonough
2009-09-16Checkpoint. Not 100% test coverage.Chris McDonough
2009-09-14- The ``view`` attribute of the ``view`` ZCML directive is no longerChris McDonough
required if the ZCML directive has a ``template`` attribute.
2009-09-14- A ZCML ``view`` directive (and the associated ``bfg_view``Chris McDonough
decorator) can now accept a "wrapper" value. If a "wrapper" value is supplied, it is the value of a separate view's *name* attribute. When a view with a ``wrapper`` attribute is rendered, the "inner" view is first rendered normally. Its body is then attached to the request as "wrapped_body", and then a wrapper view name is looked up and rendered (using ``repoze.bfg.render_view_to_response``), passed the request and the context. The wrapper view is assumed to do something sensible with ``request.wrapped_body``, usually inserting its structure into some other rendered template. This feature makes it possible to specify (potentially nested) "owrap" relationships between views using only ZCML or decorators (as opposed always using ZPT METAL and analogues to wrap view renderings in outer wrappers).
2009-09-14Page->view.Chris McDonough
2009-09-14Renderings.Chris McDonough
2009-09-14- A ZCML ``view`` directive (and the associated ``bfg_view``Chris McDonough
decorator) can now accept an "attr" value. If an "attr" value is supplied, it is considered a method named of the view object to be called when the response is required. This is typically only good for views that are classes or instances (not so useful for functions, as functions typically have no methods other than ``__call__``). - A ZCML ``view`` directive (and the associated ``bfg_view`` decorator) can now accept a "template" value. If a "template" value is supplied, and the view callable returns a dictionary, the associated template is rendered with the dictionary as keyword arguments.
2009-09-06Merge multiview2 branch to HEAD.Chris McDonough
2009-08-25- The ``repoze.bfg.view.static`` class now accepts a string as itsChris McDonough
first argument ("root_dir") that represents a package-relative name e.g. ``somepackage:foo/bar/static``. This is now the preferred mechanism for spelling package-relative static paths using this class. A ``package_name`` keyword argument has been left around for backwards compatibility. If it is supplied, it will be honored. - Fixed documentation for ``repoze.bfg.view.static`` (in narrative ``Views`` chapter).
2009-08-24Added ZCML directive to serve up static files from a directory.Malthe Borch
2009-08-13- Request-only-convention examples in the "Views" narrativeChris McDonough
documentation were broken.
2009-07-08Rendering.Chris McDonough
2009-07-05Spellcheck.Chris McDonough
2009-07-03Not a publisher, a router.Chris McDonough
2009-07-03General editing walkthrough.Chris McDonough
2009-07-02- Added an "Extending" chapter to the narrative documentation whichChris McDonough
explains how to extend or modify an existing BFG application using another Python package and ZCML.
2009-06-19Edit.Chris McDonough
2009-06-18Document request-only calling convention.Chris McDonough
2009-06-11Document route_name (badly).Chris McDonough
2009-05-31- The ``request_type`` argument of ZCML ``view`` declarations andChris McDonough
``bfg_view`` decorators can now be one of the strings ``GET``, ``POST``, ``PUT``, ``DELETE``, or ``HEAD`` instead of a reference to the respective interface type imported from ``repoze.bfg.interfaces``.
2009-05-27Merge authchanges branch to trunk.Chris McDonough
2009-05-21Disambiguate.Chris McDonough
2009-05-21Disambiguate.Chris McDonough
2009-05-21- Class objects may now be used as view callables (both via ZCML andChris McDonough
via use of the ``bfg_view`` decorator in Python 2.6 as a class decorator). The calling semantics when using a class as a view callable is similar to that of using a class as a Zope "browser view": the class' ``__init__`` must accept two positional parameters (conventionally named ``context``, and ``request``). The resulting instance must be callable (it must have a ``__call__`` method). When called, the instance should return a response. For example:: from webob import Response class MyView(object): def __init__(self, context, request): self.context = context self.request = request def __call__(self): return Response('hello from %s!' % self.context) See the "Views" chapter in the documentation and the ``repoze.bfg.view`` API documentation for more information.
2009-05-21- Removed the pickling of ZCML actions (the code that wroteChris McDonough
``configure.zcml.cache`` next to ``configure.zcml`` files in projects). The code which managed writing and reading of the cache file was a source of subtle bugs when users switched between imperative (e.g. ``@bfg_view``) registrations and declarative registrations (e.g. the ``view`` directive in ZCML) on the same project. On a moderately-sized project (535 ZCML actions and 15 ZCML files), executing actions read from the pickle was saving us only about 200ms (2.5 sec vs 2.7 sec average). On very small projects (1 ZCML file and 4 actions), startup time was comparable, and sometimes even slower when reading from the pickle, and both ways were so fast that it really just didn't matter anyway.
2009-05-14Rendering.Chris McDonough
2009-04-11Tweaks.Chris McDonough
2009-04-11Rendering.Chris McDonough
2009-04-11- The default request charset encoding is now ``utf-8``. As a result,Chris McDonough
the request machinery will attempt to decode values from the utf-8 encoding to Unicode automatically when they are obtained via ``request.params``, ``request.GET``, and ``request.POST``. The previous behavior of BFG was to return a bytestring when a value was accessed in this manner. This change will break form handling code in apps that rely on values from those APIs being considered bytestrings. If you are manually decoding values from form submissions in your application, you'll either need to change the code that does that to expect Unicode values from ``request.params``, ``request.GET`` and ``request.POST``, or you'll need to explicitly reenable the previous behavior. To reenable the previous behavior, add the following to your application's ``configure.zcml``:: <subscriber for="repoze.bfg.interfaces.INewRequest" handler="repoze.bfg.request.make_request_ascii"/> See also the documentation in the "Views" chapter of the BFG docs entitled "Using Views to Handle Form Submissions (Unicode and Character Set Issues)".
2009-01-25Document Routes ZCML attrs.Chris McDonough
2009-01-19view_name attr.Chris McDonough