summaryrefslogtreecommitdiff
path: root/docs/api/traversal.rst
AgeCommit message (Collapse)Author
2010-12-18resource -> assetChris McDonough
2010-10-25convert API docs to PyramidChris McDonough
2009-07-05Get rid of secondary header.Chris McDonough
2009-05-27Merge authchanges branch to trunk.Chris McDonough
2009-05-18FeaturesChris McDonough
-------- - Added a ``traverse`` function to the ``repoze.bfg.traversal`` module. This function may be used to retrieve certain values computed during path resolution. See the Traversal API chapter of the documentation for more information about this function. Deprecations ------------ - Internal: ``ITraverser`` callables should now return a dictionary rather than a tuple. Up until 0.7.0, all ITraversers were assumed to return a 3-tuple. In 0.7.1, ITraversers were assumed to return a 6-tuple. As (by evidence) it's likely we'll need to add further information to the return value of an ITraverser callable, 0.8 assumes that an ITraverser return a dictionary with certain elements in it. See the ``repoze.bfg.interfaces.ITraverser`` interface for the list of keys that should be present in the dictionary. ``ITraversers`` which return tuples will still work, although a deprecation warning will be issued. Backwards Incompatibilities --------------------------- - If your code used the ITraverser interface directly (not via an API function such as ``find_model``) via an adapter lookup, you'll need to change your code to expect a dictionary rather than a 3- or 6-tuple if your code ever gets return values from the default ModelGraphTraverser or RoutesModelTraverser adapters.
2009-02-06Docs renderings.Chris McDonough
2009-02-06Revert my decision to make ``model_path`` return a tuple; itChris McDonough
now still returns a string; albeit a quoted one. An additional API (model_path_tuple) now also exists which can be used to get a model path as a tuple. - The ``repoze.bfg.traversal.model_path`` API now returns a *quoted* string rather than a string represented by series of unquoted elements joined via ``/`` characters. Previously it returned a string or unicode object representing the model path, with each segment name in the path joined together via ``/`` characters, e.g. ``/foo /bar``. Now it returns a string, where each segment is a UTF-8 encoded and URL-quoted element e.g. ``/foo%20/bar``. This change was (as discussed briefly on the repoze-dev maillist) necessary to accomodate model objects which themselves have ``__name__`` attributes that contain the ``/`` character. For people that have no models that have high-order Unicode ``__name__`` attributes or ``__name__`` attributes with values that require URL-quoting with in their model graphs, this won't cause any issue. However, if you have code that currently expects ``model_path`` to return an unquoted string, or you have an existing application with data generated via the old method, and you're too lazy to change anything, you may wish replace the BFG-imported ``model_path`` in your code with this function (this is the code of the "old" ``model_path`` implementation):: from repoze.bfg.location import lineage def i_am_too_lazy_to_move_to_the_new_model_path(model, *elements): rpath = [] for location in lineage(model): if location.__name__: rpath.append(location.__name__) path = '/' + '/'.join(reversed(rpath)) if elements: suffix = '/'.join(elements) path = '/'.join([path, suffix]) return path - The ``repoze.bfg.traversal.find_model`` API no longer implicitly converts unicode representations of a full path passed to it as a Unicode object into a UTF-8 string. Callers should either use prequoted path strings returned by ``repoze.bfg.traversal.model_path``, or tuple values returned by the result of ``repoze.bfg.traversal.model_path_tuple`` or they should use the guidelines about passing a string ``path`` argument described in the ``find_model`` API documentation. - Each argument contained in ``elements`` passed to ``repoze.bfg.traversal.model_path`` will now have any ``/`` characters contained within quoted to ``%2F`` in the returned string. Previously, ``/`` characters in elements were left unquoted (a bug). - A ``repoze.bfg.traversal.model_path_tuple`` API was added. This API is an alternative to ``model_path`` (which returns a string); ``model_path_tuple`` returns a model path as a tuple (much like Zope's ``getPhysicalPath``). - A ``repoze.bfg.traversal.quote_path_segment`` API was added. This API will quote an individual path segment (string or unicode object). See the ``repoze.bfg.traversal`` API documentation for more information.
2009-01-27FeaturesChris McDonough
-------- - The ``repoze.bfg.url.model_url`` API now works against contexts derived from Routes URL dispatch (``Routes.util.url_for`` is called under the hood). - "Virtual root" support for traversal-based applications has been added. Virtual root support is useful when you'd like to host some model in a :mod:`repoze.bfg` model graph as an application under a URL pathname that does not include the model path itself. For more information, see the (new) "Virtual Hosting" chapter in the documentation. - A ``repoze.bfg.traversal.virtual_root`` API has been added. When called, it returns the virtual root object (or the physical root object if no virtual root has been specified). Implementation Changes ---------------------- - ``repoze.bfg.traversal.RoutesModelTraverser`` has been moved to ``repoze.bfg.urldispatch``. - ``model_url`` URL generation is now performed via an adapter lookup based on the context and the request. - ZCML which registers two adapters for the ``IContextURL`` interface has been added to the configure.zcml in ``repoze.bfg.includes``.
2009-01-26- Added a ``traversal_path`` API to the traversal module; see theChris McDonough
"traversal" API chapter in the docs. This was a function previously known as ``split_path`` that was not an API but people were using it anyway. Unlike ``split_path`` it now returns a tuple instead of a list (as its values are cached).
2009-01-05 New ModulesChris McDonough
- A new module ``repoze.bfg.url`` has been added. It contains the ``model_url`` API (moved from ``repoze.bfg.traversal``) and an implementation of ``urlencode`` (like Python's ``urllib.urlencode``) which can handle Unicode keys and values in parameters to the ``query`` argument. Deprecations - The ``model_url`` function has been moved from ``repoze.bfg.traversal`` into ``repoze.bfg.url``. It can still be imported from ``repoze.bfg.traversal`` but an import from ``repoze.bfg.traversal`` will emit a DeprecationWarning. Features - The ``repoze.bfg.url.model_url`` API (nee' ``repoze.bfg.traversal.model_url``) now accepts and honors a keyword argument named ``query``. The value of this argument will be used to compose a query string, which will be attached to the generated URL before it is returned. See the API docs (in the docs directory or `on the web <http://static.repoze.org/bfgdocs>`_) for more information.
2008-08-29model_path and *backwards incompatible change* removing "make_app" and ↵Chris McDonough
"get_options" from __init__.py of repoze.bfg; use repoze.bfg.router:make_app and repoze.bfg.registry:get_options instead.
2008-08-08(no commit message)Chris McDonough
2008-08-08 - Add ``find_context_from_path`` and ``find_root`` traversal APIs.Chris McDonough
In the process, make ITraverser a uni-adapter (on context) rather than a multiadapter (on context and request).
2008-07-290.2.5: add model_url.Chris McDonough
2008-07-25Make the global module index render properly.Chris McDonough
2008-07-20 - Add find_interface API.Chris McDonough