Next release ============ Index-Related ------------- - The canonical package index location for ``repoze.bfg`` has changed. The "old" index (http://dist.repoze.org/lemonade/dev/simple) has been superseded by a new index location (`http://dist.repoze.org/bfg/current/simple `_). The installation documentation has been updated. The "lemonade" index still exists, but it is not guaranteed to have the latest BFG software in it, nor will it be maintained in the future. Features -------- - Added better documentation for virtual hosting at a URL prefix within the virtual hosting docs chapter. - The interface for ``repoze.bfg.interfaces.ITraverser`` and the built-in implementations that implement the interface (``repoze.bfg.traversal.ModelGraphTraverser``, and ``repoze.bfg.urldispatch.RoutesModelTraverser``) now expect the ``__call__`` method of an ITraverser to return 3 additional arguments: ``traversed``, ``virtual_root``, and ``virtual_root_path`` (the old contract was that the ``__call__`` method of an ITraverser returned; three arguments, the contract new is that it returns six). ``traversed`` will be a sequence of Unicode names that were traversed (including the virtual root path, if any) or ``None`` if no traversal was performed, ``virtual_root`` will be a model object representing the virtual root (or the physical root if traversal was not performed), and ``virtual_root_path`` will be a sequence representing the virtual root path (a sequence of Unicode names) or ``None`` if traversal was not performed. Six arguments are now returned from BFG ITraversers. They are returned in this order: ``context``, ``view_name``, ``subpath``, ``traversed``, ``virtual_root``, and ``virtual_root_path``. Places in the BFG code which called an ITraverser continue to accept a 3-argument return value, although BFG will generate and log a warning when one is encountered. - The request object now has the following attributes: ``traversed`` (the sequence of names traversed or ``None`` if traversal was not performed), ``virtual_root`` (the model object representing the virtual root, including the virtual root path if any), and ``virtual_root_path`` (the seuquence of names representing the virtual root path or ``None`` if traversal was not performed). - A new decorator named ``wsgiapp2`` was added to the ``repoze.bfg.wsgi`` module. This decorator performs the same function as ``repoze.bfg.wsgi.wsgiapp`` except it fixes up the ``SCRIPT_NAME``, and ``PATH_INFO`` environment values before invoking the WSGI subapplication. - The ``repoze.bfg.testing.DummyRequest`` object now has default attributes for ``traversed``, ``virtual_root``, and ``virtual_root_path``. - The RoutesModelTraverser now behaves more like the Routes "RoutesMiddleware" object when an element in the match dict is named ``path_info`` (usually when there's a pattern like ``http://foo/*path_info``). When this is the case, the ``PATH_INFO`` environment variable is set to the value in the match dict, and the ``SCRIPT_NAME`` is appended to with the prefix of the original ``PATH_INFO`` not including the value of the new variable. - The notfound debug now shows the traversed path, the virtual root, and the virtual root path too. - Speed up / clarify 'traversal' module's 'model_path', 'model_path_tuple', and '_model_path_list' functions. Backwards Incompatibilities --------------------------- - In all previous releases, by default, if traversal was used (as opposed to URL-dispatch), and the root object supplied the``repoze.bfg.interfaces.ILocation`` interface, but the children returned via its ``__getitem__`` returned an object that did not implement the same interface, :mod:`repoze.bfg` provided some implicit help during traversal. This traversal feature wrapped subobjects from the root (and thereafter) that did not implement ``ILocation`` in proxies which automatically provided them with a ``__name__`` and ``__parent__`` attribute based on the name being traversed and the previous object traversed. This feature has now been disabled in the default configuration for purposes of speed and understandability. In order to re-enable the ILocation wrapper behavior for older applications which cannot be changed, register the ``WrappingModelGraphTraverser`` as the traversal policy, rather than the default ``ModelGraphTraverser``. To use this feature, your application will need to have the following in its ``configure.zcml``:: When this ITraverserFactory is used, no object in the graph (even the root object) must supply a ``__name__`` or ``__parent__`` attribute. Even if subobjects returned from the root *do* implement the ILocation interface, these will still be wrapped in proxies that override the object's "real" ``__parent__`` and ``__name__`` attributes. See also changes to the "Models" chapter of the documentation (in the "Location-Aware Model Instances") section. 0.7.0 (2009-04-11) ================== Bug Fixes --------- - Fix a bug in ``repoze.bfg.wsgi.HTTPException``: the content length was returned as an int rather than as a string. - Add explicit dependencies on ``zope.deferredimport``, ``zope.deprecation``, and ``zope.proxy`` for forward compatibility reasons (``zope.component`` will stop relying on ``zope.deferredimport`` soon and although we use it directly, it's only a transitive dependency, and ''zope.deprecation`` and ``zope.proxy`` are used directly even though they're only transitive dependencies as well). - Using ``model_url`` or ``model_path`` against a broken model graph (one with models that had a non-root model with a ``__name__`` of ``None``) caused an inscrutable error to be thrown: ( if not ``_must_quote[cachekey].search(s): TypeError: expected string or buffer``). Now URLs and paths generated against graphs that have None names in intermediate nodes will replace the None with the empty string, and, as a result, the error won't be raised. Of course the URL or path will still be bogus. Features -------- - Make it possible to have ``testing.DummyTemplateRenderer`` return some nondefault string representation. - Added a new ``anchor`` keyword argument to ``model_url``. If ``anchor`` is present, its string representation will be used as a named anchor in the generated URL (e.g. if ``anchor`` is passed as ``foo`` and the model URL is ``http://example.com/model/url``, the generated URL will be ``http://example.com/model/url#foo``). Backwards Incompatibilities --------------------------- - The default request charset encoding is now ``utf-8``. As a result, 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``:: See also the documentation in the "Views" chapter of the BFG docs entitled "Using Views to Handle Form Submissions (Unicode and Character Set Issues)". Documentation ------------- - Add a section to the narrative Views chapter entitled "Using Views to Handle Form Submissions (Unicode and Character Set Issues)" explaining implicit decoding of form data values. 0.6.9 (2009-02-16) ================== Bug Fixes --------- - lru cache was unstable under concurrency (big surprise!) when it tried to redelete a key in the cache that had already been deleted. Symptom: line 64 in put:del data[oldkey]:KeyError: '/some/path'. Now we just ignore the key error if we can't delete the key (it has already been deleted). - Empty location names in model paths when generating a URL using ``repoze.bfg.model_url`` based on a model obtained via traversal are no longer ignored in the generated URL. This means that if a non-root model object has a ``__name__`` of ``''``, the URL will reflect it (e.g. ``model_url`` will generate ``http://foo/bar//baz`` if an object with the ``__name__`` of ``''`` is a child of bar and the parent of baz). URLs generated with empty path segments are, however, still irresolveable by the model graph traverser on request ingress (the traverser strips empty path segment names). Features -------- - Microspeedups of ``repoze.bfg.traversal.model_path``, ``repoze.bfg.traversal.model_path_tuple``, ``repoze.bfg.traversal.quote_path_segment``, and ``repoze.bfg.url.urlencode``. - add zip_safe = false to setup.cfg. Documentation ------------- - Add a note to the ``repoze.bfg.traversal.quote_path_segment`` API docs about caching of computed values. Implementation Changes ---------------------- - Simplification of ``repoze.bfg.traversal.TraversalContextURL.__call__`` (it now uses ``repoze.bfg.traversal.model_path`` instead of rolling its own path-generation). 0.6.8 (2009-02-05) ================== Backwards Incompatibilities --------------------------- - 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. Bugfixes -------- - 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). Features -------- - 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. - The ``repoze.bfg.traversal.find_model`` API now accepts "path tuples" (see the above note regarding ``model_path_tuple``) as well as string path representations (from ``repoze.bfg.traversal.model_path``) as a ``path`` argument. - Add ` `renderer`` argument (defaulting to None) to ``repoze.bfg.testing.registerDummyRenderer``. This makes it possible, for instance, to register a custom renderer that raises an exception in a unit test. Implementation Changes ---------------------- - Moved _url_quote function back to ``repoze.bfg.traversal`` from ``repoze.bfg.url``. This is not an API. 0.6.7 (2009-01-27) ================== Features -------- - 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``. 0.6.6 (2009-01-26) ================== Implementation Changes ---------------------- - There is an indirection in ``repoze.bfg.url.model_url`` now that consults a utility to generate the base model url (without extra elements or a query string). Eventually this will service virtual hosting; for now it's undocumented and should not be hooked. 0.6.5 (2009-01-26) ================== Features -------- - You can now override the NotFound and Unauthorized responses that :mod:`repoze.bfg` generates when a view cannot be found or cannot be invoked due to lack of permission. See the "ZCML Hooks" chapter in the docs for more information. - Added Routes ZCML directive attribute explanations in documentation. - Added a ``traversal_path`` API to the traversal module; see the "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). Behavior Changes ---------------- - The ``repoze.bfg.view.render_view_to_response`` API will no longer raise a ValueError if an object returned by a view function it calls does not possess certain attributes (``headerlist``, ``app_iter``, ``status``). This API used to attempt to perform a check using the ``is_response`` function in ``repoze.bfg.view``, and raised a ``ValueError`` if the ``is_response`` check failed. The responsibility is now the caller's to ensure that the return value from a view function is a "real" response. - WSGI environ dicts passed to ``repoze.bfg`` 's Router must now contain a REQUEST_METHOD key/value; if they do not, a KeyError will be raised (speed). - It is no longer permissible to pass a "nested" list of principals to ``repoze.bfg.ACLAuthorizer.permits`` (e.g. ``['fred', ['larry', 'bob']]``). The principals list must be fully expanded. This feature was never documented, and was never an API, so it's not a backwards incompatibility. - It is no longer permissible for a security ACE to contain a "nested" list of permissions (e.g. ``(Allow, Everyone, ['read', ['view', ['write', 'manage']]])`)`. The list must instead be fully expanded (e.g. ``(Allow, Everyone, ['read', 'view', 'write', 'manage])``). This feature was never documented, and was never an API, so it's not a backwards incompatibility. - The ``repoze.bfg.urldispatch.RoutesRootFactory`` now injects the ``wsgiorg.routing_args`` environment variable into the environ when a route matches. This is a tuple of ((), routing_args) where routing_args is the value that comes back from the routes mapper match (the "match dict"). - The ``repoze.bfg.traversal.RoutesModelTraverser`` class now wants to obtain the ``view_name`` and ``subpath`` from the ``wsgiorgs.routing_args`` environment variable. It falls back to obtaining these from the context for backwards compatibility. Implementation Changes ---------------------- - Get rid of ``repoze.bfg.security.ACLAuthorizer``: the ``ACLSecurityPolicy`` now does what it did inline. - Get rid of ``repoze.bfg.interfaces.NoAuthorizationInformation`` exception: it was used only by ``ACLAuthorizer``. - Use a homegrown NotFound error instead of ``webob.exc.HTTPNotFound`` (the latter is slow). - Use a homegrown Unauthorized error instead of ``webob.exc.Unauthorized`` (the latter is slow). - the ``repoze.bfg.lru.lru_cached`` decorator now uses functools.wraps in order to make documentation of LRU-cached functions possible. - Various speed micro-tweaks. Bug Fixes --------- - ``repoze.bfg.testing.DummyModel`` did not have a ``get`` method; it now does. 0.6.4 (2009-01-23) ================== Backwards Incompatibilities --------------------------- - The ``unicode_path_segments`` configuration variable and the ``BFG_UNICODE_PATH_SEGMENTS`` configuration variable have been removed. Path segments are now always passed to model ``__getitem__`` methods as unicode. "True" has been the default for this setting since 0.5.4, but changing this configuration setting to false allowed you to go back to passing raw path element strings to model ``__getitem__`` methods. Removal of this knob services a speed goal (we get about +80 req/s by removing the check), and it's clearer just to always expect unicode path segments in model ``__getitem__`` methods. Implementation Changes ---------------------- - ``repoze.bfg.traversal.split_path`` now also handles decoding path segments to unicode (for speed, because its results are cached). - ``repoze.bfg.traversal.step`` was made a method of the ModelGraphTraverser. - Use "precooked" Request subclasses (e.g. ``repoze.bfg.request.GETRequest``) that correspond to HTTP request methods within ``router.py`` when constructing a request object rather than using ``alsoProvides`` to attach the proper interface to an unsubclassed ``webob.Request``. This pattern is purely an optimization (e.g. preventing calls to ``alsoProvides`` means the difference between 590 r/s and 690 r/s on a MacBook 2GHz). - Tease out an extra 4% performance boost by changing the Router; instead of using imported ZCA APIs, use the same APIs directly against the registry that is an attribute of the Router. - The registry used by BFG is now a subclass of ``zope.component.registry.Components`` (defined as ``repoze.bfg.registry.Registry``); it has a ``notify`` method, a ``registerSubscriptionAdapter`` and a ``registerHandler`` method. If no subscribers are registered via ``registerHandler`` or ``registerSubscriptionAdapter``, ``notify`` is a noop for speed. - The Allowed and Denied classes in ``repoze.bfg.security`` now are lazier about constructing the representation of a reason message for speed; ``repoze.bfg.view_execution_permitted`` takes advantage of this. - The ``is_response`` check was sped up by about half at the expense of making its code slightly uglier. New Modules ----------- - ``repoze.bfg.lru`` implements an LRU cache class and a decorator for internal use. 0.6.3 (2009-01-19) ================== Bug Fixes --------- - Readd ``root_policy`` attribute on Router object (as a property which returns the IRootFactory utility). It was inadvertently removed in 0.6.2. Code in the wild depended upon its presence (esp. scripts and "debug" helpers). Features -------- - URL-dispatch has been overhauled: it is no longer necessary to manually create a RoutesMapper in your application's entry point callable in order to use URL-dispatch (aka `Routes `_). A new ``route`` directive has been added to the available list of ZCML directives. Each ``route`` directive inserted into your application's ``configure.zcml`` establishes a Routes mapper connection. If any ``route`` declarations are made via ZCML within a particular application, the ``get_root`` callable passed in to ``repoze.bfg.router.make_app`` will automatically be wrapped in the equivalent of a RoutesMapper. Additionally, the new ``route`` directive allows the specification of a ``context_interfaces`` attribute for a route, this will be used to tag the manufactured routes context with specific interfaces when a route specifying a ``context_interfaces`` attribute is matched. - A new interface ``repoze.bfg.interfaces.IContextNotFound`` was added. This interface is attached to a "dummy" context generated when Routes cannot find a match and there is no "fallback" get_root callable that uses traversal. - The ``bfg_starter`` and ``bfg_zodb`` "paster create" templates now contain images and CSS which are displayed when the default page is displayed after initial project generation. - Allow the ``repoze.bfg.view.static`` helper to be passed a relative ``root_path`` name; it will be considered relative to the file in which it was called. - The functionality of ``repoze.bfg.convention`` has been merged into the core. Applications which make use of ``repoze.bfg.convention`` will continue to work indefinitely, but it is recommended that apps stop depending upon it. To do so, substitute imports of ``repoze.bfg.convention.bfg_view`` with imports of ``repoze.bfg.view.bfg_view``, and change the stanza in ZCML from ```` to ````. As a result of the merge, bfg has grown a new dependency: ``martian``. - View functions which use the pushpage decorator are now pickleable (meaning their use won't prevent a ``configure.zcml.cache`` file from being written to disk). - Instead of invariably using ``webob.Request`` as the "request factory" (e.g. in the ``Router`` class) and ``webob.Response`` and the "response factory" (e.g. in ``render_template_to_response``), allow both to be overridden via a ZCML utility hook. See the "Using ZCML Hooks" chapter of the documentation for more information. Deprecations ------------ - The class ``repoze.bfg.urldispatch.RoutesContext`` has been renamed to ``repoze.bfg.urldispatch.DefaultRoutesContext``. The class should be imported by the new name as necessary (although in reality it probably shouldn't be imported from anywhere except internally within BFG, as it's not part of the API). Implementation Changes ---------------------- - The ``repoze.bfg.wsgi.wsgiapp`` decorator now uses ``webob.Request.get_response`` to do its work rather than relying on homegrown WSGI code. - The ``repoze.bfg.view.static`` helper now uses ``webob.Request.get_response`` to do its work rather than relying on homegrown WSGI code. - The ``repoze.bfg.urldispatch.RoutesModelTraverser`` class has been moved to ``repoze.bfg.traversal.RoutesModelTraverser``. - The ``repoze.bfg.registry.makeRegistry`` function was renamed to ``repoze.bfg.registry.populateRegistry`` and now accepts a ``registry`` argument (which should be an instance of ``zope.component.registry.Components``). Documentation Additions ----------------------- - Updated narrative urldispatch chapter with changes required by ```` ZCML directive. - Add a section on "Using BFG Security With URL Dispatch" into the urldispatch chapter of the documentation. - Better documentation of security policy implementations that ship with repoze.bfg. - Added a "Using ZPT Macros in repoze.bfg" section to the narrative templating chapter. 0.6.2 (2009-01-13) ================== Features -------- - Tests can be run with coverage output if you've got ``nose`` installed in the interpreter which you use to run tests. Using an interpreter with ``nose`` installed, do ``python setup.py nosetests`` within a checkout of the ``repoze.bfg`` package to see test coverage output. - Added a ``post`` argument to the ``repoze.bfg.testing:DummyRequest`` constructor. - Added ``__len__`` and ``__nonzero__`` to ``repoze.bfg.testing:DummyModel``. - The ``repoze.bfg.registry.get_options`` callable (now renamed to ``repoze.bfg.setings.get_options``) used to return only framework-specific keys and values in the dictionary it returned. It now returns all the keys and values in the dictionary it is passed *plus* any framework-specific settings culled from the environment. As a side effect, all PasteDeploy application-specific config file settings are made available as attributes of the ``ISettings`` utility from within BFG. - Renamed the existing BFG paster template to ``bfg_starter``. Added another template (``bfg_zodb``) showing default ZODB setup using ``repoze.zodbconn``. - Add a method named ``assert_`` to the DummyTemplateRenderer. This method accepts keyword arguments. Each key/value pair in the keyword arguments causes an assertion to be made that the renderer received this key with a value equal to the asserted value. - Projects generated by the paster templates now use the ``DummyTemplateRenderer.assert_`` method in their view tests. - Make the (internal) thread local registry manager maintain a stack of registries in order to make it possible to call one BFG application from inside another. - An interface specific to the HTTP verb (GET/PUT/POST/DELETE/HEAD) is attached to each request object on ingress. The HTTP-verb-related interfaces are defined in ``repoze.bfg.interfaces`` and are ``IGETRequest``, ``IPOSTRequest``, ``IPUTRequest``, ``IDELETERequest`` and ``IHEADRequest``. These interfaces can be specified as the ``request_type`` attribute of a bfg view declaration. A view naming a specific HTTP-verb-matching interface will be found only if the view is defined with a request_type that matches the HTTP verb in the incoming request. The more general ``IRequest`` interface can be used as the request_type to catch all requests (and this is indeed the default). All requests implement ``IRequest``. The HTTP-verb-matching idea was pioneered by `repoze.bfg.restrequest `_ . That package is no longer required, but still functions fine. Bug Fixes --------- - Fix a bug where the Paste configuration's ``unicode_path_segments`` (and os.environ's ``BFG_UNICODE_PATH_SEGMENTS``) may have been defaulting to false in some circumstances. It now always defaults to true, matching the documentation and intent. - The ``repoze.bfg.traversal.find_model`` API did not work properly when passed a ``path`` argument which was unicode and contained high-order bytes when the ``unicode_path_segments`` or ``BFG_UNICODE_PATH_SEGMENTS`` configuration variables were "true". - A new module was added: ``repoze.bfg.settings``. This contains deployment-settings-related code. Implementation Changes ---------------------- - The ``make_app`` callable within ``repoze.bfg.router`` now registers the ``root_policy`` argument as a utility (unnamed, using the new ``repoze.bfg.interfaces.IRootFactory`` as a provides interface) rather than passing it as the first argument to the ``repoze.bfg.router.Router`` class. As a result, the ``repoze.bfg.router.Router`` router class only accepts a single argument: ``registry``. The ``repoze.bfg.router.Router`` class retrieves the root policy via a utility lookup now. The ``repoze.bfg.router.make_app`` API also now performs some important application registrations that were previously handled inside ``repoze.bfg.registry.makeRegistry``. New Modules ----------- - A ``repoze.bfg.settings`` module was added. It contains code related to deployment settings. Most of the code it contains was moved to it from the ``repoze.bfg.registry`` module. Behavior Changes ---------------- - The ``repoze.bfg.settings.Settings`` class (an instance of which is registered as a utility providing ``repoze.bfg.interfaces.ISettings`` when any application is started) now automatically calls ``repoze.bfg.settings.get_options`` on the options passed to its constructor. This means that usage of ``get_options`` within an application's ``make_app`` function is no longer required (the "raw" ``options`` dict or None may be passed). - Remove old cold which attempts to recover from trying to unpickle a ``z3c.pt`` template; Chameleon has been the templating engine for a good long time now. Running repoze.bfg against a sandbox that has pickled ``z3c.pt`` templates it will now just fail with an unpickling error, but can be fixed by deleting the template cache files. Deprecations ------------ - Moved the ``repoze.bfg.registry.Settings`` class. This has been moved to ``repoze.bfg.settings.Settings``. A deprecation warning is issued when it is imported from the older location. - Moved the ``repoze.bfg.registry.get_options`` function This has been moved to ``repoze.bfg.settings.get_options``. A deprecation warning is issued when it is imported from the older location. - The ``repoze.bfg.interfaces.IRootPolicy`` interface was renamed within the interfaces package. It has been renamed to ``IRootFactory``. A deprecation warning is issued when it is imported from the older location. 0.6.1 (2009-01-06) ================== New Modules ----------- - 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 -------- - A ``static`` helper class was added to the ``repoze.bfg.views`` module. Instances of this class are willing to act as BFG views which return static resources using files on disk. See the ``repoze.bfg.view`` docs for more info. - 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 `_) for more information. 0.6 (2008-12-26) ================ Backwards Incompatibilities --------------------------- - Rather than prepare the "stock" implementations of the ZCML directives from the ``zope.configuration`` package for use under ``repoze.bfg``, ``repoze.bfg`` now makes available the implementations of directives from the ``repoze.zcml`` package (see http://static.repoze.org/zcmldocs). As a result, the ``repoze.bfg`` package now depends on the ``repoze.zcml`` package, and no longer depends directly on the ``zope.component``, ``zope.configuration``, ``zope.interface``, or ``zope.proxy`` packages. The primary reason for this change is to enable us to eventually reduce the number of inappropriate ``repoze.bfg`` Zope package dependencies, as well as to shed features of dependent package directives that don't make sense for ``repoze.bfg``. Note that currently the set of requirements necessary to use bfg has not changed. This is due to inappropriate Zope package requirements in ``chameleon.zpt``, which will hopefully be remedied soon. NOTE: in lemonade index a 1.0b8-repozezcml0 package exists which does away with these requirements. - BFG applications written prior to this release which expect the "stock" ``zope.component`` ZCML directive implementations (e.g. ``adapter``, ``subscriber``, or ``utility``) to function now must either 1) include the ``meta.zcml`` file from ``zope.component`` manually (e.g. ````) and include the ``zope.security`` package as an ``install_requires`` dependency or 2) change the ZCML in their applications to use the declarations from `repoze.zcml `_ instead of the stock declarations. ``repoze.zcml`` only makes available the ``adapter``, ``subscriber`` and ``utility`` directives. In short, if you've got an existing BFG application, after this update, if your application won't start due to an import error for "zope.security", the fastest way to get it working again is to add ``zope.security`` to the "install_requires" of your BFG application's ``setup.py``, then add the following ZCML anywhere in your application's ``configure.zcml``:: Then re-``setup.py develop`` or reinstall your application. - The ``http://namespaces.repoze.org/bfg`` XML namespace is now the default XML namespace in ZCML for paster-generated applications. The docs have been updated to reflect this. - The copies of BFG's ``meta.zcml`` and ``configure.zcml`` were removed from the root of the ``repoze.bfg`` package. In 0.3.6, a new package named ``repoze.bfg.includes`` was added, which contains the "correct" copies of these ZCML files; the ones that were removed were for backwards compatibility purposes. - The BFG ``view`` ZCML directive no longer calls ``zope.component.interface.provideInterface`` for the ``for`` interface. We don't support ``provideInterface`` in BFG because it mutates the global registry. Other ----- - The minimum requirement for ``chameleon.core`` is now 1.0b13. The minimum requirement for ``chameleon.zpt`` is now 1.0b8. The minimum requirement for ``chameleon.genshi`` is now 1.0b2. - Updated paster template "ez_setup.py" to one that requires setuptools 0.6c9. - Turn ``view_execution_permitted`` from the ``repoze.bfg.view`` module into a documented API. - Doc cleanups. - Documented how to create a view capable of serving static resources. 0.5.6 (2008-12-18) ================== - Speed up ``traversal.model_url`` execution by using a custom url quoting function instead of Python's ``urllib.quote``, by caching URL path segment quoting and encoding results, by disusing Python's ``urlparse.urljoin`` in favor of a simple string concatenation, and by using ``ob.__class__ is unicode`` rather than ``isinstance(ob, unicode)`` in one strategic place. 0.5.5 (2008-12-17) ================== Backwards Incompatibilities --------------------------- - In the past, during traversal, the ModelGraphTraverser (the default traverser) always passed each URL path segment to any ``__getitem__`` method of a model object as a byte string (a ``str`` object). Now, by default the ModelGraphTraverser attempts to decode the path segment to Unicode (a ``unicode`` object) using the UTF-8 encoding before passing it to the ``__getitem__`` method of a model object. This makes it possible for model objects to be dumber in ``__getitem__`` when trying to resolve a subobject, as model objects themselves no longer need to try to divine whether or not to try to decode the path segment passed by the traverser. Note that since 0.5.4, URLs generated by repoze.bfg's ``model_url`` API will contain UTF-8 encoded path segments as necessary, so any URL generated by BFG itself will be decodeable by the traverser. If another application generates URLs to a BFG application, to be resolved successully, it should generate the URL with UTF-8 encoded path segments to be successfully resolved. The decoder is not at all magical: if a non-UTF-8-decodeable path segment (e.g. one encoded using UTF-16 or some other insanity) is passed in the URL, BFG will raise a ``TypeError`` with a message indicating it could not decode the path segment. To turn on the older behavior, where path segments were not decoded to Unicode before being passed to model object ``__getitem__`` by the traverser, and were passed as a raw byte string, set the ``unicode_path_segments`` configuration setting to a false value in your BFG application's section of the paste .ini file, for example:: unicode_path_segments = False Or start the application using the ``BFG_UNICODE_PATH_SEGMENT`` envvar set to a false value:: BFG_UNICODE_PATH_SEGMENTS=0 0.5.4 (2008-12-13) ================== Backwards Incompatibilities --------------------------- - URL-quote "extra" element names passed in as ``**elements`` to the ``traversal.model_url`` API. If any of these names is a Unicode string, encode it to UTF-8 before URL-quoting. This is a slight backwards incompatibility that will impact you if you were already UTF-8 encoding or URL-quoting the values you passed in as ``elements`` to this API. Bugfixes -------- - UTF-8 encode each segment in the model path used to generate a URL before url-quoting it within the ``traversal.model_url`` API. This is a bugfix, as Unicode cannot always be successfully URL-quoted. Features -------- - Make it possible to run unit tests using a buildout-generated Python "interpreter". - Add ``request.root`` to ``router.Router`` in order to have easy access to the application root. 0.5.3 (2008-12-07) ================== - Remove the ``ITestingTemplateRenderer`` interface. When ``testing.registerDummyRenderer`` is used, it instead registers a dummy implementation using ``ITemplateRenderer`` interface, which is checked for when the built-in templating facilities do rendering. This change also allows developers to make explcit named utility registrations in the ZCML registry against ``ITemplateRenderer``; these will be found before any on-disk template is looked up. 0.5.2 (2008-12-05) ================== - The component registration handler for views (functions or class instances) now observes component adaptation annotations (see ``zope.component.adaptedBy``) and uses them before the fallback values for ``for_`` and ``request_type``. This change does not affect existing code insomuch as the code does not rely on these defaults when an annotation is set on the view (unlikely). This means that for a new-style class you can do ``zope.component.adapts(ISomeContext, ISomeRequest)`` at class scope or at module scope as a decorator to a bfg view function you can do ``@zope.component.adapter(ISomeContext, ISomeRequest)``. This differs from r.bfg.convention inasmuch as you still need to put something in ZCML for the registrations to get done; it's only the defaults that will change if these declarations exist. - Strip all slashes from end and beginning of path in clean_path within traversal machinery. 0.5.1 (2008-11-25) ================== - Add ``keys``, ``items``, and ``values`` methods to ``testing.DummyModel``. - Add __delitem__ method to ``testing.DummyModel``. 0.5.0 (2008-11-18) ================== - Fix ModelGraphTraverser; don't try to change the ``__name__`` or ``__parent__`` of an object that claims it implements ILocation during traversal even if the ``__name__`` or ``__parent__`` of the object traversed does not match the name used in the traversal step or the or the traversal parent . Rationale: it was insane to do so. This bug was only found due to a misconfiguration in an application that mistakenly had intermediate persistent non-ILocation objects; traversal was causing a persistent write on every request under this setup. - ``repoze.bfg.location.locate`` now unconditionally sets ``__name__`` and ``__parent__`` on objects which provide ILocation (it previously only set them conditionally if they didn't match attributes already present on the object via equality). 0.4.9 (2008-11-17) ================== - Add chameleon text template API (chameleon ${name} renderings where the template does not need to be wrapped in any containing XML). - Change docs to explain install in terms of a virtualenv (unconditionally). - Make pushpage decorator compatible with repoze.bfg.convention's ``bfg_view`` decorator when they're stacked. - Add content_length attribute to testing.DummyRequest. - Change paster template ``tests.py`` to include a true unit test. Retain old test as an integration test. Update documentation. - Document view registrations against classes and ``repoze.bfg.convention`` in context. - Change the default paster template to register its single view against a class rather than an interface. - Document adding a request type interface to the request via a subscriber function in the events narrative documentation. 0.4.8 (2008-11-12) ================== Backwards Incompatibilities --------------------------- - ``repoze.bfg.traversal.model_url`` now always appends a slash to all generated URLs unless further elements are passed in as the third and following arguments. Rationale: views often use ``model_url`` without the third-and-following arguments in order to generate a URL for a model in order to point at the default view of a model. The URL that points to the default view of the *root* model is technically ``http://mysite/`` as opposed to ``http://mysite`` (browsers happen to ask for '/' implicitly in the GET request). Because URLs are never automatically generated for anything *except* models by ``model_url``, and because the root model is not really special, we continue this pattern. The impact of this change is minimal (at most you will have too many slashes in your URL, which BFG deals with gracefully anyway). 0.4.7 (2008-11-11) ================== Features -------- - Allow ``testing.registerEventListener`` to be used with Zope 3 style "object events" (subscribers accept more than a single event argument). We extend the list with the arguments, rather than append. 0.4.6 (2008-11-10) ================== Bug Fixes --------- - The ``model_path`` and ``model_url`` traversal APIs returned the wrong value for the root object (e.g. ``model_path`` returned ``''`` for the root object, while it should have been returning ``'/'``). 0.4.5 (2008-11-09) ================== Features -------- - Added a ``clone`` method and a ``__contains__`` method to the DummyModel testing object. - Allow DummyModel objects to receive extra keyword arguments, which will be attached as attributes. - The DummyTemplateRenderer now returns ``self`` as its implementation. 0.4.4 (2008-11-08) ================== Features -------- - Added a ``repoze.bfg.testing`` module to attempt to make it slightly easier to write unittest-based automated tests of BFG applications. Information about this module is in the documentation. - The default template renderer now supports testing better by looking for ``ITestingTemplateRenderer`` using a relative pathname. This is exposed indirectly through the API named ``registerTemplateRenderer`` in ``repoze.bfg.testing``. Deprecations ------------ - The names ``repoze.bfg.interfaces.ITemplate`` , ``repoze.bfg.interfaces.ITemplateFactory`` and ``repoze.bfg.interfaces.INodeTemplate`` have been deprecated. These should now be imported as ``repoze.bfg.interfaces.ITemplateRenderer`` and ``repoze.bfg.interfaces.ITemplateRendererFactory``, and ``INodeTemplateRenderer`` respectively. - The name ``repoze.bfg.chameleon_zpt.ZPTTemplateFactory`` is deprecated. Use ``repoze.bfg.chameleon_zpt.ZPTTemplateRenderer``. - The name ``repoze.bfg.chameleon_genshi.GenshiTemplateFactory`` is deprecated. Use ``repoze.bfg.chameleon_genshi.GenshiTemplateRenderer``. - The name ``repoze.bfg.xslt.XSLTemplateFactory`` is deprecated. Use ``repoze.bfg.xslt.XSLTemplateRenderer``. 0.4.3 (2008-11-02) ================== Bug Fixes --------- - Not passing the result of "get_options" as the second argument of make_app could cause attribute errors when attempting to look up settings against the ISettings object (internal). Fixed by giving the Settings objects defaults for ``debug_authorization`` and ``debug_notfound``. - Return an instance of ``Allowed`` (rather than ``True``) from ``has_permission`` when no security policy is in use. - Fix bug where default deny in authorization check would throw a TypeError (use ``ACLDenied`` instead of ``Denied``). 0.4.2 (2008-11-02) ================== Features -------- - Expose a single ILogger named "repoze.bfg.debug" as a utility; this logger is registered unconditionally and is used by the authorization debug machinery. Applications may also make use of it as necessary rather than inventing their own logger, for convenience. - The ``BFG_DEBUG_AUTHORIZATION`` envvar and the ``debug_authorization`` config file value now only imply debugging of view-invoked security checks. Previously, information was printed for every call to ``has_permission`` as well, which made output confusing. To debug ``has_permission`` checks and other manual permission checks, use the debugger and print statements in your own code. - Authorization debugging info is now only present in the HTTP response body oif ``debug_authorization`` is true. - The format of authorization debug messages was improved. - A new ``BFG_DEBUG_NOTFOUND`` envvar was added and a symmetric ``debug_notfound`` config file value was added. When either is true, and a NotFound response is returned by the BFG router (because a view could not be found), debugging information is printed to stderr. When this value is set true, the body of HTTPNotFound responses will also contain the same debugging information. - ``Allowed`` and ``Denied`` responses from the security machinery are now specialized into two types: ACL types, and non-ACL types. The ACL-related responses are instances of ``repoze.bfg.security.ACLAllowed`` and ``repoze.bfg.security.ACLDenied``. The non-ACL-related responses are ``repoze.bfg.security.Allowed`` and ``repoze.bfg.security.Denied``. The allowed-type responses continue to evaluate equal to things that themselves evaluate equal to the ``True`` boolean, while the denied-type responses continue to evaluate equal to things that themselves evaluate equal to the ``False`` boolean. The only difference between the two types is the information attached to them for debugging purposes. - Added a new ``BFG_DEBUG_ALL`` envvar and a symmetric ``debug_all`` config file value. When either is true, all other debug-related flags are set true unconditionally (e.g. ``debug_notfound`` and ``debug_authorization``). Documentation ------------- - Added info about debug flag changes. - Added a section to the security chapter named "Debugging Imperative Authorization Failures" (for e.g. ``has_permssion``). Bug Fixes --------- - Change default paster template generator to use ``Paste#http`` server rather than ``PasteScript#cherrpy`` server. The cherrypy server has a security risk in it when ``REMOTE_USER`` is trusted by the downstream application. 0.4.1 (2008-10-28) ================== Bug Fixes --------- - If the ``render_view_to_response`` function was called, if the view was found and called, but it returned something that did not implement IResponse, the error would pass by unflagged. This was noticed when I created a view function that essentially returned None, but received a NotFound error rather than a ValueError when the view was rendered. This was fixed. 0.4.0 (2008-10-03) ================== Docs ---- - An "Environment and Configuration" chapter was added to the narrative portion of the documentation. Features -------- - Ensure bfg doesn't generate warnings when running under Python 2.6. - The environment variable ``BFG_RELOAD_TEMPLATES`` is now available (serves the same purpose as ``reload_templates`` in the config file). - A new configuration file option ``debug_authorization`` was added. This turns on printing of security authorization debug statements to ``sys.stderr``. The ``BFG_DEBUG_AUTHORIZATION`` environment variable was also added; this performs the same duty. Bug Fixes --------- - The environment variable ``BFG_SECURITY_DEBUG`` did not always work. It has been renamed to ``BFG_DEBUG_AUTHORIZATION`` and fixed. Deprecations ------------ - A deprecation warning is now issued when old API names from the ``repoze.bfg.templates`` module are imported. Backwards incompatibilities --------------------------- - The ``BFG_SECURITY_DEBUG`` environment variable was renamed to ``BFG_DEBUG_AUTHORIZATION``. 0.3.9 (2008-08-27) ================== Features -------- - A ``repoze.bfg.location`` API module was added. Backwards incompatibilities --------------------------- - Applications must now use the ``repoze.bfg.interfaces.ILocation`` interface rather than ``zope.location.interfaces.ILocation`` to represent that a model object is "location-aware". We've removed a dependency on ``zope.location`` for cleanliness purposes: as new versions of zope libraries are released which have improved dependency information, getting rid of our dependence on ``zope.location`` will prevent a newly installed repoze.bfg application from requiring the ``zope.security``, egg, which not truly used at all in a "stock" repoze.bfg setup. These dependencies are still required by the stack at this time; this is purely a futureproofing move. The security and model documentation for previous versions of ``repoze.bfg`` recommended using the ``zope.location.interfaces.ILocation`` interface to represent that a model object is "location-aware". This documentation has been changed to reflect that this interface should now be imported from ``repoze.bfg.interfaces.ILocation`` instead. 0.3.8 (2008-08-26) ================== Docs ---- - Documented URL dispatch better in narrative form. Bug fixes --------- - Routes URL dispatch did not have access to the WSGI environment, so conditions such as method=GET did not work. Features -------- - Add ``principals_allowed_by_permission`` API to security module. - Replace ``z3c.pt`` support with support for ``chameleon.zpt``. Chameleon is the new name for the package that used to be named ``z3c.pt``. NOTE: If you update a ``repoze.bfg`` SVN checkout that you're using for development, you will need to run "setup.py install" or "setup.py develop" again in order to obtain the proper Chameleon packages. ``z3c.pt`` is no longer supported by ``repoze.bfg``. All API functions that used to render ``z3c.pt`` templates will work fine with the new packages, and your templates should render almost identically. - Add a ``repoze.bfg.chameleon_zpt`` module. This module provides Chameleon ZPT support. - Add a ``repoze.bfg.xslt`` module. This module provides XSLT support. - Add a ``repoze.bfg.chameleon_genshi`` module. This provides direct Genshi support, which did not exist previously. Deprecations ------------ - Importing API functions directly from ``repoze.bfg.template`` is now deprecated. The ``get_template``, ``render_template``, ``render_template_to_response`` functions should now be imported from ``repoze.chameleon_zpt``. The ``render_transform``, and ``render_transform_to_response`` functions should now be imported from ``repoze.bfg.xslt``. The ``repoze.bfg.template`` module will remain around "forever" to support backwards compatibility. 0.3.7 (2008-09-09) ================== Features -------- - Add compatibility with z3c.pt 1.0a7+ (z3c.pt became a namespace package). Bug fixes --------- - ``repoze.bfg.traversal.find_model`` function did not function properly. 0.3.6 (2008-09-04) ================== Features -------- - Add startup process docs. - Allow configuration cache to be bypassed by actions which include special "uncacheable" discriminators (for actions that have variable results). Bug Fixes --------- - Move core repoze.bfg ZCML into a ``repoze.bfg.includes`` package so we can use repoze.bfg better as a namespace package. Adjust the code generator to use it. We've left around the ``configure.zcml`` in the repoze.bfg package directly so as not to break older apps. - When a zcml application registry cache was unpickled, and it contained a reference to an object that no longer existed (such as a view), bfg would not start properly. 0.3.5 (2008-09-01) ================== Features -------- - Event notification is issued after application is created and configured (``IWSGIApplicationCreatedEvent``). - New API module: ``repoze.bfg.view``. This module contains the functions named ``render_view_to_response``, ``render_view_to_iterable``, ``render_view`` and ``is_response``, which are documented in the API docs. These features aid programmatic (non-server-driven) view execution. 0.3.4 (2008-08-28) ================== Backwards incompatibilities --------------------------- - Make ``repoze.bfg`` a namespace package so we can allow folks to create subpackages (e.g. ``repoze.bfg.otherthing``) within separate eggs. This is a backwards incompatible change which makes it impossible to import "make_app" and "get_options" from the ``repoze.bfg`` module directly. This change will break all existing apps generated by the paster code generator. Instead, you need to import these functions as ``repoze.bfg.router:make_app`` and ``repoze.bfg.registry:get_options``, respectively. Sorry folks, it has to be done now or never, and definitely better now. Features -------- - Add ``model_path`` API function to traversal module. Bugfixes - Normalize path returned by repoze.bfg.caller_path. 0.3.3 (2008-08-23) ================== - Fix generated test.py module to use project name rather than package name. 0.3.2 (2008-08-23) ================== - Remove ``sampleapp`` sample application from bfg package itself. - Remove dependency on FormEncode (only needed by sampleapp). - Fix paster template generation so that case-sensitivity is preserved for project vs. package name. - Depend on ``z3c.pt`` version 1.0a1 (which requires the ``[lxml]`` extra currently). - Read and write a pickled ZCML actions list, stored as ``configure.zcml.cache`` next to the applications's "normal" configuration file. A given bfg app will usually start faster if it's able to read the pickle data. It fails gracefully to reading the real ZCML file if it cannot read the pickle. 0.3.1 (2008-08-20) ================== - Generated application differences: ``make_app`` entry point renamed to ``app`` in order to have a different name than the bfg function of the same name, to prevent confusion. - Add "options" processing to bfg's ``make_app`` to support runtime options. A new API function named ``get_options`` was added to the registry module. This function is typically used in an application's ``app`` entry point. The Paste config file section for the app can now supply the ``reload_templates`` option, which, if true, will prevent the need to restart the appserver in order for ``z3c.pt`` or XSLT template changes to be detected. - Use only the module name in generated project's "test_suite" (run all tests found in the package). - Default port for generated apps changed from 5432 to 6543 (Postgres default port is 6543). 0.3.0 (2008-08-16) ================== - Add ``get_template`` API to template module. 0.2.9 (2008-08-11) ================== - 0.2.8 was "brown bag" release. It didn't work at all. Symptom: ComponentLookupError when trying to render a page. 0.2.8 (2008-08-11) ================== - Add ``find_model`` and ``find_root`` traversal APIs. In the process, make ITraverser a uni-adapter (on context) rather than a multiadapter (on context and request). 0.2.7 (2008-08-05) ================== - Add a ``request_type`` attribute to the available attributes of a ``bfg:view`` configure.zcml element. This attribute will have a value which is a dotted Python path, pointing at an interface. If the request object implements this interface when the view lookup is performed, the appropriate view will be called. This is meant to allow for simple "skinning" of sites based on request type. An event subscriber should attach the interface to the request on ingress to support skins. - Remove "template only" views. These were just confusing and were never documented. - Small url dispatch overhaul: the ``connect`` method of the ``urldispatch.RoutesMapper`` object now accepts a keyword parameter named ``context_factory``. If this parameter is supplied, it must be a callable which returns an instance. This instance is used as the context for the request when a route is matched. - The registration of a RoutesModelTraverser no longer needs to be performed by the application; it's in the bfg ZCML now. 0.2.6 (2008-07-31) ================== - Add event sends for INewRequest and INewResponse. See the events.rst chapter in the documentation's ``api`` directory. 0.2.5 (2008-07-28) ================== - Add ``model_url`` API. 0.2.4 (2008-07-27) ================== - Added url-based dispatch. 0.2.3 (2008-07-20) ================== - Add API functions for authenticated_userid and effective_principals. 0.2.2 (2008-07-20) ================== - Add authenticated_userid and effective_principals API to security policy. 0.2.1 (2008-07-20) ================== - Add find_interface API. 0.2 (2008-07-19) ================ - Add wsgiapp decorator. - The concept of "view factories" was removed in favor of always calling a view, which is a callable that returns a response directly (as opposed to returning a view). As a result, the ``factory`` attribute in the bfg:view ZCML statement has been renamed to ``view``. Various interface names were changed also. - ``render_template`` and ``render_transform`` no longer return a Response object. Instead, these return strings. The old behavior can be obtained by using ``render_template_to_response`` and ``render_transform_to_response``. - Added 'repoze.bfg.push:pushpage' decorator, which creates BFG views from callables which take (context, request) and return a mapping of top-level names. - Added ACL-based security. - Support for XSLT templates via a render_transform method 0.1 (2008-07-08) ================ - Initial release.