Pyramid Change History¶
1.0.2 (2011-12-14)¶
Features¶
- Backport the
egg:pyramid#wsgirefandegg:pyramid#cherrypyserver runners from the 1.3 branch. This change is to primarily allow scaffolding authors to rely on the wsgiref entry point for projects that are meant to work on both Pyramid 1.0.X and 1.3.X.
1.0.1 (2011-08-13)¶
Backported Features¶
- Backport from 1.2dev: A new attribute is available on request objects:
exc_info. Its value will beNoneuntil an exception is caught by the Pyramid router, after which it will be the result ofsys.exc_info().
1.0 (2011-01-30)¶
Documentation¶
- Fixed bug in ZODB Wiki tutorial (missing dependency on
docutilsin “models” step withinsetup.py). - Removed API documentation for
pyramid.testingAPIs namedregisterDummySecurityPolicy,registerResources,registerModels,registerEventListener,registerTemplateRenderer,registerDummyRenderer,registerView,registerUtility,registerAdapter,registerSubscriber,registerRoute, andregisterSettings. - Moved “Using ZODB With ZEO” and “Using repoze.catalog Within Pyramid” tutorials out of core documentation and into the Pyramid Tutorials site (http://docs.pylonsproject.org/projects/pyramid_tutorials/dev/).
- Changed “Cleaning up After a Request” section in the URL Dispatch chapter
to use
request.add_finished_callbackinstead of jamming an object with a__del__into the WSGI environment. - Remove duplication of
add_routeAPI documentation from URL Dispatch narrative chapter. - Remove duplication of API and narrative documentation in
pyramid.view.view_configAPI docs by pointing topyramid.config.add_viewdocumentation and narrative chapter documentation. - Removed some API documentation duplicated in narrative portions of documentation
- Removed “Overall Flow of Authentication” from SQLAlchemy + URL Dispatch wiki tutorial due to print space concerns (moved to Pyramid Tutorials site).
Bug Fixes¶
- Deprecated-since-BFG-1.2 APIs from
pyramid.testingnow properly emit deprecation warnings. - Added
egg:repoze.retry#retrymiddleware to the WSGI pipeline in ZODB templates (retry ZODB conflict errors which occur in normal operations). - Removed duplicate implementations of
is_response. Two competing implementations existed: one inpyramid.configand one inpyramid.view. Now the one defined inpyramid.viewis used internally bypyramid.configand continues to be advertised as an API.
1.0b3 (2011-01-28)¶
Bug Fixes¶
- Use © instead of copyright symbol in paster templates / tutorial templates for the benefit of folks who cutnpaste and save to a non-UTF8 format.
pyramid.view.append_slash_notfound_viewnow preserves GET query parameters across redirects.
Documentation¶
- Beef up documentation related to
set_default_permission: explicitly mention that default permissions also protect exception views. - Paster templates and tutorials now use spaces instead of tabs in their HTML templates.
1.0b2 (2011-01-24)¶
Bug Fixes¶
- The
production.inigenerated by all paster templates now have an effective logging level of WARN, which prevents e.g. SQLAlchemy statement logging and other inappropriate output. - The
production.iniof thepyramid_routesalchemyandpyramid_alchemypaster templates did not have asqlalchemylogger section, preventingpaster serve production.inifrom working. - The
pyramid_routesalchemyandpyramid_alchemypaster templates used the{{package}}variable in a place where it should have used the{{project}}variable, causing applications created with uppercase letters e.g.paster create -t pyramid_routesalchemy Dibbusto fail to start whenpaster serve development.iniwas used against the result. See https://github.com/Pylons/pyramid/issues/#issue/107 - The
render_viewmethod ofpyramid.renderers.RendererHelperpassed an incorrect value into the renderer forrenderer_info. It now passes an instance ofRendererHelperinstead of a dictionary, which is consistent with other usages. See https://github.com/Pylons/pyramid/issues#issue/106 - A bug existed in the
pyramid.authentication.AuthTktCookieHelperwhich would break any usage of an AuthTktAuthenticationPolicy when one was configured to reissue its tokens (reissue_time<timeout/max_age). Symptom:ValueError: ('Invalid token %r', ''). See https://github.com/Pylons/pyramid/issues#issue/108.
1.0b1 (2011-01-21)¶
Features¶
- The AuthTktAuthenticationPolicy now accepts a
tokensparameter viapyramid.security.remember. The value must be a sequence of strings. Tokens are placed into the auth_tkt “tokens” field and returned in the auth_tkt cookie. - Add
wild_domainargument to AuthTktAuthenticationPolicy, which defaults toTrue. If it is set toFalse, the feature of the policy which sets a cookie with a wilcard domain will be turned off. - Add a
MANIFEST.infile to each paster template. See https://github.com/Pylons/pyramid/issues#issue/95
Bug Fixes¶
testing.setUpnow adds asettingsattribute to the registry (both when it’s passed a registry without any settings and when it creates one).- The
testing.setUpfunction now takes asettingsargument, which should be a dictionary. Its values will subsequently be available on the returnedconfigobject asconfig.registry.settings.
Documentation¶
- Added “What’s New in Pyramid 1.0” chapter to HTML rendering of documentation.
- Merged caseman-master narrative editing branch, many wording fixes and extensions.
- Fix deprecated example showing
chameleon_zptAPI call in testing narrative chapter. - Added “Adding Methods to the Configurator via
add_directive” section to Advanced Configuration narrative chapter. - Add docs for
add_finished_callback,add_response_callback,route_path,route_url, andstatic_urlmethods topyramid.request.RequestAPI docs. - Add (minimal) documentation about using I18N within Mako templates to “Internationalization and Localization” narrative chapter.
- Move content of “Forms” chapter back to “Views” chapter; I can’t think of a better place to put it.
- Slightly improved interface docs for
IAuthorizationPolicy. - Minimally explain usage of custom regular expressions in URL dispatch replacement markers within URL Dispatch chapter.
Deprecations¶
- Using the
pyramid.view.bfg_viewalias forpyramid.view.view_config(a backwards compatibility shim) now issues a deprecation warning.
Backwards Incompatibilities¶
- When a
pyramid.exceptions.Forbiddenerror is raised, its status code now403 Forbidden. It was previously401 Unauthorized, for backwards compatibility purposes withrepoze.bfg. This change will cause problems for users of Pyramid withrepoze.who, which intercepts401 Unauthorizedby default, but allows403 Forbiddento pass through. Those deployments will need to configurerepoze.whoto also react to403 Forbidden. - The default value for the
cookie_on_exceptionparameter topyramid.session.UnencyrptedCookieSessionFactoryis nowTrue. This means that when view code causes an exception to be raised, and the session has been mutated, a cookie will be sent back in the response. Previously its default value wasFalse.
Paster Templates¶
- The
pyramid_zodb,pyramid_routesalchemyandpyramid_alchemypaster templates now use a default “commit veto” hook when configuring therepoze.tm2transaction manager indevelopment.ini. This prevents a transaction from being committed when the response status code is within the 400 or 500 ranges. See also http://docs.repoze.org/tm2/#using-a-commit-veto.
1.0a10 (2011-01-18)¶
Bug Fixes¶
- URL dispatch now properly handles a
.*or*appearing in a regex match when used inside brackets. Resolves issue #90.
Backwards Incompatibilities¶
- The
add_handlermethod of a Configurator has been removed from the Pyramid core. Handlers are now a feature of thepyramid_handlerspackage, which can be downloaded from PyPI. Documentation for the package should be available via http://pylonsproject.org/projects/pyramid_handlers/dev/, which describes how to add a configuration statement to yourmainblock to reobtain this method. You will also need to add aninstall_requiresdependency uponpyramid_handlersto yoursetup.pyfile. - The
load_zcmlmethod of a Configurator has been removed from the Pyramid core. Loading ZCML is now a feature of thepyramid_zcmlpackage, which can be downloaded from PyPI. Documentation for the package should be available via http://pylonsproject.org/projects/pyramid_zcml/dev/, which describes how to add a configuration statement to yourmainblock to reobtain this method. You will also need to add aninstall_requiresdependency uponpyramid_zcmlto yoursetup.pyfile. - The
pyramid.includessubpackage has been removed. ZCML files which use include the packagepyramid.includes(e.g.<include package="pyramid.includes"/>) now must include thepyramid_zcmlpackage instead (e.g.<include package="pyramid_zcml"/>). - The
pyramid.view.actiondecorator has been removed from the Pyramid core. Handlers are now a feature of thepyramid_handlerspackage. It should now be imported frompyramid_handlerse.g.from pyramid_handlers import action. - The
handlerZCML directive has been removed. It is now a feature of thepyramid_handlerspackage. - The
pylons_minimal,pylons_basicandpylons_sqlapaster templates were removed. Usepyramid_sqla(available from PyPI) as a generic replacement for Pylons-esque development. - The
make_appfunction has been removed from thepyramid.routermodule. It continues life within thepyramid_zcmlpackage. This leaves thepyramid.routermodule without any API functions. - The
configure_zcmlsetting within the deployment settings (within**settingspassed to a Pyramidmainfunction) has ceased to have any meaning.
Features¶
pyramid.testing.setUpandpyramid.testing.tearDownhave been undeprecated. They are now the canonical setup and teardown APIs for test configuration, replacing “direct” creation of a Configurator. This is a change designed to provide a facade that will protect against any future Configurator deprecations.- Add
charsetattribute topyramid.testing.DummyRequest(unconditionallyUTF-8). - Add
add_directivemethod to configurator, which allows framework extenders to add methods to the configurator (ala ZCML directives). - When
Configurator.includeis passed a module as an argument, it defaults to attempting to find and use a callable namedincludemewithin that module. This makes it possible to useconfig.include('some.module')rather thanconfig.include('some.module.somefunc')as long as the include function withinsome.moduleis namedincludeme. - The
bfg2pyramidscript now converts ZCML include tags that haverepoze.bfg.includesas a package attribute to the valuepyramid_zcml. For example,<include package="repoze.bfg.includes">will be converted to<include package="pyramid_zcml">.
Paster Templates¶
- All paster templates now use
pyramid.testing.setUpandpyramid.testing.tearDownrather than creating a Configurator “by hand” within theirtests.pymodule, as per decision in features above. - The
starter_zcmlpaster template has been moved to thepyramid_zcmlpackage.
Documentation¶
- The wiki and wiki2 tutorials now use
pyramid.testing.setUpandpyramid.testing.tearDownrather than creating a Configurator “by hand”, as per decision in features above. - The “Testing” narrative chapter now explains
pyramid.testing.setUpandpyramid.testing.tearDowninstead of Configurator creation andConfigurator.begin()andConfigurator.end(). - Document the
request.override_rendererattribute within the narrative “Renderers” chapter in a section named “Overriding A Renderer at Runtime”. - The “Declarative Configuration” narrative chapter has been removed (it was
moved to the
pyramid_zcmlpackage). - Most references to ZCML in narrative chapters have been removed or
redirected to
pyramid_zcmllocations.
Deprecations¶
- Deprecation warnings related to import of the following API functions were
added:
pyramid.traversal.find_model,pyramid.traversal.model_path,pyramid.traversal.model_path_tuple,pyramid.url.model_url. The instructions emitted by the deprecation warnings instruct the developer to change these method spellings to theirresourceequivalents. This is a consequence of the mass concept rename of “model” to “resource” performed in 1.0a7.
1.0a9 (2011-01-08)¶
Bug Fixes¶
- The
proutescommand tried too hard to resolve the view for printing, resulting in exceptions when an exceptional root factory was encountered. Instead of trying to resolve the view, if it cannot, it will now just print<unknown>. - The self argument was included in new methods of the
ISessioninterface signature, causingpyramid_beakertests to fail. - Readd
pyramid.traversal.model_path_tupleas an alias forpyramid.traversal.resource_path_tuplefor backwards compatibility.
Features¶
- Add a new API
pyramid.url.current_route_url, which computes a URL based on the “current” route (if any) and its matchdict values. config.add_viewnow accepts adecoratorkeyword argument, a callable which will decorate the view callable before it is added to the registry.- If a handler class provides an
__action_decorator__attribute (usually a classmethod or staticmethod), use that as the decorator for each view registration for that handler. - The
pyramid.interfaces.IAuthenticationPolicyinterface now specifies anunauthenticated_useridmethod. This method supports an important optimization required by people who are using persistent storages which do not support object caching and whom want to create a “user object” as a request attribute. - A new API has been added to the
pyramid.securitymodule namedunauthenticated_userid. This API function calls theunauthenticated_useridmethod of the effective security policy. - An
unauthenticated_useridmethod has been added to the dummy authentication policy returned bypyramid.config.Configurator.testing_securitypolicy. It returns the same thing as that the dummy authentication policy’sauthenticated_useridmethod. - The class
pyramid.authentication.AuthTktCookieHelperis now an API. This class can be used by third-party authentication policy developers to help in the mechanics of authentication cookie-setting. - New constructor argument to Configurator:
default_view_mapper. Useful to create systems that have alternate view calling conventions. A view mapper allows objects that are meant to be used as view callables to have an arbitrary argument list and an arbitrary result. The object passed asdefault_view_mappershould implement thepyramid.interfaces.IViewMapperFactoryinterface. - add a
set_view_mapperAPI to Configurator. Has the same result as passingdefault_view_mapperto the Configurator constructor. config.add_viewnow accepts amapperkeyword argument, which should either beNone, a string representing a Python dotted name, or an object which is anIViewMapperFactory. This feature is not useful for “civilians”, only for extension writers.- Allow static renderer provided during view registration to be overridden at
request time via a request attribute named
override_renderer, which should be the name of a previously registered renderer. Useful to provide “omnipresent” RPC using existing rendered views. - Instances of
pyramid.testing.DummyRequestnow have asessionobject, which is mostly a dictionary, but also implements the other session API methods for flash and CSRF.
Backwards Incompatibilities¶
- Since the
pyramid.interfaces.IAuthenticationPolicyinterface now specifies that a policy implementation must implement anunauthenticated_useridmethod, all third-party custom authentication policies now must implement this method. It, however, will only be called when the global function namedpyramid.security.unauthenticated_useridis invoked, so if you’re not invoking that, you will not notice any issues. pyramid.interfaces.ISession.get_csrf_tokennow mandates that an implementation should return a new token if one doesn’t already exist in the session (previously it would return None). The internal sessioning implementation has been changed.
Documentation¶
- The (weak) “Converting a CMF Application to Pyramid” tutorial has been
removed from the tutorials section. It was moved to the
pyramid_tutorialsGithub repository. - The “Resource Location and View Lookup” chapter has been replaced with a variant of Rob Miller’s “Much Ado About Traversal” (originally published at http://blog.nonsequitarian.org/2010/much-ado-about-traversal/).
- Many minor wording tweaks and refactorings (merged Casey Duncan’s docs fork, in which he is working on general editing).
- Added (weak) description of new view mapper feature to Hooks narrative chapter.
- Split views chapter into 2: View Callables and View Configuration.
- Reorder Renderers and Templates chapters after View Callables but before View Configuration.
- Merge Session Objects, Cross-Site Request Forgery, and Flash Messaging chapter into a single Sessions chapter.
- The Wiki and Wiki2 tutorials now have much nicer CSS and graphics.
Internals¶
- The “view derivation” code is now factored into a set of classes rather than a large number of standalone functions (a side effect of the view mapper refactoring).
- The
pyramid.renderer.RendererHelperclass has grown arender_viewmethod, which is used by the default view mapper (a side effect of the view mapper refactoring). - The object passed as
rendererto the “view deriver” is now an instance ofpyramid.renderers.RendererHelperrather than a dictionary (a side effect of view mapper refactoring). - The class used as the “page template” in
pyramid.chameleon_textwas removed, in preference to using a Chameleon-inbuilt version. - A view callable wrapper registered in the registry now contains an
__original_view__attribute which references the original view callable (or class). - The (non-API) method of all internal authentication policy implementations
previously named
_get_useridis now namedunauthenticated_userid, promoted to an API method. If you were overriding this method, you’ll now need to override it asunauthenticated_useridinstead. - Remove (non-API) function of config.py named _map_view.
1.0a8 (2010-12-27)¶
Bug Fixes¶
- The name
registrywas not available in thepaster pshellenvironment under IPython.
Features¶
- If a resource implements a
__resource_url__method, it will be called as the result of invoking thepyramid.url.resource_urlfunction to generate a URL, overriding the default logic. See the new “Generating The URL Of A Resource” section within the Resources narrative chapter. - Added flash messaging, as described in the “Flash Messaging” narrative documentation chapter.
- Added CSRF token generation, as described in the narrative chapter entitled “Preventing Cross-Site Request Forgery Attacks”.
- Prevent misunderstanding of how the
viewandview_permissionarguments to add_route work by raising an exception during configuration if view-related arguments exist but noviewargument is passed. - Add
paster proutecommand which displays a summary of the routing table. See the narrative documentation section within the “URL Dispatch” chapter entitled “Displaying All Application Routes”.
Paster Templates¶
- The
pyramid_zodbPaster template no longer employs ZCML. Instead, it is based on scanning.
Documentation¶
- Added “Generating The URL Of A Resource” section to the Resources narrative
chapter (includes information about overriding URL generation using
__resource_url__). - Added “Generating the Path To a Resource” section to the Resources narrative chapter.
- Added “Finding a Resource by Path” section to the Resources narrative chapter.
- Added “Obtaining the Lineage of a Resource” to the Resources narrative chapter.
- Added “Determining if a Resource is In The Lineage of Another Resource” to Resources narrative chapter.
- Added “Finding the Root Resource” to Resources narrative chapter.
- Added “Finding a Resource With a Class or Interface in Lineage” to Resources narrative chapter.
- Added a “Flash Messaging” narrative documentation chapter.
- Added a narrative chapter entitled “Preventing Cross-Site Request Forgery Attacks”.
- Changed the “ZODB + Traversal Wiki Tutorial” based on changes to
pyramid_zodbPaster template. - Added “Advanced Configuration” narrative chapter which documents how to
deal with configuration conflicts, two-phase configuration,
includeandcommit. - Fix API documentation rendering for
pyramid.view.static - Add “Pyramid Provides More Than One Way to Do It” to Design Defense documentation.
- Changed “Static Assets” narrative chapter: clarify that
namerepresents a prefix unless it’s a URL, added an example of a root-relative static view fallback for URL dispatch, added an example of creating a simple view that returns the body of a file. - Move ZCML usage in Hooks chapter to Declarative Configuration chapter.
- Merge “Static Assets” chapter into the “Assets” chapter.
- Added narrative documentation section within the “URL Dispatch” chapter
entitled “Displaying All Application Routes” (for
paster proutescommand).
1.0a7 (2010-12-20)¶
Terminology Changes¶
The Pyramid concept previously known as “model” is now known as “resource”. As a result:
The following API changes have been made:
pyramid.url.model_url -> pyramid.url.resource_url pyramid.traversal.find_model -> pyramid.url.find_resource pyramid.traversal.model_path -> pyramid.traversal.resource_path pyramid.traversal.model_path_tuple -> pyramid.traversal.resource_path_tuple pyramid.traversal.ModelGraphTraverser -> pyramid.traversal.ResourceTreeTraverser pyramid.config.Configurator.testing_models -> pyramid.config.Configurator.testing_resources pyramid.testing.registerModels -> pyramid.testing.registerResources pyramid.testing.DummyModel -> pyramid.testing.DummyResource
- All documentation which previously referred to “model” now refers to “resource”.
- The
starterandstarter_zcmlpaster templates now have aresources.pymodule instead of amodels.pymodule.
- Positional argument names of various APIs have been changed from
modeltoresource.
Backwards compatibility shims have been left in place in all cases. They will continue to work “forever”.
The Pyramid concept previously known as “resource” is now known as “asset”. As a result:
The (non-API) module previously known as
pyramid.resourceis now known aspyramid.asset.All docs that previously referred to “resource specification” now refer to “asset specification”.
The following API changes were made:
pyramid.config.Configurator.absolute_resource_spec -> pyramid.config.Configurator.absolute_asset_spec pyramid.config.Configurator.override_resource -> pyramid.config.Configurator.override_assetThe ZCML directive previously known as
resourceis now known asasset.The setting previously known as
BFG_RELOAD_RESOURCES(envvar) orreload_resources(config file) is now known, respectively, asPYRAMID_RELOAD_ASSETSandreload_assets.
Backwards compatibility shims have been left in place in all cases. They will continue to work “forever”.
Bug Fixes¶
- Make it possible to succesfully run all tests via
nosetestscommand directly (rather than indirectly viapython setup.py nosetests). - When a configuration conflict is encountered during scanning, the conflict exception now shows the decorator information that caused the conflict.
Features¶
- Added
debug_routematchconfiguration setting that logs matched routes (including the matchdict and predicates). - The name
registryis now available in apshellenvironment by default. It is the application registry object.
Environment¶
- All environment variables which used to be prefixed with
BFG_are now prefixed withPYRAMID_(e.g.BFG_DEBUG_NOTFOUNDis nowPYRAMID_DEBUG_NOTFOUND)
Documentation¶
- Added “Debugging Route Matching” section to the urldispatch narrative documentation chapter.
- Added reference to
PYRAMID_DEBUG_ROUTEMATCHenvvar anddebug_routematchconfig file setting to the Environment narrative docs chapter. - Changed “Project” chapter slightly to expand on use of
paster pshell. - Direct Jython users to Mako rather than Jinja2 in “Install” narrative chapter.
- Many changes to support terminological renaming of “model” to “resource” and “resource” to “asset”.
- Added an example of
WebTestfunctional testing to the testing narrative chapter. - Rearranged chapter ordering by popular demand (URL dispatch first, then traversal). Put hybrid chapter after views chapter.
- Split off “Renderers” as its own chapter from “Views” chapter in narrative documentation.
Paster Templates¶
- Added
debug_routematch = falseto all paster templates.
Dependencies¶
- Depend on Venusian >= 0.5 (for scanning conflict exception decoration).
1.0a6 (2010-12-15)¶
Bug Fixes¶
- 1.0a5 introduced a bug when
pyramid.config.Configurator.scanwas used without apackageargument (e.g.config.scan()as opposed toconfig.scan('packagename'). The symptoms were: lots of deprecation warnings printed to the console about imports of deprecated Pyramid functions and classes and non-detection of view callables decorated withview_configdecorators. This has been fixed. - Tests now pass on Windows (no bugs found, but a few tests in the test suite assumed UNIX path segments in filenames).
Documentation¶
- If you followed it to-the-letter, the ZODB+Traversal Wiki tutorial would
instruct you to run a test which would fail because the view callable
generated by the
pyramid_zodbtutorial used a one-arg view callable, but the test in the sample code used a two-arg call. - Updated ZODB+Traversal tutorial setup.py of all steps to match what’s
generated by
pyramid_zodb. - Fix reference to
repoze.bfg.traversalwrapperin “Models” chapter (point atpyramid_traversalwrapperinstead).
1.0a5 (2010-12-14)¶
Features¶
- Add a
handlerZCML directive. This directive does the same thing aspyramid.configuration.add_handler. - A new module named
pyramid.configwas added. It subsumes the duties of the olderpyramid.configurationmodule. - The new
pyramid.config.Configurator` class has API methods that the older ``pyramid.configuration.Configuratorclass did not:with_context(a classmethod),include,action, andcommit. These methods exist for imperative application extensibility purposes. - The
pyramid.testing.setUpfunction now accepts anautocommitkeyword argument, which defaults toTrue. If it is passedFalse, the Config object returned bysetUpwill be a non-autocommiting Config object. - Add logging configuration to all paster templates.
pyramid_alchemy,pyramid_routesalchemy, andpylons_sqlapaster templates now use idiomatic SQLAlchemy configuration in their respective.inifiles and Python code.pyramid.testing.DummyRequestnow has a class variable,query_string, which defaults to the empty string.- Add support for json on GAE by catching NotImplementedError and importing simplejson from django.utils.
- The Mako renderer now accepts a resource specification for
mako.module_directory. - New boolean Mako settings variable
mako.strict_undefined. See Mako Context Variables for its meaning.
Dependencies¶
- Depend on Mako 0.3.6+ (we now require the
strict_undefinedfeature).
Bug Fixes¶
- When creating a Configurator from within a
paster pshellsession, you were required to pass apackageargument althoughpackageis not actually required. If you didn’t passpackage, you would receive an error something likeKeyError: '__name__'emanating from thepyramid.path.caller_modulefunction. This has now been fixed. - The
pyramid_routesalchemypaster template’s unit tests failed (AssertionError: 'SomeProject' != 'someproject'). This is fixed. - Make default renderer work (renderer factory registered with no name, which is active for every view unless the view names a specific renderer).
- The Mako renderer did not properly turn the
mako.imports,mako.default_filters, andmako.importssettings into lists. - The Mako renderer did not properly convert the
mako.error_handlersetting from a dotted name to a callable.
Documentation¶
- Merged many wording, readability, and correctness changes to narrative documentation chapters from https://github.com/caseman/pyramid (up to and including “Models” narrative chapter).
- “Sample Applications” section of docs changed to note existence of Cluegun, Shootout and Virginia sample applications, ported from their repoze.bfg origin packages.
- SQLAlchemy+URLDispatch tutorial updated to integrate changes to
pyramid_routesalchemytemplate. - Add
pyramid.interfaces.ITemplateRendererinterface to Interfaces API chapter (hasimplementation()method, required to be used when getting at Chameleon macros). - Add a “Modifying Package Structure” section to the project narrative documentation chapter (explain turning a module into a package).
- Documentation was added for the new
handlerZCML directive in the ZCML section.
Deprecations¶
pyramid.configuration.Configuratoris now deprecated. Usepyramid.config.Configurator, passing its constructorautocommit=Trueinstead. Thepyramid.configuration.Configuratoralias will live for a long time, as every application uses it, but its import now issues a deprecation warning. Thepyramid.config.Configuratorclass has the same API aspyramid.configuration.Configuratorclass, which it means to replace, except by default it is a non-autocommitting configurator. The now-deprecatedpyramid.configuration.Configuratorwill autocommit every time a configuration method is called.The
pyramid.configurationmodule remains, but it is deprecated. Usepyramid.configinstead.
1.0a4 (2010-11-21)¶
Features¶
- URL Dispatch now allows for replacement markers to be located anywhere
in the pattern, instead of immediately following a
/. - URL Dispatch now uses the form
{marker}to denote a replace marker in the route pattern instead of:marker. The old colon-style marker syntax is still accepted for backwards compatibility. The new format allows a regular expression for that marker location to be used instead of the default[^/]+, for example{marker:\d+}is now valid to require the marker to be digits. - Add a
pyramid.url.route_pathAPI, allowing folks to generate relative URLs. Callingroute_pathis the same as callingpyramid.url.route_urlwith the argument_app_urlequal to the empty string. - Add a
pyramid.request.Request.route_pathAPI. This is a convenience method of the request which callspyramid.url.route_url. - Make test suite pass on Jython (requires PasteScript trunk, presumably to be 1.7.4).
- Make test suite pass on PyPy (Chameleon doesn’t work).
- Surrounding application configuration with
config.begin()andconfig.end()is no longer necessary. All paster templates have been changed to no longer call these functions. - Fix configurator to not convert
ImportErrortoConfigurationErrorif the import that failed was unrelated to the import requested via a dotted name when resolving dotted names (such as view dotted names).
Documentation¶
- SQLAlchemy+URLDispatch and ZODB+Traversal tutorials have been updated to
not call
config.begin()orconfig.end().
Bug Fixes¶
- Add deprecation warnings to import of
pyramid.chameleon_textandpyramid.chameleon_zptofget_renderer,get_template,render_template, andrender_template_to_response. - Add deprecation warning for import of
pyramid.zcml.zcml_configureandpyramid.zcml.file_configure. - The
pyramid_alchemypaster template had a typo, preventing an import from working. - Fix apparent failures when calling
pyramid.traversal.find_model(root, path)orpyramid.traversal.traverse(path)whenpathis (erroneously) a Unicode object. The user is meant to pass these APIs a string object, never a Unicode object. In practice, however, users indeed pass Unicode. Because the string that is passed must be ASCII encodeable, now, if they pass a Unicode object, its data is eagerly converted to an ASCII string rather than being passed along to downstream code as a convenience to the user and to prevent puzzling second-order failures from cropping up (all failures will occur withinpyramid.traversal.traverserather than later down the line as the result of calling e.g.traversal_path).
Backwards Incompatibilities¶
- The
pyramid.testing.zcml_configureAPI has been removed. It had been advertised as removed since repoze.bfg 1.2a1, but hadn’t actually been.
Deprecations¶
- The
pyramid.settings.get_settingsAPI is now deprecated. Usepyramid.threadlocals.get_current_registry().settingsinstead or use thesettingsattribute of the registry available from the request (request.registry.settings).
Documentation¶
- Removed
zodbsessionstutorial chapter. It’s still useful, but we now have a SessionFactory abstraction which competes with it, and maintaining documentation on both ways to do it is a distraction.
Internal¶
- Replace Twill with WebTest in internal integration tests (avoid deprecation warnings generated by Twill).
1.0a3 (2010-11-16)¶
Features¶
- Added Mako TemplateLookup settings for
mako.error_handler,mako.default_filters, andmako.imports. - Normalized all paster templates: each now uses the name
mainto represent the function that returns a WSGI application, each now uses WebError, each now has roughly the same shape of development.ini style. - Added class vars
matchdictandmatched_routetopyramid.request.Request. Each is set toNone. - New API method:
pyramid.settings.asbool. - New API methods for
pyramid.request.Request:model_url,route_url, andstatic_url. These are simple passthroughs for their respective functions inpyramid.url. - The
settingsobject which used to be available only whenrequest.settings.get_settingswas called is now available asregistry.settings(e.g.request.registry.settingsin view code).
Bug Fixes¶
- The pylons_* paster templates erroneously used the
{squiggly}routing syntax as the pattern supplied toadd_route. This style of routing is not supported. They were replaced with:colonstyle route patterns. - The pylons_* paster template used the same string
(
your_app_secret_string) for thesession.secretsetting in the generateddevelopment.ini. This was a security risk if left unchanged in a project that used one of the templates to produce production applications. It now uses a randomly generated string.
Documentation¶
- ZODB+traversal wiki (
wiki) tutorial updated due to changes topyramid_zodbpaster template. - SQLAlchemy+urldispach wiki (
wiki2) tutorial updated due to changes topyramid_routesalchemypaster template. - Documented the
matchdictandmatched_routeattributes of the request object in the Request API documentation.
Deprecations¶
- Obtaining the
settingsobject viaregistry.{get|query}Utility(ISettings)is now deprecated. Instead, obtain thesettingsobject via theregistry.settingsattribute. A backwards compatibility shim was added to the registry object to register the settings object as an ISettings utility whensetattr(registry, 'settings', foo)is called, but it will be removed in a later release. - Obtaining the
settingsobject viapyramid.settings.get_settingsis now deprecated. Obtain it as thesettingsattribute of the registry now (obtain the registry viapyramid.threadlocal.get_registryor asrequest.registry).
Behavior Differences¶
- Internal: ZCML directives no longer call get_current_registry() if there’s
a
registryattribute on the ZCML context (kill off use of threadlocals). - Internal: Chameleon template renderers now accept two arguments:
pathandlookup.Lookupwill be an instance of a lookup class which supplies (late-bound) arguments for debug, reload, and translate. Any third-party renderers which use (the non-API) functionpyramid.renderers.template_renderer_factorywill need to adjust their implementations to obey the new callback argument list. This change was to kill off inappropriate use of threadlocals.
1.0a2 (2010-11-09)¶
Documentation¶
- All references to events by interface
(e.g.
pyramid.interfaces.INewRequest) have been changed to reference their concrete classes (e.g.pyramid.events.NewRequest) in documentation about making subscriptions. - All references to Pyramid-the-application were changed from mod-pyramid
to app-Pyramid. A custom role setting was added to
docs/conf.pyto allow for this. (internal)
1.0a1 (2010-11-05)¶
Features (delta from BFG 1.3)¶
Mako templating renderer supports resource specification format for template lookups and within Mako templates. Absolute filenames must be used in Pyramid to avoid this lookup process.
Add
pyramid.httpexceptionsmodule, which is a facade for thewebob.excmodule.Direct built-in support for the Mako templating language.
A new configurator method exists:
add_handler. This method adds a Pylons-style “view handler” (such a thing used to be called a “controller” in Pylons 1.0).New argument to configurator:
session_factory.New method on configurator:
set_session_factoryUsing
request.sessionnow returns a (dictionary-like) session object if a session factory has been configured.The request now has a new attribute:
tmpl_contextfor benefit of Pylons users.The decorator previously known as
pyramid.view.bfg_viewis now known most formally aspyramid.view.view_configin docs and paster templates. An import ofpyramid.view.bfg_view, however, will continue to work “forever”.New API methods in
pyramid.session:signed_serializeandsigned_deserialize.New interface:
pyramid.interfaces.IRendererInfo. An object of this type is passed to renderer factory constructors (see “Backwards Incompatibilities”).New event type:
pyramid.interfaces.IBeforeRender. An object of this type is sent as an event before a renderer is invoked (but after the application-level renderer globals factory added viapyramid.configurator.configuration.set_renderer_globals_factory, if any, has injected its own keys). Applications may now subscribe to theIBeforeRenderevent type in order to introspect the and modify the set of renderer globals before they are passed to a renderer. The event object iself has a dictionary-like interface that can be used for this purpose. For example:from repoze.events import subscriber from pyramid.interfaces import IRendererGlobalsEvent @subscriber(IRendererGlobalsEvent) def add_global(event): event['mykey'] = 'foo'
If a subscriber attempts to add a key that already exist in the renderer globals dictionary, a
KeyErroris raised. This limitation is due to the fact that subscribers cannot be ordered relative to each other. The set of keys added to the renderer globals dictionary by all subscribers and app-level globals factories must be unique.New class:
pyramid.response.Response. This is a pure facade forwebob.Response(old code need not change to use this facade, it’s existence is mostly for vanity and documentation-generation purposes).All preexisting paster templates (except
zodb) now use “imperative” configuration (starter,routesalchemy,alchemy).A new paster template named
pyramid_starter_zcmlexists, which uses declarative configuration.
Documentation (delta from BFG 1.3)¶
- Added a
pyramid.httpexceptionsAPI documentation chapter. - Added a
pyramid.sessionAPI documentation chapter. - Added a
Session Objectsnarrative documentation chapter. - Added an API chapter for the
pyramid.personalitymodule. - Added an API chapter for the
pyramid.responsemodule. - All documentation which previously referred to
webob.Responsenow usespyramid.response.Responseinstead. - The documentation has been overhauled to use imperative configuration,
moving declarative configuration (ZCML) explanations to a separate
narrative chapter
declarative.rst. - The ZODB Wiki tutorial was updated to take into account changes to the
pyramid_zodbpaster template. - The SQL Wiki tutorial was updated to take into account changes to the
pyramid_routesalchemypaster template.
Backwards Incompatibilities (with BFG 1.3)¶
There is no longer an
IDebugLoggerregistered as a named utility with the namerepoze.bfg.debug.The logger which used to have the name of
repoze.bfg.debugnow has the namepyramid.debug.The deprecated API
pyramid.testing.registerViewPermissionhas been removed.The deprecated API named
pyramid.testing.registerRoutesMapperhas been removed.The deprecated API named
pyramid.request.get_requestwas removed.The deprecated API named
pyramid.security.Unauthorizedwas removed.The deprecated API named
pyramid.view.view_execution_permittedwas removed.The deprecated API named
pyramid.view.NotFoundwas removed.The
bfgshellpaster command is now namedpshell.The Venusian “category” for all built-in Venusian decorators (e.g.
subscriberandview_config/bfg_view) is nowpyramidinstead ofbfg.pyramid.renderers.rendered_responsefunction removed; userender_pyramid.renderers.render_to_responseinstead.Renderer factories now accept a renderer info object rather than an absolute resource specification or an absolute path. The object has the following attributes:
name(therenderer=value),package(the ‘current package’ when the renderer configuration statement was found),type: the renderer type,registry: the current registry, andsettings: the deployment settings dictionary.Third-party
repoze.bfgrenderer implementations that must be ported to Pyramid will need to account for this.This change was made primarily to support more flexible Mako template rendering.
The presence of the key
repoze.bfg.messagein the WSGI environment when an exception occurs is now deprecated. Instead, code which relies on this environ value should use theexceptionattribute of the request (e.g.request.exception[0]) to retrieve the message.The values
bfg_localizerandbfg_locale_namekept on the request during internationalization for caching purposes were never APIs. These however have changed tolocalizerandlocale_name, respectively.The default
cookie_namevalue of theauthtktauthenticationpolicyZCML now defaults toauth_tkt(it used to default torepoze.bfg.auth_tkt).The default
cookie_namevalue of thepyramid.authentication.AuthTktAuthenticationPolicyconstructor now defaults toauth_tkt(it used to default torepoze.bfg.auth_tkt).The
request_typeargument to theviewZCML directive, thepyramid.configuration.Configurator.add_viewmethod, or thepyramid.view.view_configdecorator (neebfg_view) is no longer permitted to be one of the stringsGET,HEAD,PUT,POSTorDELETE, and now must always be an interface. Accepting the method-strings asrequest_typewas a backwards compatibility strategy servicing repoze.bfg 1.0 applications. Use therequest_methodparameter instead to specify that a view a string request-method predicate.
repoze.bfg Change History (previous name for Pyramid)¶
1.3b1 (2010-10-25)¶
Features¶
- The
pastertemplate namedbfg_routesalchemyhas been updated to use SQLAlchemy declarative syntax. Thanks to Ergo^.
Bug Fixes¶
- When a renderer factory could not be found, a misleading error message was raised if the renderer name was not a string.
Documentation¶
- The “”bfgwiki2” (SQLAlchemy + url dispatch) tutorial has been
updated slightly. In particular, the source packages no longer
attempt to use a private index, and the recommended Python version
is now 2.6. It was also updated to take into account the changes to
the
bfg_routesalchemytemplate used to set up an environment. - The “bfgwiki” (ZODB + traversal) tutorial has been updated slightly. In particular, the source packages no longer attempt to use a private index, and the recommended Python version is now 2.6.
1.3a15 (2010-09-30)¶
Features¶
- The
repoze.bfg.traversal.traversal_pathAPI now eagerly attempts to encode a Unicodepathinto ASCII before attempting to split it and decode its segments. This is for convenience, effectively to allow a (stored-as-Unicode-in-a-database, or retrieved-as-Unicode-from-a-request-parameter) Unicode path to be passed tofind_model, which eventually internally uses thetraversal_pathfunction under the hood. In version 1.2 and prior, if thepathwas Unicode, that Unicode was split on slashes and each resulting segment value was Unicode. An inappropriate call to thedecode()method of a resulting Unicode path segment could cause aUnicodeDecodeErrorto occur even if the Unicode representation of the path contained no ‘high order’ characters (it effectively did a “double decode”). By converting the Unicode path argument to ASCII before we attempt to decode and split, genuine errors will occur in a more obvious place while also allowing us to handle (for convenience) the case that it’s a Unicode representation formed entirely from ASCII-compatible characters.
1.3a14 (2010-09-14)¶
Bug Fixes¶
- If an exception view was registered through the legacy
set_notfound_vieworset_forbidden_viewAPIs, the context sent to the view was incorrect (could beNoneinappropriately).
Features¶
- Compatibility with WebOb 1.0.
Requirements¶
- Now requires WebOb >= 1.0.
Backwards Incompatibilities¶
- Due to changes introduced WebOb 1.0, the
repoze.bfg.request.make_request_asciievent subscriber no longer works, so it has been removed. This subscriber was meant to be used in a deployment so that code written before BFG 0.7.0 could run unchanged. At this point, such code will need to be rewritten to expect Unicode fromrequest.GET,request.POSTandrequest.paramsor it will need to be changed to userequest.str_POST,request.str_GETand/orrequest.str_paramsinstead of the non-strversions of same, as the non-strversions of the same APIs always now perform decoding to Unicode.
Errata¶
- A prior changelog entry asserted that the
INewResponseevent was not sent to listeners if the response was not “valid” (if a view or renderer returned a response object that did not have a status/headers/app_iter). This is not true in this release, nor was it true in 1.3a13.
1.3a13 (2010-09-14)¶
Bug Fixes¶
- The
traverseroute predicate could not successfully generate a traversal path.
Features¶
- In support of making it easier to configure applications which are
“secure by default”, a default permission feature was added. If
supplied, the default permission is used as the permission string to
all view registrations which don’t otherwise name a permission.
These APIs are in support of that:
- A new constructor argument was added to the Configurator:
default_permission. - A new method was added to the Configurator:
set_default_permission. - A new ZCML directive was added:
default_permission.
- A new constructor argument was added to the Configurator:
- Add a new request API:
request.add_finished_callback. Finished callbacks are called by the router unconditionally near the very end of request processing. See the “Using Finished Callbacks” section of the “Hooks” narrative chapter of the documentation for more information. - A
request.matched_routeattribute is now added to the request when a route has matched. Its value is the “route” object that matched (see theIRouteinterface withinrepoze.bfg.interfacesAPI documentation for the API of a route object). - The
exceptionattribute of the request is now set slightly earlier and in a slightly different set of scenarios, for benefit of “finished callbacks” and “response callbacks”. In previous versions, theexceptionattribute of the request was not set at all if an exception view was not found. In this version, therequest.exceptionattribute is set immediately when an exception is caught by the router, even if an exception view could not be found. - The
add_routemethod of a Configurator now accepts apregeneratorargument. The pregenerator for the resulting route is called byroute_urlin order to adjust the set of arguments passed to it by the user for special purposes, such as Pylons ‘subdomain’ support. It will influence the URL returned byroute_url. See therepoze.bfg.interfaces.IRoutePregeneratorinterface for more information.
Backwards Incompatibilities¶
- The router no longer sets the value
wsgiorg.routing_argsinto the environ when a route matches. The value used to be something like((), matchdict). This functionality was only ever obliquely referred to in change logs; it was never documented as an API. - The
exceptionattribute of the request now defaults toNone. In prior versions, therequest.exceptionattribute did not exist if an exception was not raised by user code during request processing; it only began existence once an exception view was found.
Deprecations¶
- The
repoze.bfg.interfaces.IWSGIApplicationCreatedEventevent interface was renamed torepoze.bfg.interfaces.IApplicationCreated. Likewise, therepoze.bfg.events.WSGIApplicationCreatedEventclass was renamed torepoze.bfg.events.ApplicationCreated. The older aliases will continue to work indefinitely. - The
repoze.bfg.interfaces.IAfterTraversalevent interface was renamed torepoze.bfg.interfaces.IContextFound. Likewise, therepoze.bfg.events.AfterTraversalclass was renamed torepoze.bfg.events.ContextFound. The older aliases will continue to work indefinitely. - References to the WSGI environment values
bfg.routes.matchdictandbfg.routes.routewere removed from documentation. These will stick around internally for several more releases, but it isrequest.matchdictandrequest.matched_routeare now the “official” way to obtain the matchdict and the route object which resulted in the match.
Documentation¶
- Added documentation for the
default_permissionZCML directive. - Added documentation for the
default_permissionconstructor value and theset_default_permissionmethod in the Configurator API documentation. - Added a new section to the “security” chapter named “Setting a Default Permission”.
- Document
renderer_globals_factoryandrequest_factoryarguments to Configurator constructor. - Added two sections to the “Hooks” chapter of the documentation: “Using Response Callbacks” and “Using Finished Callbacks”.
- Added documentation of the
request.exceptionattribute to therepoze.bfg.request.RequestAPI documentation. - Added glossary entries for “response callback” and “finished callback”.
- The “Request Processing” narrative chapter has been updated to note finished and response callback steps.
- New interface in interfaces API documentation:
IRoutePregenerator. - Added a “The Matched Route” section to the URL Dispatch narrative
docs chapter, detailing the
matched_routeattribute.
1.3a12 (2010-09-08)¶
Bug Fixes¶
- Fix a bug in
repoze.bfg.url.static_urlURL generation: if two resource specifications were used to create two separate static views, but they shared a common prefix, it was possible thatstatic_urlwould generate an incorrect URL. - Fix another bug in
repoze.bfg.static_urlURL generation: too many slashes in generated URL. - Prevent a race condition which could result in a
RuntimeErrorwhen rendering a Chameleon template that has not already been rendered once. This would usually occur directly after a restart, when more than one person or thread is trying to execute the same view at the same time: https://bugs.launchpad.net/karl3/+bug/621364
Features¶
- The argument to
repoze.bfg.configuration.Configurator.add_routewhich was previously calledpathis now calledpatternfor better explicability. For backwards compatibility purposes, passing a keyword argument namedpathtoadd_routewill still work indefinitely. - The
pathattribute to the ZCMLroutedirective is now namedpatternfor better explicability. The olderpathattribute will continue to work indefinitely.
Documentation¶
- All narrative, API, and tutorial docs which referred to a route
pattern as a
pathhave now been updated to refer to them as apattern. - The
repoze.bfg.interfacesAPI documentation page is now rendered viarepoze.sphinx.autointerface. - The URL Dispatch narrative chapter now refers to the
interfaceschapter to explain the API of anIRouteobject.
Paster Templates¶
- The routesalchemy template has been updated to use
patternin its route declarations rather thanpath.
Dependencies¶
tests_requirenow includesrepoze.sphinx.autointerfaceas a dependency.
Internal¶
- Add an API to the
Configuratornamedget_routes_mapper. This returns an object implementing theIRoutesMapperinterface. - The
repoze.bfg.urldispatch.RoutesMapperobject now has aget_routemethod which returns a single Route object orNone. - A new interface
repoze.bfg.interfaces.IRoutewas added. Therepoze.bfg.urldispatch.Routeobject implements this interface. - The canonical attribute for accessing the routing pattern from a
route object is now
patternrather thanpath. - Use
hash()rather thanid()when computing the “phash” of a custom route/view predicate in order to allow the custom predicate some control over which predicates are “equal”. - Use
response.headerlist.appendinstead ofresponse.headers.addinrepoze.bfg.request.add_global_response_headersin case the response is not a WebOb response. - The
repoze.bfg.urldispatch.Routeconstructor (not an API) now accepts a different ordering of arguments. Previously it was(pattern, name, factory=None, predicates=()). It is now(name, pattern, factory=None, predicates=()). This is in support of consistency withconfigurator.add_route. - The
repoze.bfg.urldispatch.RoutesMapper.connectmethod (not an API) now accepts a different ordering of arguments. Previously it was(pattern, name, factory=None, predicates=()). It is now(name, pattern, factory=None, predicates=()). This is in support of consistency withconfigurator.add_route.
1.3a11 (2010-09-05)¶
Bug Fixes¶
- Process the response callbacks and the NewResponse event earlier, to enable mutations to the response to take effect.
1.3a10 (2010-09-05)¶
Features¶
A new
repoze.bfg.request.Request.add_response_callbackAPI has been added. This method is documented in the newrepoze.bfg.requestAPI chapter. It can be used to influence response values before a concrete response object has been created.The
repoze.bfg.interfaces.INewResponseinterface now includes arequestattribute; as a result, a handler for INewResponse now has access to the request which caused the response.Each of the follow methods of the Configurator now allow the below-named arguments to be passed as “dotted name strings” (e.g. “foo.bar.baz”) rather than as actual implementation objects that must be imported:
- setup_registry
root_factory, authentication_policy, authorization_policy, debug_logger, locale_negotiator, request_factory, renderer_globals_factory
- add_subscriber
subscriber, iface
- derive_view
view
- add_view
view,
for_, context, request_type, containment- add_route()
view, view_for, factory,
for_, view_context- scan
package
- add_renderer
factory
- set_forbidden_view
view
- set_notfound_view
view
- set_request_factory
factory
- set_renderer_globals_factory()
factory
- set_locale_negotiator
negotiator
- testing_add_subscriber
event_iface
Bug Fixes¶
- The route pattern registered internally for a a local “static view”
(either via the
staticZCML directive or via theadd_static_viewmethod of the configurator) was incorrect. It was regsistered for e.g.static*traverse, while it should have been registered forstatic/*traverse. Symptom: two static views could not reliably be added to a system when they both shared the same path prefix (e.g./staticand/static2).
Backwards Incompatibilities¶
- The INewResponse event is now not sent to listeners if the response
returned by view code (or a renderer) is not a “real” response
(e.g. if it does not have
.status,.headerlistand.app_iterattribtues).
Documentation¶
- Add an API chapter for the
repoze.bfg.requestmodule, which includes documentation for therepoze.bfg.request.Requestclass (the “request object”). - Modify the “Request and Response” narrative chapter to reference the
new
repoze.bfg.requestAPI chapter. Some content was moved from this chapter into the API documentation itself. - Various changes to denote that Python dotted names are now allowed as input to Configurator methods.
Internal¶
- The (internal) feature which made it possible to attach a
global_response_headersattribute to the request (which was assumed to contain a sequence of header key/value pairs which would later be added to the response by the router), has been removed. The functionality ofrepoze.bfg.request.Request.add_response_callbacktakes its place. - The
repoze.bfg.events.NewResponseclass’s construct has changed: it now must be created with(request, response)rather than simply(response).
1.3a9 (2010-08-22)¶
Features¶
- The Configurator now accepts a dotted name string to a package as
a
packageconstructor argument. Thepackageargument was previously required to be a package object (not a dotted name string). - The
repoze.bfg.configuration.Configurator.with_packagemethod was added. This method returns a new Configurator using the same application registry as the configurator object it is called upon. The new configurator is created afresh with itspackageconstructor argument set to the value passed towith_package. This feature will make it easier for future BFG versions to allow dotted names as arguments in places where currently only object references are allowed (the work to allow dotted names isntead of object references everywhere has not yet been done, however). - The new
repoze.bfg.configuration.Configurator.maybe_dottedmethod resolves a Python dotted name string supplied as itsdottedargument to a global Python object. If the value cannot be resolved, arepoze.bfg.configuration.ConfigurationErroris raised. If the value supplied asdottedis not a string, the value is returned unconditionally without any resolution attempted. - The new
repoze.bfg.configuration.Configurator.absolute_resource_specmethod resolves a potentially relative “resource specification” string into an absolute version. If the value supplied asrelative_specis not a string, the value is returned unconditionally without any resolution attempted.
Backwards Incompatibilities¶
- The functions in
repoze.bfg.renderersnamedrenderandrender_to_responseintroduced in 1.3a6 previously took a set of**valuesarguments for the values to be passed to the renderer. This was wrong, as renderers don’t need to accept only dictionaries (they can accept any type of object). Now, the value sent to the renderer must be supplied as a positional argument namedvalue. Therequestargument is still a keyword argument, however. - The functions in
repoze.bfg.renderersnamedrenderandrender_to_responsenow accept an additonal keyword argument namedpackage. - The
get_rendererAPI inrepoze.bfg.renderersnow accepts apackageargument.
Documentation¶
- The ZCML
includedirective docs were incorrect: they specifiedfilenamerather than (the correct)fileas an allowable attribute.
Internal¶
- The
repoze.bfg.resource.resolve_resource_specfunction can now accept a package object as itspnameargument instead of just a package name. - The
_renderer_factory_from_nameand_renderer_from_namemethods of the Configurator were removed. These were never APIs. - The
_render,_render_to_responseand_make_responsefunctions withrepoze.bfg.render(added in 1.3a6) have been removed. - A new helper class
repoze.bfg.renderers.RendererHelperwas added. - The _map_view function of
repoze.bfg.configurationnow takes only a renderer_name argument instead of both arendererandrenderer``_name argument. It also takes a ``packageargument now. - Use
imp.get_suffixesindirection inrepoze.bfg.path.package_nameinstead of hardcoded.py.pycand.pyoto use for comparison when attemtping to decide if a directory is a package. - Make tests runnable again under Jython (although they do not all pass currently).
- The reify decorator now maintains the docstring of the function it wraps.
1.3a8 (2010-08-08)¶
Features¶
New public interface:
repoze.bfg.exceptions.IExceptionResponse. This interface is provided by all internal exception classes (such asrepoze.bfg.exceptions.NotFoundandrepoze.bfg.exceptions.Forbidden), instances of which are both exception objects and can behave as WSGI response objects. This interface is made public so that exception classes which are also valid WSGI response factories can be configured to implement them or exception instances which are also or response instances can be configured to provide them.New API class:
repoze.bfg.view.AppendSlashNotFoundViewFactory.There can only be one Not Found view in any
repoze.bfgapplication. Even if you userepoze.bfg.view.append_slash_notfound_viewas the Not Found view,repoze.bfgstill must generate a404 Not Foundresponse when it cannot redirect to a slash-appended URL; this not found response will be visible to site users.If you don’t care what this 404 response looks like, and you only need redirections to slash-appended route URLs, you may use the
repoze.bfg.view.append_slash_notfound_viewobject as the Not Found view. However, if you wish to use a custom notfound view callable when a URL cannot be redirected to a slash-appended URL, you may wish to use an instance of therepoze.bfg.view.AppendSlashNotFoundViewFactoryclass as the Not Found view, supplying the notfound view callable as the first argument to its constructor. For instance:from repoze.bfg.exceptions import NotFound from repoze.bfg.view import AppendSlashNotFoundViewFactory def notfound_view(context, request): return HTTPNotFound('It aint there, stop trying!') custom_append_slash = AppendSlashNotFoundViewFactory(notfound_view) config.add_view(custom_append_slash, context=NotFound)
The
notfound_viewsupplied must adhere to the two-argument view callable calling convention of(context, request)(contextwill be the exception object).
Documentation¶
- Expanded the “Cleaning Up After a Request” section of the URL Dispatch narrative chapter.
- Expanded the “Redirecting to Slash-Appended Routes” section of the URL Dispatch narrative chapter.
Internal¶
- Previously, two default view functions were registered at
Configurator setup (one for
repoze.bfg.exceptions.NotFoundnameddefault_notfound_viewand one forrepoze.bfg.exceptions.Forbiddennameddefault_forbidden_view) to render internal exception responses. Those default view functions have been removed, replaced with a generic default view function which is registered at Configurator setup for therepoze.bfg.interfaces.IExceptionResponseinterface that simply returns the exception instance; theNotFoundandForbiddenclasses are now still exception factories but they are also response factories which generate instances that implement the newrepoze.bfg.interfaces.IExceptionResponseinterface.
1.3a7 (2010-08-01)¶
Features¶
- The
repoze.bfg.configuration.Configurator.add_routeAPI now returns the route object that was added. - A
repoze.bfg.events.subscriberdecorator was added. This decorator decorates module-scope functions, which are then treated as event listeners after a scan() is performed. See the Events narrative documentation chapter and therepoze.bfg.eventsmodule documentation for more information.
Bug Fixes¶
- When adding a view for a route which did not yet exist (“did not yet
exist” meaning, temporally, a view was added with a route name for a
route which had not yet been added via add_route), the value of the
custom_predicateargument toadd_viewwas lost. Symptom: wrong view matches when using URL dispatch and custom view predicates together. - Pattern matches for a
:segmentmarker in a URL dispatch route pattern now always match at least one character. See “Backwards Incompatibilities” below in this changelog.
Backwards Incompatibilities¶
- A bug existed in the regular expression to do URL matching. As an
example, the URL matching machinery would cause the pattern
/{foo}to match the root URL/resulting in a match dictionary of{'foo':u''}or the pattern/{fud}/edit might match the URL ``//editresulting in a match dictionary of{'fud':u''}. It was always the intent that:segmentmarkers in the pattern would need to match at least one character, and never match the empty string. This, however, means that in certain circumstances, a routing match which your application inadvertently depended upon may no longer happen.
Documentation¶
- Added description of the
repoze.bfg.events.subscriberdecorator to the Events narrative chapter. - Added
repoze.bfg.events.subscriberAPI documentation torepoze.bfg.eventsAPI docs. - Added a section named “Zope 3 Enforces ‘TTW’ Authorization Checks By Default; BFG Does Not” to the “Design Defense” chapter.
1.3a6 (2010-07-25)¶
Features¶
New argument to
repoze.bfg.configuration.Configurator.add_routeand therouteZCML directive:traverse. If you would like to cause thecontextto be something other than therootobject when this route matches, you can spell a traversal pattern as thetraverseargument. This traversal pattern will be used as the traversal path: traversal will begin at the root object implied by this route (either the global root, or the object returned by thefactoryassociated with this route).The syntax of the
traverseargument is the same as it is forpath. For example, if thepathprovided isarticles/:article/edit, and thetraverseargument provided is/:article, when a request comes in that causes the route to match in such a way that thearticlematch value is ‘1’ (when the request URI is/articles/1/edit), the traversal path will be generated as/1. This means that the root object’s__getitem__will be called with the name1during the traversal phase. If the1object exists, it will become thecontextof the request. The Traversal narrative has more information about traversal.If the traversal path contains segment marker names which are not present in the path argument, a runtime error will occur. The
traversepattern should not contain segment markers that do not exist in thepath.A similar combining of routing and traversal is available when a route is matched which contains a
*traverseremainder marker in its path. Thetraverseargument allows you to associate route patterns with an arbitrary traversal path without using a a*traverseremainder marker; instead you can use other match information.Note that the
traverseargument is ignored when attached to a route that has a*traverseremainder marker in its path.A new method of the
Configuratorexists:set_request_factory. If used, this method will set the factory used by therepoze.bfgrouter to create all request objects.The
Configuratorconstructor takes an additional argument:request_factory. If used, this argument will set the factory used by therepoze.bfgrouter to create all request objects.The
Configuratorconstructor takes an additional argument:request_factory. If used, this argument will set the factory used by therepoze.bfgrouter to create all request objects.A new method of the
Configuratorexists:set_renderer_globals_factory. If used, this method will set the factory used by therepoze.bfgrouter to create renderer globals.A new method of the
Configuratorexists:get_settings. If used, this method will return the current settings object (performs the same job as therepoze.bfg.settings.get_settingsAPI).The
Configuratorconstructor takes an additional argument:renderer_globals_factory. If used, this argument will set the factory used by therepoze.bfgrouter to create renderer globals.Add
repoze.bfg.renderers.render,repoze.bfg.renderers.render_to_responseandrepoze.bfg.renderers.get_rendererfunctions. These are imperative APIs which will use the same rendering machinery used by view configurations with arenderer=attribute/argument to produce a rendering or renderer. Because these APIs provide a central API for all rendering, they now form the preferred way to perform imperative template rendering. Using functions namedrender_*from modules such asrepoze.bfg.chameleon_zptandrepoze.bfg.chameleon_textis now discouraged (although not deprecated). The code the backing older templating-system-specific APIs now calls into the newerrepoze.bfg.renderercode.The
repoze.bfg.configuration.Configurator.testing_add_templatehas been renamed totesting_add_renderer. A backwards compatibility alias is present using the old name.
Documentation¶
- The
Hybridnarrative chapter now contains a description of thetraverseroute argument. - The
Hooksnarrative chapter now contains sections about changing the request factory and adding a renderer globals factory. - The API documentation includes a new module:
repoze.bfg.renderers. - The
Templateschapter was updated; all narrative that used templating-specific APIs within examples to perform rendering (such as therepoze.bfg.chameleon_zpt.render_template_to_responsemethod) was changed to userepoze.bfg.renderers.render_*functions.
Bug Fixes¶
- The
headerpredicate (when used as either a view predicate or a route predicate) had a problem when specified with a name/regex pair. When the header did not exist in the headers dictionary, the regex match could be fedNone, causing it to throw aTypeError: expected string or bufferexception. Now, the predicate returns False as intended.
Deprecations¶
The
repoze.bfg.renderers.rendered_responsefunction was never an official API, but may have been imported by extensions in the wild. It is officially deprecated in this release. Userepoze.bfg.renderers.render_to_responseinstead.The following APIs are documentation deprecated (meaning they are officially deprecated in documentation but do not raise a deprecation error upon their usage, and may continue to work for an indefinite period of time):
In the
repoze.bfg.chameleon_zptmodule:get_renderer,get_template,render_template,render_template_to_response. The suggested alternatives are documented within the docstrings of those methods (which are still present in the documentation).In the
repoze.bfg.chameleon_textmodule:get_renderer,get_template,render_template,render_template_to_response. The suggested alternatives are documented within the docstrings of those methods (which are still present in the documentation).In general, to perform template-related functions, one should now use the various methods in the
repoze.bfg.renderersmodule.
Backwards Incompatibilities¶
A new internal exception class (not an API) named
repoze.bfg.exceptions.PredicateMismatchnow exists. This exception is currently raised when no constituent view of a multiview can be called (due to no predicate match). Previously, in this situation, arepoze.bfg.exceptions.NotFoundwas raised. We provide backwards compatibility for code that expected aNotFoundto be raised when no predicates match by causingrepoze.bfg.exceptions.PredicateMismatchto inherit fromNotFound. This will cause any exception view registered forNotFoundto be called when a predicate mismatch occurs, as was the previous behavior.There is however, one perverse case that will expose a backwards incompatibility. If 1) you had a view that was registered as a member of a multiview 2) this view explicitly raised a
NotFoundexception in order to proceed to the next predicate check in the multiview, that code will now behave differently: rather than skipping to the next view match, a NotFound will be raised to the top-level exception handling machinery instead. For code to be depending upon the behavior of a view raisingNotFoundto proceed to the next predicate match, would be tragic, but not impossible, given thatNotFoundis a public interface.repoze.bfg.exceptions.PredicateMismatchis not a public API and cannot be depended upon by application code, so you should not change your view code to raisePredicateMismatch. Instead, move the logic which raised theNotFoundexception in the view out into a custom view predicate.If, when you run your application’s unit test suite under BFG 1.3, a
KeyErrornaming a template or aValueErrorindicating that a ‘renderer factory’ is not registered may is raised (e.g.ValueError: No factory for renderer named '.pt' when looking up karl.views:templates/snippets.pt), you may need to perform some extra setup in your test code.The best solution is to use the
repoze.bfg.configuration.Configurator.testing_add_renderer(or, alternately the deprecatedrepoze.bfg.testing.registerTemplateRendererorregisterDummyRenderer) API within the code comprising each individual unit test suite to register a “dummy” renderer for each of the templates and renderers used by code under test. For example:config = Configurator() config.testing_add_renderer('karl.views:templates/snippets.pt')
This will register a basic dummy renderer for this particular missing template. The
testing_add_rendererAPI actually returns the renderer, but if you don’t care about how the render is used, you don’t care about having a reference to it either.A more rough way to solve the issue exists. It causes the “real” template implementations to be used while the system is under test, which is suboptimal, because tests will run slower, and unit tests won’t actually be unit tests, but it is easier. Always ensure you call the
setup_registry()method of the Configurator . Eg:reg = MyRegistry() config = Configurator(registry=reg) config.setup_registry()
Calling
setup_registryonly has an effect if you’re passing in aregistryargument to the Configurator constructor.setup_registryis called by the course of normal operations anyway if you do not pass in aregistry.If your test suite isn’t using a Configurator yet, and is still using the older
repoze.bfg.testingAPIs namesetUporcleanUp, these will register the renderers on your behalf.A variant on the symptom for this theme exists: you may already be dutifully registering a dummy template or renderer for a template used by the code you’re testing using
testing_register_rendererorregisterTemplateRenderer, but (perhaps unbeknownst to you) the code under test expects to be able to use a “real” template renderer implementation to retrieve or render another template that you forgot was being rendered as a side effect of calling the code you’re testing. This happened to work because it found the real template while the system was under test previously, and now it cannot. The solution is the same.It may also help reduce confusion to use a resource specification to specify the template path in the test suite and code rather than a relative path in either. A resource specification is unambiguous, while a relative path needs to be relative to “here”, where “here” isn’t always well-defined (“here” in a test suite may or may not be the same as “here” in the code under test).
1.3a5 (2010-07-14)¶
Features¶
- New internal exception:
repoze.bfg.exceptions.URLDecodeError. This URL is a subclass of the built-in Python exception namedUnicodeDecodeError. - When decoding a URL segment to Unicode fails, the exception raised
is now
repoze.bfg.exceptions.URLDecodeErrorinstead ofUnicodeDecodeError. This makes it possible to register an exception view invoked specifically whenrepoze.bfgcannot decode a URL.
Bug Fixes¶
- Fix regression in
repoze.bfg.configuration.Configurator.add_static_view. Before 1.3a4, view names that contained a slash were supported as route prefixes. 1.3a4 broke this by trying to treat them as full URLs.
Documentation¶
- The
repoze.bfg.exceptions.URLDecodeErrorexception was added to the exceptions chapter of the API documentation.
Backwards Incompatibilities¶
- in previous releases, when a URL could not be decoded from UTF-8
during traversal, a
TypeErrorwas raised. Now the error which is raised is arepoze.bfg.exceptions.URLDecodeError.
1.3a4 (2010-07-03)¶
Features¶
Undocumented hook: make
get_appandget_rootof therepoze.bfg.paster.BFGShellCommandhookable in cases where endware may interfere with the default versions.In earlier versions, a custom route predicate associated with a url dispatch route (each of the predicate functions fed to the
custom_predicatesargument ofrepoze.bfg.configuration.Configurator.add_route) has always required a 2-positional argument signature, e.g.(context, request). Before this release, thecontextargument was alwaysNone.As of this release, the first argument passed to a predicate is now a dictionary conventionally named
infoconsisting ofroute, andmatch.matchis a dictionary: it represents the arguments matched in the URL by the route.routeis an object representing the route which was matched.This is useful when predicates need access to the route match. For example:
def any_of(segment_name, *args): def predicate(info, request): if info['match'][segment_name] in args: return True return predicate num_one_two_or_three = any_of('num, 'one', 'two', 'three') add_route('num', '/:num', custom_predicates=(num_one_two_or_three,))The
routeobject is an object that has two useful attributes:nameandpath. Thenameattribute is the route name. Thepathattribute is the route pattern. An example of using the route in a set of route predicates:def twenty_ten(info, request): if info['route'].name in ('ymd', 'ym', 'y'): return info['match']['year'] == '2010' add_route('y', '/:year', custom_predicates=(twenty_ten,)) add_route('ym', '/:year/:month', custom_predicates=(twenty_ten,)) add_route('ymd', '/:year/:month:/day', custom_predicates=(twenty_ten,))
The
repoze.bfg.url.route_urlAPI has changed. If a keyword_app_urlis present in the arguments passed toroute_url, this value will be used as the protocol/hostname/port/leading path prefix of the generated URL. For example, using an_app_urlofhttp://example.com:8080/foowould cause the URLhttp://example.com:8080/foo/fleeb/flubto be returned from this function if the expansion of the route pattern associated with theroute_nameexpanded to/fleeb/flub.It is now possible to use a URL as the
nameargument fed torepoze.bfg.configuration.Configurator.add_static_view. When the name argument is a URL, therepoze.bfg.url.static_urlAPI will generate join this URL (as a prefix) to a path including the static file name. This makes it more possible to put static media on a separate webserver for production, while keeping static media package-internal and served by the development webserver during development.
Documentation¶
- The authorization chapter of the ZODB Wiki Tutorial (docs/tutorials/bfgwiki) was changed to demonstrate authorization via a group rather than via a direct username (thanks to Alex Marandon).
- The authorization chapter of the SQLAlchemy Wiki Tutorial (docs/tutorials/bfgwiki2) was changed to demonstrate authorization via a group rather than via a direct username.
- Redirect requests for tutorial sources to http://docs.repoze.org/bfgwiki-1.3 and http://docs.repoze.org/bfgwiki2-1.3/ respectively.
- A section named
Custom Route Predicateswas added to the URL Dispatch narrative chapter. - The Static Resources chapter has been updated to mention using
static_urlto generate URLs to external webservers.
Internal¶
- Removed
repoze.bfg.static.StaticURLFactoryin favor of a new abstraction revolving around the (still-internal)repoze.bfg.static.StaticURLInfohelper class.
1.3a3 (2010-05-01)¶
Paster Templates¶
- The
bfg_alchemyandbfg_routesalchemytemplates no longer register ahandle_teardownevent listener which callsDBSession.remove. This was found by Chris Withers to be unnecessary.
Documentation¶
- The “bfgwiki2” (URL dispatch wiki) tutorial code and documentation
was changed to remove the
handle_teardownevent listener which callsDBSession.remove. - Any mention of the
handle_teardownevent listener as used by the paster templates was removed from the URL Dispatch narrative chapter. - A section entitled Detecting Available Languages was added to the i18n narrative docs chapter.
1.3a2 (2010-04-28)¶
Features¶
- A locale negotiator no longer needs to be registered explicitly. The
default locale negotiator at
repoze.bfg.i18n.default_locale_negotiatoris now used unconditionally as... um, the default locale negotiator. - The default locale negotiator has become more complex.
- First, the negotiator looks for the
_LOCALE_attribute of the request object (possibly set by a view or an event listener). - Then it looks for the
request.params['_LOCALE_']value. - Then it looks for the
request.cookies['_LOCALE_']value.
- First, the negotiator looks for the
Backwards Incompatibilities¶
- The default locale negotiator now looks for the parameter named
_LOCALE_rather than a parameter namedlocaleinrequest.params.
Behavior Changes¶
- A locale negotiator may now return
None, signifying that the default locale should be used.
Documentation¶
- Documentation concerning locale negotiation in the Internationalizationa and Localization chapter was updated.
- Expanded portion of i18n narrative chapter docs which discuss working with gettext files.
1.3a1 (2010-04-26)¶
Features¶
Added “exception views”. When you use an exception (anything that inherits from the Python
Exceptionbuiltin) as view context argument, e.g.:from repoze.bfg.view import bfg_view from repoze.bfg.exceptions import NotFound from webob.exc import HTTPNotFound @bfg_view(context=NotFound) def notfound_view(request): return HTTPNotFound()
For the above example, when the
repoze.bfg.exceptions.NotFoundexception is raised by any view or any root factory, thenotfound_viewview callable will be invoked and its response returned.Other normal view predicates can also be used in combination with an exception view registration:
from repoze.bfg.view import bfg_view from repoze.bfg.exceptions import NotFound from webob.exc import HTTPNotFound @bfg_view(context=NotFound, route_name='home') def notfound_view(request): return HTTPNotFound()
The above exception view names the
route_nameofhome, meaning that it will only be called when the route matched has a name ofhome. You can therefore have more than one exception view for any given exception in the system: the “most specific” one will be called when the set of request circumstances which match the view registration. The only predicate that cannot be not be used successfully isname. The name used to look up an exception view is always the empty string.Existing (pre-1.3) normal views registered against objects inheriting from
Exceptionwill continue to work. Exception views used for user-defined exceptions and system exceptions used as contexts will also work.The feature can be used with any view registration mechanism (
@bfg_viewdecorator, ZCML, or imperativeconfig.add_viewstyles).This feature was kindly contributed by Andrey Popp.
Use “Venusian” (http://docs.repoze.org/venusian) to perform
bfg_viewdecorator scanning rather than relying on a BFG-internal decorator scanner. (Truth be told, Venusian is really just a generalization of the BFG-internal decorator scanner).Internationalization and localization features as documented in the narrative documentation chapter entitled
Internationalization and Localization.A new deployment setting named
default_locale_namewas added. If this string is present as a Paster.inifile option, it will be considered the default locale name. The default locale name is used during locale-related operations such as language translation.It is now possible to turn on Chameleon template “debugging mode” for all Chameleon BFG templates by setting a BFG-related Paster
.inifile setting nameddebug_templates. The exceptions raised by Chameleon templates when a rendering fails are sometimes less than helpful.debug_templatesallows you to configure your application development environment so that exceptions generated by Chameleon during template compilation and execution will contain more helpful debugging information. This mode is on by default in all new projects.Add a new method of the Configurator named
derive_viewwhich can be used to generate a BFG view callable from a user-supplied function, instance, or class. This useful for external framework and plugin authors wishing to wrap callables supplied by their users which follow the same calling conventions and response conventions as objects that can be supplied directly to BFG as a view callable. See thederive_viewmethod in therepoze.bfg.configuration.Configuratordocs.
ZCML¶
- Add a
translationdirZCML directive to support localization. - Add a
localenegotiatorZCML directive to support localization.
Deprecations¶
- The exception views feature replaces the need for the
set_notfound_viewandset_forbidden_viewmethods of theConfiguratoras well as thenotfoundandforbiddenZCML directives. Those methods and directives will continue to work for the foreseeable future, but they are deprecated in the documentation.
Dependencies¶
- A new install-time dependency on the
venusiandistribution was added. - A new install-time dependency on the
translationstringdistribution was added. - Chameleon 1.2.3 or better is now required (internationalization and per-template debug settings).
Internal¶
- View registrations and lookups are now done with three “requires” arguments instead of two to accomodate orthogonality of exception views.
- The
repoze.bfg.interfaces.IForbiddenViewandrepoze.bfg.interfaces.INotFoundViewinterfaces were removed; they weren’t APIs and they became vestigial with the addition of exception views. - Remove
repoze.bfg.compat.pkgutil_26.pyand import aliasrepoze.bfg.compat.walk_packages. These were only required by internal scanning machinery; Venusian replaced the internal scanning machinery, so these are no longer required.
Documentation¶
- Exception view documentation was added to the
Hooksnarrative chapter. - A new narrative chapter entitled
Internationalization and Localizationwas added. - The “Environment Variables and
iniFile Settings” chapter was changed: documentation about thedefault_locale_namesetting was added. - A new API chapter for the
repoze.bfg.i18nmodule was added. - Documentation for the new
translationdirandlocalenegotiatorZCML directives were added. - A section was added to the Templates chapter entitled “Nicer
Exceptions in Templates” describing the result of setting
debug_templates = true.
Paster Templates¶
- All paster templates now create a
setup.cfgwhich includes commands related to nose testing and Babel message catalog extraction/compilation. - A
default_locale_name = ensetting was added to each existing paster template. - A
debug_templates = truesetting was added to each existing paster template.
Licensing¶
- The Edgewall (BSD) license was added to the LICENSES.txt file, as
some code in the
repoze.bfg.i18nderives from Babel source.
1.2 (2010-02-10)¶
- No changes from 1.2b6.
1.2b6 (2010-02-06)¶
Backwards Incompatibilities¶
- Remove magical feature of
repoze.bfg.url.model_urlwhich prepended a fully-expanded urldispatch route URL before a the model’s path if it was noticed that the request had matched a route. This feature was ill-conceived, and didn’t work in all scenarios.
Bug Fixes¶
- More correct conversion of provided
renderervalues to resource specification values (internal).
1.2b5 (2010-02-04)¶
Bug Fixes¶
- 1.2b4 introduced a bug whereby views added via a route configuration
that named a view callable and also a
view_attrbecame broken. Symptom:MyViewClass is not callableor the__call__of a class was being called instead of the method named viaview_attr. - Fix a bug whereby a
rendererargument to the@bfg_viewdecorator that provided a package-relative template filename might not have been resolved properly. Symptom: inappropriateMissing template resourceerrors.
1.2b4 (2010-02-03)¶
Documentation¶
- Update GAE tutorial to use Chameleon instead of Jinja2 (now that it’s possible).
Bug Fixes¶
- Ensure that
secureflag for AuthTktAuthenticationPolicy constructor does what it’s documented to do (merge Daniel Holth’s fancy-cookies-2 branch).
Features¶
- Add
pathandhttp_onlyoptions to AuthTktAuthenticationPolicy constructor (merge Daniel Holth’s fancy-cookies-2 branch).
Backwards Incompatibilities¶
- Remove
view_header,view_accept,view_xhr,view_path_info,view_request_method,view_request_param, andview_containmentpredicate arguments from theConfigurator.add_routeargument list. These arguments were speculative. If you need the features exposed by these arguments, add a view associated with a route using theroute_nameargument to theadd_viewmethod instead. - Remove
view_header,view_accept,view_xhr,view_path_info,view_request_method,view_request_param, andview_containmentpredicate arguments from therouteZCML directive attribute set. These attributes were speculative. If you need the features exposed by these attributes, add a view associated with a route using theroute_nameattribute of theviewZCML directive instead.
Dependencies¶
- Remove dependency on
sourcecodegen(not depended upon by Chameleon 1.1.1+).
1.2b3 (2010-01-24)¶
Bug Fixes¶
- When “hybrid mode” (both traversal and urldispatch) is in use,
default to finding route-related views even if a non-route-related
view registration has been made with a more specific context. The
default used to be to find views with a more specific context first.
Use the new
use_global_viewsargument to the route definition to get back the older behavior.
Features¶
- Add
use_global_viewsargument toadd_routemethod of Configurator. When this argument is true, views registered for no route will be found if no more specific view related to the route is found. - Add
use_global_viewsattribute to ZCML<route>directive (see above).
Internal¶
- When registering a view, register the view adapter with the
“requires” interfaces as
(request_type, context_type)rather than(context_type, request_type). This provides for saner lookup, because the registration will always be made with a specific request interface, but registration may not be made with a specific context interface. In general, when creating multiadapters, you want to order the requires interfaces so that the the elements which are more likely to be registered using specific interfaces are ordered before those which are less likely.
1.2b2 (2010-01-21)¶
Bug Fixes¶
- When the
Configuratoris passed an instance ofzope.component.registry.Componentsas aregistryconstructor argument, fix the instance up to have the attributes we expect of an instance ofrepoze.bfg.registry.Registrywhensetup_registryis called. This makes it possible to use the global Zope component registry as a BFG application registry. - When WebOb 0.9.7.1 was used, a deprecation warning was issued for
the class attribute named
charsetwithinrepoze.bfg.request.Request. BFG now requires WebOb >= 0.9.7, and code was added so that this deprecation warning has disappeared. - Fix a view lookup ordering bug whereby a view with a larger number of predicates registered first (literally first, not “earlier”) for a triad would lose during view lookup to one registered with fewer.
- Make sure views with exactly N custom predicates are always called before views with exactly N non-custom predicates given all else is equal in the view configuration.
Documentation¶
- Change renderings of ZCML directive documentation.
- Add a narrative documentation chapter: “Using the Zope Component Architecture in repoze.bfg”.
Dependencies¶
- Require WebOb >= 0.9.7
1.2b1 (2010-01-18)¶
Bug Fixes¶
- In
bfg_routesalchemy,bfg_alchemypaster templates and thebfgwiki2tutorial, clean up the SQLAlchemy connection by registering arepoze.tm.after_endcallback instead of relying on a__del__method of aCleanupclass added to the WSGI environment. The__del__strategy was fragile and caused problems in the wild. Thanks to Daniel Holth for testing.
Features¶
- Read logging configuration from PasteDeploy config file
loggerssection (and related) whenpaster bfgshellis invoked.
Documentation¶
- Major rework in preparation for book publication.
1.2a11 (2010-01-05)¶
Bug Fixes¶
- Make
paster bfgshellandpaster create -t bfg_xxxwork on Jython (fix minor incompatibility with treatment of__doc__at the class level). - Updated dependency on
WebObto require a version which supports features now used in tests.
Features¶
- Jython compatibility (at least when repoze.bfg.jinja2 is used as the templating engine; Chameleon does not work under Jython).
- Show the derived abspath of template resource specifications in the traceback when a renderer template cannot be found.
- Show the original traceback when a Chameleon template cannot be rendered due to a platform incompatibility.
1.2a10 (2010-01-04)¶
Features¶
- The
Configurator.add_viewmethod now accepts an argument namedcontext. This is an alias for the older argument namedfor_; it is preferred overfor_, butfor_will continue to be supported “forever”. - The
viewZCML directive now accepts an attribute namedcontext. This is an alias for the older attribute namedfor; it is preferred overfor, butforwill continue to be supported “forever”. - The
Configurator.add_routemethod now accepts an argument namedview_context. This is an alias for the older argument namedview_for; it is preferred overview_for, butview_forwill continue to be supported “forever”. - The
routeZCML directive now accepts an attribute namedview_context. This is an alias for the older attribute namedview_for; it is preferred overview_for, butview_forwill continue to be supported “forever”.
Documentation and Paster Templates¶
- LaTeX rendering tweaks.
- All uses of the
Configurator.add_viewmethod that used itsfor_argument now use thecontextargument instead. - All uses of the
Configurator.add_routemethod that used itsview_forargument now use theview_contextargument instead. - All uses of the
viewZCML directive that used itsforattribute now use thecontextattribute instead. - All uses of the
routeZCML directive that used itsview_forattribute now use theview_contextattribute instead. - Add a (minimal) tutorial dealing with use of
repoze.catalogin arepoze.bfgapplication.
Documentation Licensing¶
- Loosen the documentation licensing to allow derivative works: it is
now offered under the Creative Commons
Attribution-Noncommercial-Share Alike 3.0 United States License. This is
only a documentation licensing change; the
repoze.bfgsoftware continues to be offered under the Repoze Public License at http://repoze.org/license.html (BSD-like).
1.2a9 (2009-12-27)¶
Documentation Licensing¶
- The documentation (the result of
make <html|latex|htmlhelp>within thedocsdirectory) in this release is now offered under the Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License as described by http://creativecommons.org/licenses/by-nc-nd/3.0/us/ . This is only a licensing change for the documentation; therepoze.bfgsoftware continues to be offered under the Repoze Public License at http://repoze.org/license.html (BSD-like).
Documentation¶
- Added manual index entries to generated index.
- Document the previously existing (but non-API)
repoze.bfg.configuration.Configurator.setup_registrymethod as an official API of aConfigurator. - Fix syntax errors in various documentation code blocks.
- Created new top-level documentation section: “ZCML Directives”. This section contains detailed ZCML directive information, some of which was removed from various narrative chapters.
- The LaTeX rendering of the documentation has been improved.
- Added a “Fore-Matter” section with author, copyright, and licensing information.
1.2a8 (2009-12-24)¶
Features¶
- Add a
**kwarg to theConfigurator.add_settingsAPI. - Add
hook_zcaandunhook_zcamethods to theConfiguratorAPI. - The
repoze.bfg.testing.setUpmethod now returns aConfiguratorinstance which can be used to do further configuration during unit tests.
Bug Fixes¶
- The
jsonrenderer failed to set the response content type toapplication/json. It now does, by settingrequest.response_content_typeunless this attribute is already set. - The
stringrenderer failed to set the response content type totext/plain. It now does, by settingrequest.response_content_typeunless this attribute is already set.
Documentation¶
- General documentation improvements by using better Sphinx roles such as “class”, “func”, “meth”, and so on. This means that there are many more hyperlinks pointing to API documentation for API definitions in all narrative, tutorial, and API documentation elements.
- Added a description of imperative configuration in various places which only described ZCML configuration.
- A syntactical refreshing of various tutorials.
- Added the
repoze.bfg.authentication,repoze.bfg.authorization, andrepoze.bfg.interfacesmodules to API documentation.
Deprecations¶
- The
repoze.bfg.testing.registerRoutesMapperAPI (added in an early 1.2 alpha) was deprecated. Its import now generates a deprecation warning.
1.2a7 (2009-12-20)¶
Features¶
- Add four new testing-related APIs to the
repoze.bfg.configuration.Configuratorclass:testing_securitypolicy,testing_models,testing_add_subscriber, andtesting_add_template. These were added in order to provide more direct access to the functionality of therepoze.bfg.testingAPIs namedregisterDummySecurityPolicy,registerModels,registerEventListener, andregisterTemplateRendererwhen a configurator is used. ThetestingAPIs named are nominally deprecated (although they will likely remain around “forever”, as they are in heavy use in the wild). - Add a new API to the
repoze.bfg.configuration.Configuratorclass:add_settings. This API can be used to add “settings” (information returned within via therepoze.bfg.settings.get_settingsAPI) after the configurator has been initially set up. This is most useful for testing purposes. - Add a
custom_predicatesargument to theConfiguratoradd_viewmethod, thebfg_viewdecorator and the attribute list of the ZCMLviewdirective. Ifcustom_predicatesis specified, it must be a sequence of predicate callables (a predicate callable accepts two arguments:contextandrequestand returnsTrueorFalse). The associated view callable will only be invoked if all custom predicates returnTrue. Use one or more custom predicates when no existing predefined predicate is useful. Predefined and custom predicates can be mixed freely. - Add a
custom_predicatesargument to theConfiguratoradd_routeand the attribute list of the ZCMLroutedirective. Ifcustom_predicatesis specified, it must be a sequence of predicate callables (a predicate callable accepts two arguments:contextandrequestand returnsTrueorFalse). The associated route will match will only be invoked if all custom predicates returnTrue, else route matching continues. Note that the valuecontextwill always beNonewhen passed to a custom route predicate. Use one or more custom predicates when no existing predefined predicate is useful. Predefined and custom predicates can be mixed freely.
Internal¶
- Remove the
repoze.bfg.testing.registerTraverserfunction. This function was never an API.
Documenation¶
- Doc-deprecated most helper functions in the
repoze.bfg.testingmodule. These helper functions likely won’t be removed any time soon, nor will they generate a warning any time soon, due to their heavy use in the wild, but equivalent behavior exists in methods of a Configurator.
1.2a6 (2009-12-18)¶
Features¶
The
Configuratorobject now has two new methods:beginandend. Thebeginmethod is meant to be called before any “configuration” begins (e.g. beforeadd_view, et. al are called). Theendmethod is meant to be called after all “configuration” is complete.Previously, before there was imperative configuration at all (1.1 and prior), configuration begin and end was invariably implied by the process of loading a ZCML file. When a ZCML load happened, the threadlocal data structure containing the request and registry was modified before the load, and torn down after the load, making sure that all framework code that needed
get_current_registryfor the duration of the ZCML load was satisfied.Some API methods called during imperative configuration, (such as
Configurator.add_viewwhen a renderer is involved) end up for historical reasons callingget_current_registry. However, in 1.2a5 and below, the Configurator supplied no functionality that allowed people to make sure thatget_current_registryreturned the registry implied by the configurator being used.beginnow serves this purpose. Inversely,endpops the thread local stack, undoing the actions ofbegin.We make this boundary explicit to reduce the potential for confusion when the configurator is used in different circumstances (e.g. in unit tests and app code vs. just in initial app setup).
Existing code written for 1.2a1-1.2a5 which does not call
beginorendcontinues to work in the same manner it did before. It is however suggested that this code be changed to callbeginandendto reduce the potential for confusion in the future.All
pastertemplates which generate an application skeleton now make use of the newbeginandendmethods of the Configurator they use in their respective copies ofrun.pyandtests.py.
Documentation¶
- All documentation that makes use of a
Configuratorobject to do application setup and test setup now makes use of the newbeginandendmethods of the configurator.
Bug Fixes¶
- When a
repoze.bfg.exceptions.NotFoundorrepoze.bfg.exceptions.Forbiddenclass (as opposed to instance) was raised as an exception within a root factory (or route root factory), the exception would not be caught properly by therepoze.bfg.Router and it would propagate to up the call stack, as opposed to rendering the not found view or the forbidden view as would have been expected. - When Chameleon page or text templates used as renderers were added
imperatively (via
Configurator.add_viewor some derivative), they too-eagerly attempted to look up thereload_templatessetting viaget_settings, meaning they were always registered in non-auto-reload-mode (the default). Each now waits until its respectivetemplateattribute is accessed to look up the value. - When a route with the same name as a previously registered route was added, the old route was not removed from the mapper’s routelist. Symptom: the old registered route would be used (and possibly matched) during route lookup when it should not have had a chance to ever be used.
1.2a5 (2009-12-10)¶
Features¶
- When the
repoze.bfg.exceptions.NotFoundorrepoze.bfg.exceptions.Forbiddenerror is raised from within a custom root factory or thefactoryof a route, the appropriate response is now sent to the requesting user agent (the result of the notfound view or the forbidden view, respectively). When these errors are raised from within a root factory, thecontextpassed to the notfound or forbidden view will beNone. Also, the request will not be decorated withview_name,subpath,context, etc. as would normally be the case if traversal had been allowed to take place.
Internals¶
- The exception class representing the error raised by various methods
of a
Configuratoris now importable asrepoze.bfg.exceptions.ConfigurationError.
Documentation¶
- General documentation freshening which takes imperative configuration into account in more places and uses glossary references more liberally.
- Remove explanation of changing the request type in a new request event subscriber, as other predicates are now usually an easier way to get this done.
- Added “Thread Locals” narrative chapter to documentation, and added
a API chapter documenting the
repoze.bfg.threadlocalsmodule. - Added a “Special Exceptions” section to the “Views” narrative
documentation chapter explaining the effect of raising
repoze.bfg.exceptions.NotFoundandrepoze.bfg.exceptions.Forbiddenfrom within view code.
Dependencies¶
- A new dependency on the
twillpackage was added to thesetup.pytests_requireargument (Twill will only be downloaded whenrepoze.bfgsetup.py testorsetup.py nosetestsis invoked).
1.2a4 (2009-12-07)¶
Features¶
repoze.bfg.testing.DummyModelnow accepts a new constructor keyword argument:__provides__. If this constructor argument is provided, it should be an interface or a tuple of interfaces. The resulting model will then provide these interfaces (they will be attached to the constructed model viazope.interface.alsoProvides).
Bug Fixes¶
- Operation on GAE was broken, presumably because the
repoze.bfg.configurationmodule began to attempt to import therepoze.bfg.chameleon_zptandrepoze.bfg.chameleon_textmodules, and these cannot be used on non-CPython platforms. It now tolerates startup time import failures for these modules, and only raise an import error when a template from one of these packages is actually used.
1.2a3 (2009-12-02)¶
Bug Fixes¶
- The
repoze.bfg.url.route_urlfunction inappropriately passed along_queryand/or_anchorarguments to themapper.generatefunction, resulting in blowups. - When two views were registered with differering
forinterfaces or classes, and theforof first view registered was a superclass of the second, therepoze.bfgview machinery would incorrectly associate the two views with the same “multiview”. Multiviews are meant to be collections of views that have exactly the same for/request/viewname values, without taking inheritance into account. Symptom: wrong view callable found even when you had correctly specified afor_interface/class during view configuration for one or both view configurations.
Backwards Incompatibilities¶
- The
repoze.bfg.templatingmodule has been removed; it had been deprecated in 1.1 and never actually had any APIs in it.
1.2a2 (2009-11-29)¶
Bug Fixes¶
- The the long description of this package (as shown on PyPI) was not valid reStructuredText, and so was not renderable.
- Trying to use an HTTP method name string such as
GETas arequest_typepredicate argument caused a startup time failure when it was encountered in imperative configuration or in a decorator (symptom:Type Error: Required specification must be a specification). This now works again, althoughrequest_methodis now the preferred predicate argument for associating a view configuration with an HTTP request method.
Documentation¶
- Fixed “Startup” narrative documentation chapter; it was explaining “the old way” an application constructor worked.
1.2a1 (2009-11-28)¶
Features¶
An imperative configuration mode.
A
repoze.bfgapplication can now begin its life as a single Python file. Later, the application might evolve into a set of Python files in a package. Even later, it might start making use of other configuration features, such asZCML. But neither the use of a package nor the use of non-imperative configuration is required to create a simplerepoze.bfgapplication any longer.Imperative configuration makes
repoze.bfgcompetetive with “microframeworks” such as Bottle and Tornado.repoze.bfghas a good deal of functionality that most microframeworks lack, so this is hopefully a “best of both worlds” feature.The simplest possible
repoze.bfgapplication is now:from webob import Response from wsgiref import simple_server from repoze.bfg.configuration import Configurator def hello_world(request): return Response('Hello world!') if __name__ == '__main__': config = Configurator() config.add_view(hello_world) app = config.make_wsgi_app() simple_server.make_server('', 8080, app).serve_forever()
A new class now exists:
repoze.bfg.configuration.Configurator. This class forms the basis for sharing machinery between “imperatively” configured applications and traditional declaratively-configured applications.The
repoze.bfg.testing.setUpfunction now accepts three extra optional keyword arguments:registry,requestandhook_zca.If the
registryargument is notNone, the argument will be treated as the registry that is set as the “current registry” (it will be returned byrepoze.bfg.threadlocal.get_current_registry) for the duration of the test. If theregistryargument isNone(the default), a new registry is created and used for the duration of the test.The value of the
requestargument is used as the “current request” (it will be returned byrepoze.bfg.threadlocal.get_current_request) for the duration of the test; it defaults toNone.If
hook_zcaisTrue(the default), thezope.component.getSiteManagerfunction will be hooked with a function that returns the value ofregistry(or the default-created registry ifregistryisNone) instead of the registry returned byzope.component.getGlobalSiteManager, causing the Zope Component Architecture API (getSiteManager,getAdapter,getUtility, and so on) to use the testing registry instead of the global ZCA registry.The
repoze.bfg.testing.tearDownfunction now accepts anunhook_zcaargument. If this argument isTrue(the default),zope.component.getSiteManager.reset()will be called. This will cause the result of thezope.component.getSiteManagerfunction to be the global ZCA registry (the result ofzope.component.getGlobalSiteManager) once again.The
run.pymodule in variousrepoze.bfgpastertemplates now use arepoze.bfg.configuration.Configuratorclass instead of the (now-legacy)repoze.bfg.router.make_appfunction to produce a WSGI application.
Documentation¶
- The documentation now uses the “request-only” view calling
convention in most examples (as opposed to the
context, requestconvention). This is a documentation-only change; thecontext, requestconvention is also supported and documented, and will be “forever”. repoze.bfg.configurationAPI documentation has been added.- A narrative documentation chapter entitled “Creating Your First
repoze.bfgApplication” has been added. This chapter details usage of the newrepoze.bfg.configuration.Configuratorclass, and demonstrates a simplified “imperative-mode” configuration; doingrepoze.bfgapplication configuration imperatively was previously much more difficult. - A narrative documentation chapter entitled “Configuration, Decorations and Code Scanning” explaining ZCML- vs. imperative- vs. decorator-based configuration equivalence.
- The “ZCML Hooks” chapter has been renamed to “Hooks”; it documents how to override hooks now via imperative configuration and ZCML.
- The explanation about how to supply an alternate “response factory” has been removed from the “Hooks” chapter. This feature may be removed in a later release (it still works now, it’s just not documented).
- Add a section entitled “Test Set Up and Tear Down” to the unittesting chapter.
Bug Fixes¶
- The ACL authorization policy debugging output when
debug_authorizationconsole debugging output was turned on wasn’t as clear as it could have been when a view execution was denied due to an authorization failure resulting from the set of principals passed never having matched any ACE in any ACL in the lineage. Now in this case, we report<default deny>as the ACE value and either the root ACL or<No ACL found on any object in model lineage>if no ACL was found. - When two views were registered with the same
acceptargument, but were otherwise registered with the same arguments, if a request entered the application which had anAcceptheader that accepted either of the media types defined by the set of views registered with predicates that otherwise matched, a more or less “random” one view would “win”. Now, we try harder to use the view callable associated with the view configuration that has the most specificacceptargument. Thanks to Alberto Valverde for an initial patch.
Internals¶
The routes mapper is no longer a root factory wrapper. It is now consulted directly by the router.
The
repoze.bfg.registry.make_registrycallable has been removed.The
repoze.bfg.view.map_viewcallable has been removed.The
repoze.bfg.view.owrap_viewcallable has been removed.The
repoze.bfg.view.predicate_wrapcallable has been removed.The
repoze.bfg.view.secure_viewcallable has been removed.The
repoze.bfg.view.authdebug_viewcallable has been removed.The
repoze.bfg.view.renderer_from_namecallable has been removed. Userepoze.bfg.configuration.Configurator.renderer_from_nameinstead (still not an API, however).The
repoze.bfg.view.derive_viewcallable has been removed. Userepoze.bfg.configuration.Configurator.derive_viewinstead (still not an API, however).The
repoze.bfg.settings.get_optionscallable has been removed. Its job has been subsumed by therepoze.bfg.settings.Settingsclass constructor.The
repoze.bfg.view.requestonlyfunction has been moved torepoze.bfg.configuration.requestonly.The
repoze.bfg.view.rendered_responsefunction has been moved torepoze.bfg.configuration.rendered_response.The
repoze.bfg.view.decorate_viewfunction has been moved torepoze.bfg.configuration.decorate_view.The
repoze.bfg.view.MultiViewclass has been moved torepoze.bfg.configuration.MultiView.The
repoze.bfg.zcml.Uncacheableclass has been removed.The
repoze.bfg.resource.resource_specfunction has been removed.All ZCML directives which deal with attributes which are paths now use the
pathmethod of the ZCML context to resolve a relative name to an absolute one (imperative configuration requirement).The
repoze.bfg.scripting.get_rootAPI now uses a ‘real’ WebOb request rather than a FakeRequest when it sets up the request as a threadlocal.The
repoze.bfg.traversal.traverseAPI now uses a ‘real’ WebOb request rather than a FakeRequest when it calls the traverser.The
repoze.bfg.request.FakeRequestclass has been removed.Most uses of the ZCA threadlocal API (the
getSiteManager,getUtility,getAdapter,getMultiAdapterthreadlocal API) have been removed from the core. Instead, when a threadlocal is necessary, the core uses therepoze.bfg.threadlocal.get_current_registryAPI to obtain the registry.The internal ILogger utility named
repoze.bfg.debugis now just an IDebugLogger unnamed utility. A named utility with the old name is registered for b/w compat.The
repoze.bfg.interfaces.ITemplateRendererFactoryinterface was removed; it has become unused.Instead of depending on the
martianpackage to do code scanning, we now just use our own scanning routines.We now no longer have a dependency on
repoze.zcmlpackage; instead, therepoze.bfgpackage includes implementations of theadapter,subscriberandutilitydirectives.Relating to the following functions:
repoze.bfg.view.render_viewrepoze.bfg.view.render_view_to_iterablerepoze.bfg.view.render_view_to_responserepoze.bfg.view.append_slash_notfound_viewrepoze.bfg.view.default_notfound_viewrepoze.bfg.view.default_forbidden_viewrepoze.bfg.configuration.rendered_responserepoze.bfg.security.has_permissionrepoze.bfg.security.authenticated_useridrepoze.bfg.security.effective_principalsrepoze.bfg.security.view_execution_permittedrepoze.bfg.security.rememberrepoze.bfg.security.forgetrepoze.bfg.url.route_urlrepoze.bfg.url.model_urlrepoze.bfg.url.static_urlrepoze.bfg.traversal.virtual_rootEach of these functions now expects to be called with a request object that has a
registryattribute which represents the currentrepoze.bfgregistry. They fall back to obtaining the registry from the threadlocal API.
Backwards Incompatibilites¶
Unit tests which use
zope.testing.cleanup.cleanUpfor the purpose of isolating tests from one another may now begin to fail due to lack of isolation between tests.Here’s why: In repoze.bfg 1.1 and prior, the registry returned by
repoze.bfg.threadlocal.get_current_registrywhen no other registry had been pushed on to the threadlocal stack was thezope.component.globalregistry.baseglobal registry (aka the result ofzope.component.getGlobalSiteManager()). In repoze.bfg 1.2+, however, the registry returned in this situation is the new module-scoperepoze.bfg.registry.global_registryobject. Thezope.testing.cleanup.cleanUpfunction clears thezope.component.globalregistry.baseglobal registry unconditionally. However, it does not know about therepoze.bfg.registry.global_registryobject, so it does not clear it.If you use the
zope.testing.cleanup.cleanUpfunction in thesetUpof test cases in your unit test suite instead of using the (more correct as of 1.1)repoze.bfg.testing.setUp, you will need to replace all calls tozope.testing.cleanup.cleanUpwith a call torepoze.bfg.testing.setUp.If replacing all calls to
zope.testing.cleanup.cleanUpwith a call torepoze.bfg.testing.setUpis infeasible, you can put this bit of code somewhere that is executed exactly once (not for each test in a test suite; in the `` __init__.py`` of your package or your package’stestssubpackage would be a reasonable place):import zope.testing.cleanup from repoze.bfg.testing import setUp zope.testing.cleanup.addCleanUp(setUp)
When there is no “current registry” in the
repoze.bfg.threadlocal.managerthreadlocal data structure (this is the case when there is no “current request” or we’re not in the midst of ar.b.testing.setUp-bounded unit test), the.getmethod of the manager returns a data structure containing a global registry. In previous releases, this function returned the global Zope “base” registry: the result ofzope.component.getGlobalSiteManager, which is an instance of thezope.component.registry.Componentclass. In this release, however, the global registry returns a globally importable instance of therepoze.bfg.registry.Registryclass. This registry instance can always be imported asrepoze.bfg.registry.global_registry.Effectively, this means that when you call
repoze.bfg.threadlocal.get_current_registrywhen no request orsetUpbounded unit test is in effect, you will always get back the global registry that lives inrepoze.bfg.registry.global_registry. It also means thatrepoze.bfgAPIs that callget_current_registrywill use this registry.This change was made because
repoze.bfgnow expects the registry it uses to have a slightly different API than a bare instance ofzope.component.registry.Components.View registration no longer registers a
repoze.bfg.interfaces.IViewPermissionadapter (it is no longer checked by the framework; since 1.1, views have been responsible for providing their own security).The
repoze.bfg.router.make_appcallable no longer accepts theauthentication_policynor theauthorization_policyarguments. This feature was deprecated in version 1.0 and has been removed.Obscure: the machinery which configured views with a
request_typeand aroute_namewould ignore the request interface implied byroute_nameregistering a view only for the interface implied byrequest_type. In the unlikely event that you were trying to use these two features together, the symptom would have been that views that named arequest_typebut which were also associated with routes were not found when the route matched. Now if a view is configured with both arequest_typeand aroute_name, an error is raised.The
routeZCML directive now no longer accepts therequest_typeorview_request_typeattributes. These attributes didn’t actually work in any useful way (see entry above this one).Because the
repoze.bfgpackage now includes implementations of theadapter,subscriberandutilityZCML directives, it is now an error to have<include package="repoze.zcml" file="meta.zcml"/>in the ZCML of arepoze.bfgapplication. A ZCML conflict error will be raised if your ZCML does so. This shouldn’t be an issue for “normal” installations; it has always been the responsibility of therepoze.bfg.includesZCML to include this file in the past; it now just doesn’t.The
repoze.bfg.testing.zcml_configureAPI was removed. Use theConfigurator.load_zcmlAPI instead.
Deprecations¶
The
repoze.bfg.router.make_appfunction is now nominally deprecated. Its import and usage does not throw a warning, nor will it probably ever disappear. However, using arepoze.bfg.configuration.Configuratorclass is now the preferred way to generate a WSGI application.Note that
make_appcallszope.component.getSiteManager.sethook( repoze.bfg.threadlocal.get_current_registry)on the caller’s behalf, hooking ZCA global API lookups, for backwards compatibility purposes. If you disusemake_app, your calling code will need to perform this call itself, at least if your application uses the ZCA global API (getSiteManager,getAdapter, etc).
Dependencies¶
- A dependency on the
martianpackage has been removed (its functionality is replaced internally). - A dependency on the
repoze.zcmlpackage has been removed (its functionality is replaced internally).
1.1.1 (2009-11-21)¶
Bug Fixes¶
- “Hybrid mode” applications (applications which explicitly used
traversal after url dispatch via
<route>paths containing the*traverseelement) were broken in 1.1-final and all 1.1 alpha and beta releases. Views registered without aroute_nameroute shadowed views registered with aroute_nameinappropriately.
1.1 (2009-11-15)¶
Internals¶
- Remove dead IRouteRequirement interface from
repoze.bfg.zcmlmodule.
Documentation¶
- Improve the “Extending an Existing Application” narrative chapter.
- Add more sections to the “Defending Design” chapter.
1.1b4 (2009-11-12)¶
Bug Fixes¶
- Use
alsoProvidesin the urldispatch module to attach an interface to the request rather thandirectlyProvidesto avoid disturbing interfaces set in a NewRequest event handler.
Documentation¶
- Move 1.0.1 and previous changelog to HISTORY.txt.
- Add examples to
repoze.bfg.url.model_urldocstring. - Add “Defending BFG Design” chapter to frontpage docs.
Templates¶
- Remove
ez_setup.pyand its import from all paster templates, samples, and tutorials fordistributecompatibility. The documentation already explains how to install virtualenv (which will include somesetuptoolspackage), so these files, imports and usages were superfluous.
Deprecations¶
- The
optionskw arg to therepoze.bfg.router.make_appfunction is deprecated. In its place is the keyword argumentsettings. Theoptionskeyword continues to work, and a deprecation warning is not emitted when it is detected. However, the paster templates, code samples, and documentation now make reference tosettingsrather thanoptions. This change/deprecation was mainly made for purposes of clarity and symmetry with theget_settings()API and dicussions of “settings” in various places in the docs: we want to use the same name to refer to the same thing everywhere.
1.1b3 (2009-11-06)¶
Features¶
repoze.bfg.testing.registerRoutesMappertesting facility added. This testing function registers a routes “mapper” object in the registry, for tests which require its presence. This function is documented in therepoze.bfg.testingAPI documentation.
Bug Fixes¶
Compound statements that used an assignment entered into in an interactive IPython session invoked via
paster bfgshellno longer fail to mutate the shell namespace correctly. For example, this set of statements used to fail:In [2]: def bar(x): return x ...: In [3]: list(bar(x) for x in 'abc') Out[3]: NameError: 'bar'
In this release, the
barfunction is found and the correct output is now sent to the console. Thanks to Daniel Holth for the patch.The
bfgshellcommand did not function properly; it was still expecting to be able to call the root factory with a bareenvironrather than a request object.
Backwards Incompatibilities¶
- The
repoze.bfg.scripting.get_rootfunction now expects arequestobject as its second argument rather than anenviron.
1.1b2 (2009-11-02)¶
Bug Fixes¶
- Prevent PyPI installation failure due to
easy_installtrying way too hard to guess the best version of Paste. Wheneasy_installpulls from PyPI it reads links off various pages to determine “more up to date” versions. It incorrectly picks up a link for an ancient version of a package named “Paste-Deploy-0.1” (note the dash) when trying to find the “Paste” distribution and somehow believes it’s the latest version of “Paste”. It also somehow “helpfully” decides to check out a version of this package from SVN. We pin the Paste dependency version to a version greater than 1.7 to work around thiseasy_installbug.
Documentation¶
- Fix “Hybrid” narrative chapter: stop claiming that
<view>statements that mention a route_name need to come afer (in XML order) the<route>statement which creates the route. This hasn’t been true since 1.1a1. - “What’s New in
repoze.bfg1.1” document added to narrative documentation.
Features¶
Add a new event type:
repoze.bfg.events.AfterTraversal. Events of this type will be sent after traversal is completed, but before any view code is invoked. Likerepoze.bfg.events.NewRequest, This event will have a single attribute:requestrepresenting the current request. Unlike the request attribute ofrepoze.bfg.events.NewRequesthowever, during an AfterTraversal event, the request object will possess attributes set by the traverser, most notablycontext, which will be the context used when a view is found and invoked. The interfacerepoze.bfg.events.IAfterTraversalcan be used to subscribe to the event. For example:<subscriber for="repoze.bfg.interfaces.IAfterTraversal" handler="my.app.handle_after_traverse"/>Like any framework event, a subscriber function should expect one parameter:
event.
Dependencies¶
- Rather than depending on
chameleon.coreandchameleon.zptdistributions individually, depend on Malthe’s repackagedChameleondistribution (which includes bothchameleon.coreandchameleon.zpt).
1.1b1 (2009-11-01)¶
Bug Fixes¶
- The routes root factory called route factories and the default route
factory with an environ rather than a request. One of the symptoms
of this bug: applications generated using the
bfg_zodbpaster template in 1.1a9 did not work properly. - Reinstate
rendereralias forview_rendererin the<route>ZCML directive (in-the-wild 1.1a bw compat). bfg_routesalchemypaster template: change<route>declarations: renamerendererattribute toview_renderer.- Header values returned by the
authtktauthenticationpolicyrememberandforgetmethods would be of typeunicode. This violated the WSGI spec, causing aTypeErrorto be raised when these headers were used undermod_wsgi. - If a BFG app that had a route matching the root URL was mounted
under a path in modwsgi, ala
WSGIScriptAlias /myapp /Users/chrism/projects/modwsgi/env/bfg.wsgi, the home route (a route with the path of'/'or'') would not match when the path/myappwas visited (only when the path/myapp/was visited). This is now fixed: if the urldispatch root factory notes that the PATH_INFO is empty, it converts it to a single slash before trying to do matching.
Documentation¶
- In
<route>declarations in tutorial ZCML, renamerendererattribute toview_renderer(fwd compat). - Fix various tutorials broken by 1.1a9
<route>directive changes.
Internal¶
- Deal with a potential circref in the traversal module.
1.1a9 (2009-10-31)¶
Bug Fixes¶
- An incorrect ZCML conflict would be encountered when the
request_parampredicate attribute was used on the ZCMLviewdirective if any two otherwise same-predicated views had the combination of a predicate value with an=sign and one without (e.g.avs.a=123).
Features¶
- In previous versions of BFG, the “root factory” (the
get_rootcallable passed tomake_appor a function pointed to by thefactoryattribute of a route) was called with a “bare” WSGI environment. In this version, and going forward, it will be called with arequestobject. The request object passed to the factory implements dictionary-like methods in such a way that existing root factory code which expects to be passed an environ will continue to work. - The
__call__of a plugin “traverser” implementation (registered as an adapter forITraverserorITraverserFactory) will now receive a request as the single argument to its__call__method. In previous versions it was passed a WSGIenvironobject. The request object passed to the factory implements dictionary-like methods in such a way that existing traverser code which expects to be passed an environ will continue to work. - The ZCML
routedirective’s attributesxhr,request_method,path_info,request_param,headerandacceptare now route predicates rather than view predicates. If one or more of these predicates is specified in the route configuration, all of the predicates must return true for the route to match a request. If one or more of the route predicates associated with a route returnsFalsewhen checked during a request, the route match fails, and the next match in the routelist is tried. This differs from the previous behavior, where no route predicates existed and all predicates were considered view predicates, because in that scenario, the next route was not tried.
Documentation¶
- Various changes were made to narrative and API documentation supporting the change from passing a request rather than an environ to root factories and traversers.
Internal¶
- The request implements dictionary-like methods that mutate and query
the WSGI environ. This is only for the purpose of backwards
compatibility with root factories which expect an
environrather than a request. - The
repoze.bfg.request.create_route_request_factoryfunction, which returned a request factory was removed in favor of arepoze.bfg.request.route_request_interfacefunction, which returns an interface. - The
repoze.bfg.request.Requestclass, which is a subclass ofwebob.Requestnow defines its own__setattr__,__getattr__and__delattr__methods, which override the default WebOb behavior. The default WebOb behavior stores attributes of the request inself.environ['webob.adhoc_attrs'], and retrieves them from that dictionary during a__getattr__. This behavior was undesirable for speed and “expectation” reasons. Now attributes of therequestare stored inrequest.__dict__(as you otherwise might expect from an object that did not override these methods). - The router no longer calls
repoze.bfg.traversal._traverseand does its work “inline” (speed). - Reverse the order in which the router calls the request factory and the root factory. The request factory is now called first; the resulting request is passed to the root factory.
- The
repoze.bfg.request.request_factoryfunction has been removed. Its functionality is no longer required. - The “routes root factory” that wraps the default root factory when
there are routes mentioned in the configuration now attaches an
interface to the request via
zope.interface.directlyProvides. This replaces logic in the (now-gone)repoze.bfg.request.request_factoryfunction. - The
routeandviewZCML directives now register an interface as a named utility (retrieved fromrepoze.bfg.request.route_request_interface) rather than a request factory (the previous return value of the now-missingrepoze.bfg.request.create_route_request_factory. - The
repoze.bfg.functionalmodule was renamed torepoze.bfg.compat.
Backwards Incompatibilities¶
- Explicitly revert the feature introduced in 1.1a8: where the name
rootis available as an attribute of the request before a NewRequest event is emitted. This makes some potential future features impossible, or at least awkward (such as grouping traversal and view lookup into a single adapter lookup). - The
containment,attrandrendererattributes of therouteZCML directive were removed.
1.1a8 (2009-10-27)¶
Features¶
- Add
path_infoview configuration predicate. paster bfgshellnow supports IPython if it’s available for import. Thanks to Daniel Holth for the initial patch.- Add
repoze.bfg.testing.registerSettingsAPI, which is documented in the “repoze.bfg.testing” API chapter. This allows for registration of “settings” values obtained viarepoze.bfg.settings.get_settings()for use in unit tests. - The name
rootis available as an attribute of the request slightly earlier now (before a NewRequest event is emitted).rootis the result of the application “root factory”. - Added
max_ageparameter toauthtktauthenticationpolicyZCML directive. If this value is set, it must be an integer representing the number of seconds which the auth tkt cookie will survive. Mainly, its existence allows the auth_tkt cookie to survive across browser sessions.
Bug Fixes¶
- Fix bug encountered during “scan” (when
<scan ..>directive is used in ZCML) introduced in 1.1a7. Symptom:AttributeError: object has no attribute __provides__raised at startup time. - The
reissue_timeargument to theauthtktauthenticationpolicyZCML directive now actually works. When it is set to an integer value, an authticket set-cookie header is appended to the response whenever a request requires authentication and ‘now’ minus the authticket’s timestamp is greater thanreissue_timeseconds.
Documentation¶
- Add a chapter titled “Request and Response” to the narrative documentation, content cribbed from the WebOb documentation.
- Call out predicate attributes of ZCML directive within “Views” chapter.
- Fix route_url documentation (
_queryargument documented asqueryand_anchorargument documented asanchor).
Backwards Incompatibilities¶
- The
authtktauthentication policyremembermethod now no longer honorstokenoruserdatakeyword arguments.
Internal¶
- Change how
bfg_viewdecorator works when used as a class method decorator. In 1.1a7, the``scan``directive actually tried to grope every class in scanned package at startup time, callingdiragainst each found class, and subsequently invokinggetattragainst each thing found bydirto see if it was a method. This led to some strange symptoms (e.g.AttributeError: object has no attribute __provides__), and was generally just a bad idea. Now, instead of groping classes for methods at startup time, we just cause thebfg_viewdecorator itself to populate the method’s class’__dict__when it is used as a method decorator. This also requires a nasty _getframe thing but it’s slightly less nasty than the startup time groping behavior. This is essentially a reversion back to 1.1a6 “grokking” behavior plus some special magic for using thebfg_viewdecorator as method decorator inside thebfg_viewclass itself. - The router now checks for a
global_response_headersattribute of the request object before returning a response. If this value exists, it is presumed to be a sequence of two-tuples, representing a set of headers to append to the ‘normal’ response headers. This feature is internal, rather than exposed externally, because it’s unclear whether it will stay around in the long term. It was added to support thereissue_timefeature of the authtkt authentication policy. - The interface ITraverserFactory is now just an alias for ITraverser.
1.1a7 (2009-10-18)¶
Features¶
More than one
@bfg_viewdecorator may now be stacked on top of any number of others. Each invocation of the decorator registers a single view configuration. For instance, the following combination of decorators and a function will register two view configurations for the same view callable: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 with a single callable without requiring any ZCML.
The
@bfg_viewdecorator can now be used against a class method: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 name of the method it is attached to), so the class it’s defined within must have a suitable constructor: one that accepts
context, requestor justrequest.
Documentation¶
- Added
Changing the TraverserandChanging How :mod:`repoze.bfg.url.model_url` Generates a URLto the “Hooks” narrative chapter of the docs.
Internal¶
- Remove
ez_setup.pyand imports of it withinsetup.py. In the new world, and as per virtualenv setup instructions, people will already have either setuptools or distribute.
1.1a6 (2009-10-15)¶
Features¶
- Add
xhr,accept, andheaderview configuration predicates to ZCML view declaration, ZCML route declaration, andbfg_viewdecorator. See theViewsnarrative documentation chapter for more information about these predicates. - Add
setUpandtearDownfunctions to therepoze.bfg.testingmodule. UsingsetUpin a test setup andtearDownin a test teardown is now the recommended way to do component registry setup and teardown. Previously, it was recommended that a single function namedrepoze.bfg.testing.cleanUpbe called in both the test setup and tear down.repoze.bfg.testing.cleanUpstill exists (and will exist “forever” due to its widespread use); it is now just an alias forrepoze.bfg.testing.setUpand is nominally deprecated. - The BFG component registry is now available in view and event
subscriber code as an attribute of the request
ie.
request.registry. This fact is currently undocumented except for this note, because BFG developers never need to interact with the registry directly anywhere else. - The BFG component registry now inherits from
dict, meaning that it can optionally be used as a simple dictionary. Component registrations performed against it via e.g.registerUtility,registerAdapter, and similar API methods are kept in a completely separate namespace than its dict members, so using the its component API methods won’t effect the keys and values in the dictionary namespace. Likewise, though the component registry “happens to be” a dictionary, use of mutating dictionary methods such as__setitem__will have no influence on any component registrations made against it. In other words, the registry object you obtain via e.g.repoze.bfg.threadlocal.get_current_registryorrequest.registryhappens to be both a component registry and a dictionary, but using its component-registry API won’t impact data added to it via its dictionary API and vice versa. This is a forward compatibility move based on the goals of “marco”. - Expose and document
repoze.bfg.testing.zcml_configureAPI. This function populates a component registry from a ZCML file for testing purposes. It is documented in the “Unit and Integration Testing” chapter.
Documentation¶
- Virtual hosting narrative docs chapter updated with info about
mod_wsgi. - Point all index URLs at the literal 1.1 index (this alpha cycle may go on a while).
- Various tutorial test modules updated to use
repoze.bfg.testing.setUpandrepoze.bfg.testing.tearDownmethods in order to encourage this as best practice going forward. - Added “Creating Integration Tests” section to unit testing narrative documentation chapter. As a result, the name of the unittesting chapter is now “Unit and Integration Testing”.
Backwards Incompatibilities¶
- Importing
getSiteManagerandget_registryfromrepoze.bfg.registryis no longer supported. These imports were deprecated in repoze.bfg 1.0. Import ofgetSiteManagershould be done asfrom zope.component import getSiteManager. Import ofget_registryshould be done asfrom repoze.bfg.threadlocal import get_current_registry. This was done to prevent a circular import dependency. - Code bases which alternately invoke both
zope.testing.cleanup.cleanUpandrepoze.bfg.testing.cleanUp(treating them equivalently, using them interchangeably) in the setUp/tearDown of unit tests will begin to experience test failures due to lack of test isolation. The “right” mechanism isrepoze.bfg.testing.cleanUp(or the combination ofrepoze.bfg.testing.setUpandrepoze.bfg.testing.tearDown). but a good number of legacy codebases will usezope.testing.cleanup.cleanUpinstead. We supportzope.testing.cleanup.cleanUpbut not in combination withrepoze.bfg.testing.cleanUpin the same codebase. You should use one or the other test cleanup function in a single codebase, but not both.
Internal¶
- Created new
repoze.bfg.configurationmodule which assumes responsibilities previously held by therepoze.bfg.registryandrepoze.bfg.routermodules (avoid a circular import dependency). - The result of the
zope.component.getSiteManagerfunction in unit tests set up withrepoze.bfg.testing.cleanUporrepoze.bfg.testing.setUpwill be an instance ofrepoze.bfg.registry.Registryinstead of the globalzope.component.globalregistry.baseregistry. This also means that the threadlocal ZCA API functions such asgetAdapterandgetUtilityas well as internal BFG machinery (such asmodel_urlandroute_url) will consult this registry within unit tests. This is a forward compatibility move based on the goals of “marco”. - Removed
repoze.bfg.testing.addCleanUpfunction and associated module-scope globals. This was never an API.
1.1a5 (2009-10-10)¶
Documentation¶
- Change “Traversal + ZODB” and “URL Dispatch + SQLAlchemy” Wiki tutorials to make use of the new-to-1.1 “renderer” feature (return dictionaries from all views).
- Add tests to the “URL Dispatch + SQLAlchemy” tutorial after the “view” step.
- Added a diagram of model graph traversal to the “Traversal” narrative chapter of the documentation.
- An
exceptionsAPI chapter was added, documenting the newrepoze.bfg.exceptionsmodule. - Describe “request-only” view calling conventions inside the urldispatch narrative chapter, where it’s most helpful.
- Add a diagram which explains the operation of the BFG router to the “Router” narrative chapter.
Features¶
- Add a new
repoze.bfg.testingAPI:registerRoute, for registering routes to satisfy calls to e.g.repoze.bfg.url.route_urlin unit tests. - The
notfoundandforbiddenZCML directives now accept the following addtional attributes:attr,renderer, andwrapper. These have the same meaning as they do in the context of a ZCMLviewdirective. - For behavior like Django’s
APPEND_SLASH=True, use therepoze.bfg.view.append_slash_notfound_viewview as the Not Found view in your application. When this view is the Not Found view (indicating that no view was found), and any routes have been defined in the configuration of your application, if the value ofPATH_INFOdoes not already end in a slash, and if the value ofPATH_INFOplus a slash matches any route’s path, do an HTTP redirect to the slash-appended PATH_INFO. Note that this will losePOSTdata information (turning it into a GET), so you shouldn’t rely on this to redirect POST requests. - Speed up
repoze.bfg.location.lineageslightly. - Speed up
repoze.bfg.encode.urlencode(nee’repoze.bfg.url.urlencode) slightly. - Speed up
repoze.bfg.traversal.model_path. - Speed up
repoze.bfg.traversal.model_path_tupleslightly. - Speed up
repoze.bfg.traversal.traverseslightly. - Speed up
repoze.bfg.url.model_urlslightly. - Speed up
repoze.bfg.url.route_urlslightly. - Sped up
repoze.bfg.traversal.ModelGraphTraverser:__call__slightly. - Minor speedup of
repoze.bfg.router.Router.__call__. - New
repoze.bfg.exceptionsmodule was created to house exceptions that were previously sprinkled through various modules.
Internal¶
- Move
repoze.bfg.traversal._url_quoteintorepoze.bfg.encodeasurl_quote.
Deprecations¶
- The import of
repoze.bfg.view.NotFoundis deprecated in favor ofrepoze.bfg.exceptions.NotFound. The old location still functions, but emits a deprecation warning. - The import of
repoze.bfg.security.Unauthorizedis deprecated in favor ofrepoze.bfg.exceptions.Forbidden. The old location still functions but emits a deprecation warning. The rename fromUnauthorizedtoForbiddenbrings parity to the the name of the exception and the system view it invokes when raised.
Backwards Incompatibilities¶
We previously had a Unicode-aware wrapper for the
urllib.urlencodefunction namedrepoze.bfg.url.urlencodewhich delegated to the stdlib function, but which marshalled all unicode values to utf-8 strings before calling the stdlib version. A newer replacement now lives inrepoze.bfg.encodeThe replacement does not delegate to the stdlib.The replacement diverges from the stdlib implementation and the previous
repoze.bfg.urlurl implementation inasmuch as itsdoseqargument is now a decoy: it always behaves in thedoseq=Trueway (which is the only sane behavior) for speed purposes.The old import location (
repoze.bfg.url.urlencode) still functions and has not been deprecated.In 0.8a7, the return value expected from an object implementing
ITraverserFactorywas changed from a sequence of values to a dictionary containing the keyscontext,view_name,subpath,traversed,virtual_root,virtual_root_path, androot. Until now, old-style traversers which returned a sequence have continued to work but have generated a deprecation warning. In this release, traversers which return a sequence instead of a dictionary will no longer work.
1.1a4 (2009-09-23)¶
Bug Fixes¶
- On 64-bit Linux systems, views that were members of a multiview
(orderings of views with predicates) were not evaluated in the
proper order. Symptom: in a configuration that had two views with
the same name but one with a
request_method=POSTpredicate and one without, the one without the predicate would be called unconditionally (even if the request was a POST request). Thanks much to Sebastien Douche for providing the buildbots that pointed this out.
Documentation¶
- Added a tutorial which explains how to use
repoze.session(ZODB-based sessions) in a ZODB-based repoze.bfg app. - Added a tutorial which explains how to add ZEO to a ZODB-based
repoze.bfgapplication. - Added a tutorial which explains how to run a
repoze.bfgapplication under mod_wsgi. See “Running a repoze.bfg Application under mod_wsgi” in the tutorials section of the documentation.
Features¶
- Add a
repoze.bfg.url.static_urlAPI which is capable of 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. - Add a
stringrenderer. This renderer converts a non-Response return value of any view callble into a string. It is documented in the “Views” narrative chapter. - Give the
routeZCML directive theview_attrandview_rendererparameters (bring up to speed with 1.1a3 features). These can also be spelled asattrandrenderer.
Backwards Incompatibilities¶
- An object implementing the
IRendererinterface (andITemplateRenderer`, which is a subclass of ``IRenderer) must now accept an extrasystemargument in its__call__method implementation. Values computed by the system (as opposed to by the view) are passed by the system in thesystemparameter, which will always be a dictionary. Keys in the dictionary include:view(the view object that returned the value),renderer_name(the template name or simple name of the renderer),context(the context object passed to the view), andrequest(the request object passed to the view). Previously only ITemplateRenderers received system arguments as elements inside the mainvaluedictionary.
Internal¶
- The way
bfg_viewdeclarations are scanned for has been modified. This should have no external effects. - Speed: do not register an ITraverserFactory in configure.zcml; instead rely on queryAdapter and a manual default to ModelGraphTraverser.
- Speed: do not register an IContextURL in configure.zcml; instead rely on queryAdapter and a manual default to TraversalContextURL.
- General speed microimprovements for helloworld benchmark: replace try/excepts with statements which use ‘in’ keyword.
1.1a3 (2009-09-16)¶
Documentation¶
- The “Views” narrative chapter in the documentation has been updated extensively to discuss “renderers”.
Features¶
- A
rendererattribute has been added to view configurations, replacing the previous (1.1a2) version’stemplateattribute. A “renderer” is an object which accepts the return value of a view and converts it to a string. This includes, but is not limited to, templating systems. - A new interface named
IRendererwas added. The existing interface,ITemplateRenderernow derives from this new interface. This interface is internal. - A new interface named
IRendererFactorywas added. An existing interface namedITemplateRendererFactorynow derives from this interface. This interface is internal. - The
viewattribute of theviewZCML directive is no longer required if the ZCML directive also has arendererattribute. This is useful when the renderer is a template renderer and no names need be passed to the template at render time. - A new zcml directive
rendererhas been added. It is documented in the “Views” narrative chapter of the documentation. - A ZCML
viewdirective (and the associatedbfg_viewdecorator) 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 awrapperattribute 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 (usingrepoze.bfg.render_view_to_response), passed the request and the context. The wrapper view is assumed to do something sensible withrequest.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).
Dependencies¶
- When used under Python < 2.6, BFG now has an installation time
dependency on the
simplejsonpackage.
Deprecations¶
- The
repoze.bfg.testing.registerDummyRendererAPI has been deprecated in favor ofrepoze.bfg.testing.registerTemplateRenderer. A deprecation warning is not issued at import time for the former name; it will exist “forever”; its existence has been removed from the documentation, however. - The
repoze.bfg.templating.renderer_from_cachefunction has been moved torepoze.bfg.renderer.template_renderer_factory. This was never an API, but code in the wild was spotted that used it. A deprecation warning is issued at import time for the former.
Backwards Incompatibilities¶
- The
ITemplateRendererinterface has been changed. Previously its__call__method accepted**kw. It now accepts a single positional parameter namedkw(REVISED: it accepts two positional parameters as of 1.1a4:valueandsystem). This is mostly an internal change, but it was exposed in APIs in one place: if you’ve used therepoze.bfg.testing.registerDummyRendererAPI in your tests with a custom “renderer” argument with your own renderer implementation, you will need to change that renderer implementation to acceptkwinstead of**kwin its__call__method (REVISED: make it acceptvalueandsystempositional arguments as of 1.1a4). - The
ITemplateRendererFactoryinterface has been changed. Previously its__call__method accepted anauto_reloadkeyword parameter. Now its__call__method accepts no keyword parameters. Renderers are now themselves responsible for determining details of auto-reload. This is purely an internal change. This interface was never external. - The
template_rendererZCML directive introduced in 1.1a2 has been removed. It has been replaced by therendererdirective. - The previous release (1.1a2) added a view configuration attribute
named
template. In this release, the attribute has been renamed torenderer. This signifies that the attribute is more generic: it can now be not just a template name but any renderer name (alajson). - In the previous release (1.1a2), the Chameleon text template
renderer was used if the system didn’t associate the
templateview configuration value with a filename with a “known” extension. In this release, you must use arendererattribute which is a path that ends with a.txtextension (e.g.templates/foo.txt) to use the Chameleon text renderer.
1.1a2 (2009-09-14)¶
Features¶
- A ZCML
viewdirective (and the associatedbfg_viewdecorator) 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
viewdirective (and the associatedbfg_viewdecorator) 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. See the section named “Views That Have atemplate” in the “Views” narrative documentation chapter for more information.
1.1a1 (2009-09-06)¶
Bug Fixes¶
- “tests” module removed from the bfg_alchemy paster template; these tests didn’t work.
- Bugfix: the
discriminatorfor the ZCML “route” directive was incorrect. It was possible to register two routes that collided without the system spitting out a ConfigurationConflictError at startup time.
Features¶
- Feature addition: view predicates. These are exposed as the
request_method,request_param, andcontainmentattributes of a ZCMLviewdeclaration, or the respective arguments to a@bfg_viewdecorator. View predicates can be used to register a view for a more precise set of environment parameters than was previously possible. For example, you can register two views with the samenamewith differentrequest_paramattributes. If therequest.paramsdict contains ‘foo’ (request_param=”foo”), one view might be called; if it contains ‘bar’ (request_param=”bar”), another view might be called.request_paramcan also name a key/value pair alafoo=123. This will match only when thefookey is in the request.params dict and it has the value ‘123’. This particular example makes it possible to write separate view functions for different form submissions. The other predicates,containmentandrequest_methodwork similarly.containmentis a view predicate that will match only when the context’s graph lineage has an object possessing a particular class or interface, for example.request_methodis a view predicate that will match when the HTTPREQUEST_METHODequals some string (eg. ‘POST’). - The
@bfg_viewdecorator now accepts three additional arguments:request_method,request_param, andcontainment.request_methodis used when you’d like the view to match only a request with a particular HTTPREQUEST_METHOD; a string naming theREQUEST_METHODcan also be supplied asrequest_typefor backwards compatibility.request_paramis used when you’d like a view to match only a request that contains a particularrequest.paramskey (with or without a value).containmentis used when you’d like to match a request that has a context that has some class or interface in its graph lineage. These are collectively known as “view predicates”. - The
routeZCML directive now honorsview_request_method,view_request_paramandview_containmentattributes, which pass along these values to the associated view if any is provided. Additionally, therequest_typeattribute can now be spelled asview_request_type, andpermissioncan be spelled asview_permission. Any attribute which starts withview_can now be spelled without theview_prefix, soview_forcan be spelled asfornow, etc. Both forms are documented in the urldispatch narraitve documentation chapter. - The
request_paramZCML view directive attribute (and itsbfg_viewdecorator cousin) can now specify both a key and a value. For example,request_param="foo=123"means that the foo key must have a value of123for the view to “match”. - Allow
repoze.bfg.traversal.find_interfaceAPI to use a class object as the argument to compare against themodelpassed in. This means you can now dofind_interface(model, SomeClass)and the first object which is found in the lineage which hasSomeClassas its class (or the first object found which hasSomeClassas any of its superclasses) will be returned. - Added
staticZCML directive which registers a route for a view that serves up files in a directory. See the “Views” narrative documentation chapter’s “Serving Static Resources Using a ZCML Directive” section for more information. - The
repoze.bfg.view.staticclass now accepts a string as its 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. Apackage_namekeyword argument has been left around for backwards compatibility. If it is supplied, it will be honored. - The API
repoze.bfg.testing.registerViewnow takes apermissionargument. Use this instead of usingrepoze.bfg.testing.registerViewPermission. - The ordering of route declarations vs. the ordering of view declarations that use a “route_name” in ZCML no longer matters. Previously it had been impossible to use a route_name from a route that had not yet been defined in ZCML (order-wise) within a “view” declaration.
- The repoze.bfg router now catches both
repoze.bfg.security.Unauthorizedandrepoze.bfg.view.NotFoundexceptions while rendering a view. When the router catches anUnauthorized, it returns the registered forbidden view. When the router catches aNotFound, it returns the registered notfound view.
Internal¶
- Change urldispatch internals: Route object is now constructed using a path, a name, and a factory instead of a name, a matcher, a generator, and a factory.
- Move (non-API) default_view, default_forbidden_view, and
default_notfound_view functions into the
repoze.bfg.viewmodule (moved fromrepoze.bfg.router). - Removed ViewPermissionFactory from
repoze.bfg.security. View permission checking is now done by registering and looking up an ISecuredView. - The
staticZCML directive now uses a custom root factory when constructing a route. - The interface
IRequestFactorieswas removed from the repoze.bfg.interfaces module. This interface was never an API. - The function named
named_request_factoriesand the data structure namedDEFAULT_REQUEST_FACTORIEShave been removed from therepoze.bfg.requestmodule. These were never APIs. - The
IViewPermissionFactoryinterface has been removed. This was never an API.
Documentation¶
- Request-only-convention examples in the “Views” narrative documentation were broken.
- Fixed documentation bugs related to forget and remember in security API docs.
- Fixed documentation for
repoze.bfg.view.static(in narrativeViewschapter).
Deprecations¶
- The API
repoze.bfg.testing.registerViewPermissionhas been deprecated.
Backwards Incompatibilities¶
The interfaces
IPOSTRequest,IGETRequest,IPUTRequest,IDELETERequest, andIHEADRequesthave been removed from therepoze.bfg.interfacesmodule. These were not documented as APIs post-1.0. Instead of using one of these, use arequest_methodZCML attribute orrequest_methodbfg_view decorator parameter containing an HTTP method name (one ofGET,POST,HEAD,PUT,DELETE) instead of one of these interfaces if you were using one explicitly. Passing a string in the set (GET,HEAD,PUT,POST,DELETE) as arequest_typeargument will work too. Rationale: instead of relying on interfaces attached to the request object, BFG now uses a “view predicate” to determine the request type.Views registered without the help of the ZCML
viewdirective are now responsible for performing their own authorization checking.The
registry_managerbackwards compatibility alias importable from “repoze.bfg.registry”, deprecated since repoze.bfg 0.9 has been removed. If you are tring to use the registry manager within a debug script of your own, use a combination of the “repoze.bfg.paster.get_app” and “repoze.bfg.scripting.get_root” APIs instead.The
INotFoundAppFactoryinterface has been removed; it has been deprecated since repoze.bfg 0.9. If you have something like the following in yourconfigure.zcml:<utility provides="repoze.bfg.interfaces.INotFoundAppFactory" component="helloworld.factories.notfound_app_factory"/>Replace it with something like:
<notfound view="helloworld.views.notfound_view"/>See “Changing the Not Found View” in the “Hooks” chapter of the documentation for more information.
The
IUnauthorizedAppFactoryinterface has been removed; it has been deprecated since repoze.bfg 0.9. If you have something like the following in yourconfigure.zcml:<utility provides="repoze.bfg.interfaces.IUnauthorizedAppFactory" component="helloworld.factories.unauthorized_app_factory"/>Replace it with something like:
<forbidden view="helloworld.views.forbidden_view"/>See “Changing the Forbidden View” in the “Hooks” chapter of the documentation for more information.
ISecurityPolicy-based security policies, deprecated since repoze.bfg 0.9, have been removed. If you have something like this in yourconfigure.zcml, it will no longer work:<utility provides="repoze.bfg.interfaces.ISecurityPolicy" factory="repoze.bfg.security.RemoteUserInheritingACLSecurityPolicy" />
If ZCML like the above exists in your application, you will receive an error at startup time. Instead of the above, you’ll need something like:
<remoteuserauthenticationpolicy/> <aclauthorizationpolicy/>
This is just an example. See the “Security” chapter of the repoze.bfg documentation for more information about configuring security policies.
Custom ZCML directives which register an authentication or authorization policy (ala “authtktauthenticationpolicy” or “aclauthorizationpolicy”) should register the policy “eagerly” in the ZCML directive instead of from within a ZCML action. If an authentication or authorization policy is not found in the component registry by the view machinery during deferred ZCML processing, view security will not work as expected.
1.0.1 (2009-07-22)¶
- Added support for
has_resource,resource_isdir, andresource_listdirto the resource “OverrideProvider”; this fixes a bug with a symptom that a file could not be overridden in a resource directory unless a file with the same name existed in the original directory being overridden. - Fixed documentation bug showing invalid test for values from the
matchdict: they are stored as attributes of theArticle, rather than subitems. - Fixed documentation bug showing wrong environment key for the
matchdictproduced by the matching route. - Added a workaround for a bug in Python 2.6, 2.6.1, and 2.6.2 having to do with a recursion error in the mimetypes module when trying to serve static files from Paste’s FileApp: http://bugs.python.org/issue5853. Symptom: File “/usr/lib/python2.6/mimetypes.py”, line 244, in guess_type return guess_type(url, strict) RuntimeError: maximum recursion depth exceeded. Thanks to Armin Ronacher for identifying the symptom and pointing out a fix.
- Minor edits to tutorials for accuracy based on feedback.
- Declared Paste and PasteDeploy dependencies.
1.0 (2009-07-05)¶
- Retested and added some content to GAE tutorial.
- Edited “Extending” narrative docs chapter.
- Added “Deleting the Database” section to the “Defining Models” chapter of the traversal wiki tutorial.
- Spell checking of narratives and tutorials.
1.0b2 (2009-07-03)¶
remoteuserauthenticationpolicyZCML directive didn’t work without anenviron_keydirective (didn’t match docs).- Fix
configure_zcmlfilespec check on Windows. Previously if an absolute filesystem path including a drive letter was passed asfilename(or asconfigure_zcmlin the options dict) torepoze.bfg.router.make_app, it would be treated as a package:resource_name specification. - Fix inaccuracies and import errors in bfgwiki (traversal+ZODB) and bfgwiki2 (urldispatch+SA) tutorials.
- Use bfgsite index for all tutorial setup.cfg files.
- Full documentation grammar/style/spelling audit.
1.0b1 (2009-07-02)¶
Features¶
- Allow a Paste config file (
configure_zcml) value or an environment variable (BFG_CONFIGURE_ZCML) to name a ZCML file (optionally package-relative) that will be used to bootstrap the application. Previously, the integrator could not influence which ZCML file was used to do the boostrapping (only the original application developer could do so).
Documentation¶
- Added a “Resources” chapter to the narrative documentation which explains how to override resources within one package from another package.
- Added an “Extending” chapter to the narrative documentation which explains how to extend or modify an existing BFG application using another Python package and ZCML.
1.0a9 (2009-07-01)¶
Features¶
- Make it possible to pass strings in the form
“package_name:relative/path” to APIs like
render_template,render_template_to_response, andget_template. Sometimes the package in which a caller lives is a direct namespace package, so the module which is returned is semi-useless for navigating from. In this way, the caller can control the horizontal and vertical of where things get looked up from.
1.0a8 (2009-07-01)¶
Deprecations¶
- Deprecate the
authentication_policyandauthorization_policyarguments torepoze.bfg.router.make_app. Instead, developers should use the various authentication policy ZCML directives (repozewho1authenticationpolicy,remoteuserauthenticationpolicyandauthtktauthenticationpolicy) and the aclauthorizationpolicy` authorization policy directive as described in the changes to the “Security” narrative documenation chapter and the wiki tutorials.
Features¶
- Add three new ZCML directives which configure authentication
policies:
repozewho1authenticationpolicyremoteuserauthenticationpolicyauthtktauthenticationpolicy
- Add a new ZCML directive which configures an ACL authorization
policy named
aclauthorizationpolicy.
Bug Fixes¶
- Bug fix: when a
repoze.bfg.resource.PackageOverridesclass was instantiated, and the package it was overriding already had a__loader__attribute, it would fail at startup time, even if the__loader__attribute was another PackageOverrides instance. We now replace any__loader__that is also a PackageOverrides instance. Symptom:ConfigurationExecutionError: <type 'exceptions.TypeError'>: Package <module 'karl.views' from '/Users/chrism/projects/osi/bfgenv/src/karl/karl/views/__init__.pyc'> already has a __loader__ (probably a module in a zipped egg).
1.0a7 (2009-06-30)¶
Features¶
- Add a
reload_resourcesconfiguration file setting (aka theBFG_RELOAD_RESOURCESenvironment variable). When this is set to true, the server never needs to be restarted when moving files between directory resource overrides (esp. for templates currently). - Add a
reload_allconfiguration file setting (aka theBFG_RELOAD_ALLenvironment variable) that implies bothreload_resourcesandreload_templates. - The
statichelper view class now uses aPackageURLParserin order to allow for the overriding of static resources (CSS / logo files, etc) using theresourceZCML directive. ThePackageURLParserclass was added to a (new)staticmodule in BFG; it is a subclass of theStaticURLParserclass inpaste.urlparser. - The
repoze.bfg.templating.renderer_from_cachefunction now checks for thereload_resourcessetting; if it’s true, it does not register a template renderer (it won’t use the registry as a template renderer cache).
Documentation¶
- Add
pkg_resourcesto the glossary. - Update the “Environment” docs to note the existence of
reload_resourcesandreload_all. - Updated the
bfg_alchemypaster template to include two views: the view on the root shows a list of links to records; the view on a record shows the details for that object.
Internal¶
- Use a colon instead of a tab as the separator between package name and relpath to form the “spec” when register a ITemplateRenderer.
- Register a
repoze.bfg.resource.OverrideProvideras a pkg_resources provider only for modules which are known to have overrides, instead of globally, when a <resource> directive is used (performance).
1.0a6 (2009-06-29)¶
Bug Fixes¶
- Use
caller_packagefunction instead ofcaller_modulefunction withintemplatingto avoid needing to name the caller module in resource overrides (actually match docs). - Make it possible to override templates stored directly in a module with templates in a subdirectory of the same module, stored directly within another module, or stored in a subdirectory of another module (actually match docs).
1.0a5 (2009-06-28)¶
Features¶
A new ZCML directive exists named “resource”. This ZCML directive allows you to override Chameleon templates within a package (both directories full of templates and individual template files) with other templates in the same package or within another package. This allows you to “fake out” a view’s use of a template, causing it to retrieve a different template than the one actually named by a relative path to a call like
render_template_to_response('templates/mytemplate.pt'). For example, you can override a template file by doing:<resource to_override="some.package:templates/mytemplate.pt" override_with="another.package:othertemplates/anothertemplate.pt" />
The string passed to “to_override” and “override_with” is named a “specification”. The colon separator in a specification separates the package name from a package-relative directory name. The colon and the following relative path are optional. If they are not specified, the override attempts to resolve every lookup into a package from the directory of another package. For example:
<resource to_override="some.package" override_with="another.package" />
Individual subdirectories within a package can also be overridden:
<resource to_override="some.package:templates/" override_with="another.package:othertemplates/" />
If you wish to override a directory with another directory, you must make sure to attach the slash to the end of both the
to_overridespecification and theoverride_withspecification. If you fail to attach a slash to the end of a specification that points a directory, you will get unexpected results. You cannot override a directory specification with a file specification, and vice versa (a startup error will occur if you try).You cannot override a resource with itself (a startup error will occur if you try).
Only individual package resources may be overridden. Overrides will not traverse through subpackages within an overridden package. This means that if you want to override resources for both
some.package:templates, andsome.package.views:templates, you will need to register two overrides.The package name in a specification may start with a dot, meaning that the package is relative to the package in which the ZCML file resides. For example:
<resource to_override=".subpackage:templates/" override_with="another.package:templates/" />
Overrides for the same
to_overridesspecification can be named multiple times within ZCML. Eachoverride_withpath will be consulted in the order defined within ZCML, forming an override search path.Resource overrides can actually override resources other than templates. Any software which uses the
pkg_resourcesget_resource_filename,get_resource_streamorget_resource_stringAPIs will obtain an overridden file when an override is used. However, the only built-in facility which uses thepkg_resourcesAPI within BFG is the templating stuff, so we only call out template overrides here.Use the
pkg_resourcesAPI to locate template filenames instead of dead-reckoning using theos.pathmodule.The
repoze.bfg.templatingmodule now usespkg_resourcesto locate and register template files instead of using an absolute path name.
1.0a4 (2009-06-25)¶
Features¶
- Cause
:segmentmatches in route paths to put a Unicode-decoded and URL-dequoted value in the matchdict for the value matched. Previously a non-decoded non-URL-dequoted string was placed in the matchdict as the value. - Cause
*remaindermatches in route paths to put a tuple in the matchdict dictionary in order to be able to present Unicode-decoded and URL-dequoted values for the traversal path. Previously a non-decoded non-URL-dequoted string was placed in the matchdict as the value. - Add optional
max_agekeyword value to theremembermethod ofrepoze.bfg.authentication.AuthTktAuthenticationPolicy; if this value is passed toremember, the generated cookie will have a corresponding Max-Age value.
Documentation¶
- Add information to the URL Dispatch narrative documentation about path pattern matching syntax.
Bug Fixes¶
- Make
route_urlURL-quote segment replacements during generation. Remainder segments are not quoted.
1.0a3 (2009-06-24)¶
Implementation Changes¶
repoze.bfgno longer relies on the Routes package to interpret URL paths. All known existingpathpatterns will continue to work with the reimplemented logic, which lives inrepoze.bfg.urldispatch.<route>ZCML directives which use certain attributes (uncommon ones) may not work (see “Backwards Incompatibilities” below).
Bug Fixes¶
model_urlwhen passed a request that was generated as a result of a route match would fail in a call toroute.generate.- BFG-on-GAE didn’t work due to a corner case bug in the fallback
Python implementation of
threading.local(symptom: “Initialization arguments are not supported”). Thanks to Michael Bernstein for the bug report.
Documentation¶
- Added a “corner case” explanation to the “Hybrid Apps” chapter explaining what to do when “the wrong” view is matched.
- Use
repoze.bfg.url.route_urlAPI in tutorials rather than Routesurl_forAPI.
Features¶
- Added the
repoze.bfg.url.route_urlAPI. This API allows you to generate URLs based on<route>declarations. See the URL Dispatch narrative chapter and the “repoze.bfg.url” module API documentation for more information.
Backwards Incompatibilities¶
- As a result of disusing Routes, using the Routes
url_forAPI inside a BFG application (as was suggested by previous iterations of tutorials) will no longer work. Use therepoze.bfg.url.route_urlmethod instead. - The following attributes on the
<route>ZCML directive no longer work:encoding,static,filter,condition_method,condition_subdomain,condition_function,explicit, orsubdomains. These were all Routes features. - The
<route>ZCML directive no longer supports the<requirement>subdirective. This was a Routes feature.
1.0a2 (2009-06-23)¶
Bug Fixes¶
- The
bfg_routesalchemypaster template app tests failed due to a mismatch between test and view signatures.
Features¶
- Add a
view_forattribute to therouteZCML directive. This attribute should refer to an interface or a class (ala theforattribute of theviewZCML directive).
Documentation¶
- Conditional documentation in installation section (“how to install a Python interpreter”).
Backwards Incompatibilities¶
- The
callbackargument of therepoze.bfg.authenticationauthentication policies namedRepozeWho1AuthenticationPolicy,RemoteUserAuthenticationPolicy, andAuthTktAuthenticationPolicynow must accept two positional arguments: the orginal argument accepted by each (userid or identity) plus a second argument, which will be the current request. Apologies, this is required to service finding groups when there is no “global” database connection.
1.0a1 (2009-06-22)¶
Features¶
A new ZCML directive was added named
notfound. This ZCML directive can be used to name a view that should be invoked when the request can’t otherwise be resolved to a view callable. For example:<notfound view="helloworld.views.notfound_view"/>A new ZCML directive was added named
forbidden. This ZCML directive can be used to name a view that should be invoked when a view callable for a request is found, but cannot be invoked due to an authorization failure. For example:<forbidden view="helloworld.views.forbidden_view"/>Allow views to be optionally defined as callables that accept only a request object, instead of both a context and a request (which still works, and always will). The following types work as views in this style:
functions that accept a single argument
request, e.g.:def aview(request): pass
new and old-style classes that have an
__init__method that acceptsself, request, e.g.:def View(object): __init__(self, request): passArbitrary callables that have a
__call__method that acceptsself, request, e.g.:def AView(object): def __call__(self, request): pass view = AView()
This likely should have been the calling convention all along, as the request has
contextas an attribute already, and with views called as a result of URL dispatch, having the context in the arguments is not very useful. C’est la vie.Cache the absolute path in the caller’s package globals within
repoze.bfg.pathto get rid of repeated (expensive) calls to os.path.abspath.Add
reissue_timeandtimeoutparameters torepoze.bfg.authentication.AuthTktAuthenticationPolicyconstructor. If these are passed, cookies will be reset every so often (cadged from the same change to repoze.who lately).The matchdict related to the matching of a Routes route is available on the request as the
matchdictattribute:request.matchdict. If no route matched, this attribute will be None.Make 404 responses slightly cheaper by showing
environ["PATH_INFO"]on the notfound result page rather than the fullly computed URL.Move LRU cache implementation into a separate package (
repoze.lru).The concepts of traversal and URL dispatch have been unified. It is now possible to use the same sort of factory as both a traversal “root factory” and what used to be referred to as a urldispatch “context factory”.
When the root factory argument (as a first argument) passed to
repoze.bfg.router.make_appisNone, a default root factory is used. This is in support of using routes as “root finders”; it supplants the idea that there is a defaultIRoutesContextFactory.The view` ZCML statement and the
repoze.bfg.view.bfg_viewdecorator now accept an extra argument:route_name. If aroute_nameis specified, it must match the name of a previously definedroutestatement. When it is specified, the view will only be called when that route matches during a request.It is now possible to perfom traversal after a route has matched. Use the pattern
*traversein a<route>pathattribute within ZCML, and the path remainder which it matches will be used as a traversal path.When any route defined matches, the WSGI environment will now contain a key
bfg.routes.route(the Route object which matched), and a keybfg.routes.matchdict(the result of calling route.match).
Deprecations¶
- Utility registrations against
repoze.bfg.interfaces.INotFoundViewandrepoze.bfg.interfaces.IForbiddenVieware now deprecated. Use thenotfoundandforbiddenZCML directives instead (see the “Hooks” chapter for more information). Such registrations will continue to work, but the notfound and forbidden directives do “extra work” to ensure that the callable named by the directive can be called by the router even if it’s a class or request-argument-only view.
Removals¶
- The
IRoutesContext,IRoutesContextFactory, andIContextNotFoundinterfaces were removed fromrepoze.bfg.interfaces. These were never APIs. - The
repoze.bfg.urldispatch.RoutesContextNotFound,repoze.bfg.urldispatch.RoutesModelTraverserandrepoze.bfg.urldispatch.RoutesContextURLclasses were removed. These were also never APIs.
Backwards Incompatibilities¶
- Moved the
repoze.bfg.pushmodule, which implemented thepushpagedecorator, into a separate distribution,repoze.bfg.pushpage. Applications which used this decorator should continue to work after adding that distribution to their installation requirements. - Changing the default request factory via an IRequestFactory utility registration (as used to be documented in the “Hooks” chapter’s “Changing the request factory” section) is no longer supported. The dance to manufacture a request is complicated as a result of unifying traversal and url dispatch, making it highly unlikely for anyone to be able to override it properly. For those who just want to decorate or modify a request, use a NewRequestEvent subscriber (see the Events chapter in the documentation).
- The
repoze.bfg.IRequestFactoryinterface was removed. See the bullet above for why. - Routes “context factories” (spelled as the factory argument to a route statement in ZCML) must now expect the WSGI environ as a single argument rather than a set of keyword arguments. They can obtain the match dictionary by asking for environ[‘bfg.routes.matchdict’]. This is the same set of keywords that used to be passed to urldispatch “context factories” in BFG 0.9 and below.
- Using the
@zope.component.adapterdecorator on a bfg view function no longer works. Use the@repoze.bfg.view.bfg_viewdecorator instead to mark a function (or a class) as a view. - The name under which the matching route object is found in the
environ was changed from
bfg.routetobfg.routes.route. - Finding the root is now done before manufacturing a request object (and sending a new request event) within the router (it used to be performed afterwards).
- Adding
*path_infoto a route no longer changes the PATH_INFO for a request that matches using URL dispatch. This feature was only there to service therepoze.bfg.wsgi.wsgiapp2decorator and it did it wrong; use*subpathinstead now. - The values of
subpath,traversed, andvirtual_root_pathattached to the request object are always now tuples instead of lists (performance).
Bug Fixes¶
- The
bfg_alchemyPaster template named “repoze.tm” in its pipeline rather than “repoze.tm2”, causing the startup to fail. - Move BBB logic for registering an
IAuthenticationPolicy/IForbiddenView/INotFoundView based on older
concepts from the router module’s
make_appfunction into therepoze.bfg.zcml.zcml_configurecallable, to service compatibility with scripts that use “zope.configuration.xmlconfig” (replace withrepoze.bfg.zml.zcml_configureas necessary to get BBB logic)
Documentation¶
- Add interface docs related to how to create authentication policies and authorization policies to the “Security” narrative chapter.
- Added a (fairly sad) “Combining Traversal and URL Dispatch” chapter
to the narrative documentation. This explains the usage of
*traverseand*subpathin routes URL patters. - A “router” chapter explaining the request/response lifecycle at a high level was added.
- Replaced all mentions and explanations of a routes “context factory” with equivalent explanations of a “root factory” (context factories have been disused).
- Updated Routes bfgwiki2 tutorial to reflect the fact that context factories are now no longer used.
0.9.1 (2009-06-02)¶
Features¶
- Add API named
repoze.bfg.settings.get_settingswhich retrieves a derivation of values passed as theoptionsvalue ofrepoze.bfg.router.make_app. This API should be preferred instead of using getUtility(ISettings). I added a newrepoze.bfg.settingsAPI document as well.
Bug Fixes¶
- Restored missing entry point declaration for bfg_alchemy paster template, which was accidentally removed in 0.9.
Documentation¶
- Fix a reference to
wsgiappin thewsgiapp2API documentation within therepoze.bfg.wsgimodule.
API Removals¶
- The
repoze.bfg.location.locateAPI was removed: it didn’t do enough to be very helpful and had a misleading name.
0.9 (2009-06-01)¶
Bug Fixes¶
- It was not possible to register a custom
IRoutesContextFactoryfor use as a default context factory as documented in the “Hooks” chapter.
Features¶
- The
request_typeargument of ZCMLviewdeclarations andbfg_viewdecorators can now be one of the stringsGET,POST,PUT,DELETE, orHEADinstead of a reference to the respective interface type imported fromrepoze.bfg.interfaces. - The
routeZCML directive now acceptsrequest_typeas an alias for itscondition_methodargument for symmetry with theviewdirective. - The
bfg_routesalchemypaster template now provides a unit test and actually uses the database during a view rendering.
Removals¶
- Remove
repoze.bfg.threadlocal.setManager. It was only used in unit tests. - Remove
repoze.bfg.wsgi.HTTPException,repoze.bfg.wsgi.NotFound, andrepoze.bfg.wsgi.Unauthorized. These classes were disused with the introduction of theIUnauthorizedViewandINotFoundViewmachinery.
Documentation¶
- Add description to narrative templating chapter about how to use Chameleon text templates.
- Changed Views narrative chapter to use method strings rather than interface types, and moved advanced interface type usage to Events narrative chapter.
- Added a Routes+SQLAlchemy wiki tutorial.
0.9a8 (2009-05-31)¶
Features¶
- It is now possible to register a custom
repoze.bfg.interfaces.INotFoundViewfor a given application. This feature replaces therepoze.bfg.interfaces.INotFoundAppFactoryfeature previously described in the Hooks chapter. The INotFoundView will be called when the framework detects that a view lookup done as a result of a request fails; it should accept a context object and a request object; it should return an IResponse object (a webob response, basically). See the Hooks narrative chapter of the BFG docs for more info. - The error presented when a view invoked by the router returns a non-response object now includes the view’s name for troubleshooting purposes.
Bug Fixes¶
- A “new response” event is emitted for forbidden and notfound views.
Deprecations¶
- The
repoze.bfg.interfaces.INotFoundAppFactoryinterface has been deprecated in favor of using the newrepoze.bfg.interfaces.INotFoundViewmechanism.
Renames¶
- Renamed
repoze.bfg.interfaces.IForbiddenResponseFactorytorepoze.bfg.interfaces.IForbiddenView.
0.9a7 (2009-05-30)¶
Features¶
- Remove “context” argument from
effective_principalsandauthenticated_useridfunction APIs inrepoze.bfg.security, effectively a doing reversion to 0.8 and before behavior. Both functions now again accept only therequestparameter.
0.9a6 (2009-05-29)¶
Documentation¶
- Changed “BFG Wiki” tutorial to use AuthTktAuthenticationPolicy rather than repoze.who.
Features¶
- Add an AuthTktAuthenticationPolicy. This policy retrieves credentials from an auth_tkt cookie managed by the application itself (instead of relying on an upstream data source for authentication data). See the Security API chapter of the documentation for more info.
- Allow RemoteUserAuthenticationPolicy and RepozeWho1AuthenticationPolicy to accept various constructor arguments. See the Security API chapter of the documentation for more info.
0.9a5 (2009-05-28)¶
Features¶
- Add a
get_appAPI functions to thepastermodule. This obtains a WSGI application from a config file given a config file name and a section name. See therepoze.bfg.pasterAPI docs for more information. - Add a new module named
scripting. It contains aget_rootAPI function, which, provided a Router instance, returns a traversal root object and a “closer”. See therepoze.bfg.scriptingAPI docs for more info.
0.9a4 (2009-05-27)¶
Bug Fixes¶
- Try checking for an “old style” security policy after we parse ZCML (thinko).
0.9a3 (2009-05-27)¶
Features¶
- Allow IAuthenticationPolicy and IAuthorizationPolicy to be overridden via ZCML registrations (do ZCML parsing after registering these in router.py).
Documentation¶
- Added “BFG Wiki” tutorial to documentation; it describes step-by-step how to create a traversal-based ZODB application with authentication.
Deprecations¶
- Added deprecations for imports of
ACLSecurityPolicy,InheritingACLSecurityPolicy,RemoteUserACLSecurityPolicy,RemoteUserInheritingACLSecurityPolicy,WhoACLSecurityPolicy, andWhoInheritingACLSecurityPolicyfrom therepoze.bfg.securitymodule; for the meantime (for backwards compatibility purposes) these live in therepoze.bfg.secpolsmodule. Note however, that the entire concept of a “security policy” is deprecated in BFG in favor of separate authentication and authorization policies, so any use of a security policy will generate additional deprecation warnings even if you do start usingrepoze.bfg.secpols.repoze.bfg.secpolswill disappear in a future release ofrepoze.bfg.
Deprecated Import Alias Removals¶
- Remove
repoze.bfg.templatemodule. All imports from this package have been deprecated since 0.3.8. Instead, importget_template,render_template, andrender_template_to_responsefrom therepoze.bfg.chameleon_zptmodule. - Remove backwards compatibility import alias for
repoze.bfg.traversal.split_path(deprecated since 0.6.5). This must now be imported asrepoze.bfg.traversal.traversal_path). - Remove backwards compatibility import alias for
repoze.bfg.urldispatch.RoutesContext(deprecated since 0.6.5). This must now be imported asrepoze.bfg.urldispatch.DefaultRoutesContext. - Removed backwards compatibility import aliases for
repoze.bfg.router.get_optionsandrepoze.bfg.router.Settings(deprecated since 0.6.2). These both must now be imported fromrepoze.bfg.settings. - Removed backwards compatibility import alias for
repoze.bfg.interfaces.IRootPolicy(deprecated since 0.6.2). It must be imported asrepoze.bfg.interfaces.IRootFactorynow. - Removed backwards compatibility import alias for
repoze.bfg.interfaces.ITemplate(deprecated since 0.4.4). It must be imported asrepoze.bfg.interfaces.ITemplateRenderernow. - Removed backwards compatibility import alias for
repoze.bfg.interfaces.ITemplateFactory(deprecated since 0.4.4). It must be imported asrepoze.bfg.interfaces.ITemplateRendererFactorynow. - Removed backwards compatibility import alias for
repoze.bfg.chameleon_zpt.ZPTTemplateFactory(deprecated since 0.4.4). This must be imported asrepoze.bfg.ZPTTemplateRenderernow.
0.9a2 (2009-05-27)¶
Features¶
A paster command has been added named “bfgshell”. This command can be used to get an interactive prompt with your BFG root object in the global namespace. E.g.:
bin/paster bfgshell /path/to/myapp.ini myapp
See the
Projectchapter in the BFG documentation for more information.
Deprecations¶
- The name
repoze.bfg.registry.registry_managerwas never an API, but scripts in the wild were using it to set up an environment for use under a debug shell. A backwards compatibility shim has been added for this purpose, but the feature is deprecated.
0.9a1 (2009-5-27)¶
Features¶
New API functions named
forgetandrememberare available in thesecuritymodule. Theforgetfunction returns headers which will cause the currently authenticated user to be logged out when set in a response. Therememberfunction (when passed the proper arguments) will return headers which will cause a principal to be “logged in” when set in a response. See the Security API chapter of the docs for more info.New keyword arguments to the
repoze.bfg.router.make_appcall have been added:authentication_policyandauthorization_policy. These should, respectively, be an implementation of an authentication policy (an object implementing therepoze.bfg.interfaces.IAuthenticationPolicyinterface) and an implementation of an authorization policy (an object implementingrepoze.bfg.interfaces.IAuthorizationPolicy). Concrete implementations of authentication policies exist inrepoze.bfg.authentication. Concrete implementations of authorization policies exist inrepoze.bfg.authorization.Both
authentication_policyandauthorization_policydefault toNone.If
authentication_policyisNone, butauthorization_policyis notNone, thenauthorization_policyis ignored (the ability to do authorization depends on authentication).If the
authentication_policyargument is notNone, and theauthorization_policyargument isNone, the authorization policy defaults to an authorization implementation that uses ACLs (repoze.bfg.authorization.ACLAuthorizationPolicy).We no longer encourage configuration of “security policies” using ZCML, as previously we did for
ISecurityPolicy. This is because it’s not uncommon to need to configure settings for concrete authorization or authentication policies using paste .ini parameters; the app entry point for your application is the natural place to do this.Two new abstractions have been added in the way of adapters used by the system: an
IAuthorizationPolicyand anIAuthenticationPolicy. A combination of these (as registered by thesecuritypolicyZCML directive) take the place of theISecurityPolicyabstraction in previous releases of repoze.who. The API functions inrepoze.who.security(such asauthentication_userid,effective_principals,has_permission, and so on) have been changed to try to make use of these new adapters. If you’re using an olderISecurityPolicyadapter, the system will still work, but it will print deprecation warnings when such a policy is used.The way the (internal) IViewPermission utilities registered via ZCML are invoked has changed. They are purely adapters now, returning a boolean result, rather than returning a callable. You shouldn’t have been using these anyway. ;-)
New concrete implementations of IAuthenticationPolicy have been added to the
repoze.bfg.authenticationmodule:RepozeWho1AuthenticationPolicywhich usesrepoze.whoidentity to retrieve authentication data from andRemoteUserAuthenticationPolicy, which uses theREMOTE_USERvalue in the WSGI environment to retrieve authentication data.A new concrete implementation of IAuthorizationPolicy has been added to the
repoze.bfg.authorizationmodule:ACLAuthorizationPolicywhich uses ACL inheritance to do authorization.It is now possible to register a custom
repoze.bfg.interfaces.IForbiddenResponseFactoryfor a given application. This feature replaces therepoze.bfg.interfaces.IUnauthorizedAppFactoryfeature previously described in the Hooks chapter. The IForbiddenResponseFactory will be called when the framework detects an authorization failure; it should accept a context object and a request object; it should return an IResponse object (a webob response, basically). Read the below point for more info and see the Hooks narrative chapter of the BFG docs for more info.
Backwards Incompatibilities¶
- Custom NotFound and Forbidden (nee’ Unauthorized) WSGI applications
(registered as a utility for INotFoundAppFactory and
IUnauthorizedAppFactory) could rely on an environment key named
messagedescribing the circumstance of the response. This key has been renamed torepoze.bfg.message(as per the WSGI spec, which requires environment extensions to contain dots).
Deprecations¶
- The
repoze.bfg.interfaces.IUnauthorizedAppFactoryinterface has been deprecated in favor of using the newrepoze.bfg.interfaces.IForbiddenResponseFactorymechanism. - The
view_execution_permittedAPI should now be imported from therepoze.bfg.securitymodule instead of therepoze.bfg.viewmodule. - The
authenticated_useridandeffective_principalsAPIs inrepoze.bfg.securityused to only take a single argument (request). They now accept two arguments (contextandrequest). Calling them with a single argument is still supported but issues a deprecation warning. (NOTE: this change was reverted in 0.9a7; meaning the 0.9 versions of these functions again acceptrequestonly, just like 0.8 and before). - Use of “old-style” security policies (those base on ISecurityPolicy) is now deprecated. See the “Security” chapter of the docs for info about activating an authorization policy and an authentication poicy.
0.8.1 (2009-05-21)¶
Features¶
Class objects may now be used as view callables (both via ZCML and via use of the
bfg_viewdecorator 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 namedcontext, andrequest). 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.Removed the pickling of ZCML actions (the code that wrote
configure.zcml.cachenext toconfigure.zcmlfiles 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. theviewdirective 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.
0.8 (2009-05-18)¶
Features¶
- Added a
traversefunction to therepoze.bfg.traversalmodule. 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:
ITraversercallables 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 therepoze.bfg.interfaces.ITraverserinterface for the list of keys that should be present in the dictionary.ITraverserswhich 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.
0.8a7 (2009-05-16)¶
Backwards Incompatibilities¶
The
RoutesMapperclass inrepoze.bfg.urldispatchhas been removed, as well as its documentation. It had been deprecated since 0.6.3. Code inrepoze.bfg.urldispatch.RoutesModelTraverserwhich catered to it has also been removed.The semantics of the
routeZCML directive have been simplified. Previously, it was assumed that to use a route, you wanted to map a route to an externally registered view. The newroutedirective instead has aviewattribute which is required, specifying the dotted path to a view callable. When a route directive is processed, a view is registered using the name attribute of the route directive as its name and the callable as its value. Theview_nameandprovidesattributes of theroutedirective are therefore no longer used. Effectively, if you were previously using theroutedirective, it means you must change a pair of ZCML directives that look like this:<route name="home" path="" view_name="login" factory=".models.root.Root" /> <view for=".models.root.Root" name="login" view=".views.login_view" />
To a ZCML directive that looks like this:
<route name="home" path="" view=".views.login_view" factory=".models.root.Root" />
In other words, to make old code work, remove the
viewdirectives that were only there to serve the purpose of backingroutedirectives, and move theirview=attribute into theroutedirective itself.This change also necessitated that the
nameattribute of theroutedirective is now required. If you were previously usingroutedirectives without anameattribute, you’ll need to add one (the name is arbitrary, but must be unique among allrouteandviewstatements).The
providesattribute of theroutedirective has also been removed. This directive specified a sequence of interface types that the generated context would be decorated with. Since route views are always generated now for a single interface (repoze.bfg.IRoutesContext) as opposed to being looked up arbitrarily, there is no need to decorate any context to ensure a view is found.
Documentation¶
- Added API docs for the
repoze.bfg.testingmethodsregisterAdapter,registerUtiity,registerSubscriber, andcleanUp. - Added glossary entry for “root factory”.
- Noted existence of
repoze.bfg.pagetemplatetemplate bindings in “Available Add On Template System Bindings” in Templates chapter in narrative docs. - Update “Templates” narrative chapter in docs (expand to show a sample template and correct macro example).
Features¶
- Courtesty Carlos de la Guardia, added an
alchemyPaster template. This paster template sets up a BFG project that uses SQAlchemy (with SQLite) and uses traversal to resolve URLs. (no Routes areused). This template can be used viapaster create -t bfg_alchemy. - The Routes
Routeobject used to resolve the match is now put into the environment asbfg.routewhen URL dispatch is used. - You can now change the default Routes “context factory” globally. See the “ZCML Hooks” chapter of the documentation (in the “Changing the Default Routes Context Factory” section).
0.8a6 (2009-05-11)¶
Features¶
- Added a
routesalchemyPaster template. This paster template sets up a BFG project that uses SQAlchemy (with SQLite) and uses Routes exclusively to resolve URLs (no traversal root factory is used). This template can be used viapaster create -t bfg_routesalchemy.
Documentation¶
- Added documentation to the URL Dispatch chapter about how to catch
the root URL using a ZCML
routedirective. - Added documentation to the URL Dispatch chapter about how to perform a cleanup function at the end of a request (e.g. close the SQL connection).
Bug Fixes¶
In version 0.6.3, passing a
get_rootcallback (a “root factory”) torepoze.bfg.router.make_appbecame optional if anyroutedeclaration was made in ZCML. The intent was to make it possible to disuse traversal entirely, instead relying entirely on URL dispatch (Routes) to resolve all contexts. However a compound set of bugs prevented usage of a Routes-based root view (a view which responds to “/”). One bug existed in repoze.bfg.urldispatch`, another existed in Routes itself.To resolve this issue, the urldispatch module was fixed, and a fork of the Routes trunk was put into the “dev” index named
Routes-1.11dev-chrism-home. The source for the fork exists at http://bitbucket.org/chrism/routes-home/; its contents have been merged into the Routes trunk (what will be Routes 1.11).
0.8a5 (2009-05-08)¶
Features¶
- Two new security policies were added: RemoteUserInheritingACLSecurityPolicy and WhoInheritingACLSecurityPolicy. These are security policies which take into account all ACLs defined in the lineage of a context rather than stopping at the first ACL found in a lineage. See the “Security” chapter of the API documentation for more information.
- The API and narrative documentation dealing with security was changed to introduce the new “inheriting” security policy variants.
- Added glossary entry for “lineage”.
Deprecations¶
The security policy previously named
RepozeWhoIdentityACLSecurityPolicynow has the slightly saner name ofWhoACLSecurityPolicy. A deprecation warning is emitted when this policy is imported under the “old” name; usually this is due to its use in ZCML within your application. If you’re getting this deprecation warning, change your ZCML to use the new name, e.g. change:<utility provides="repoze.bfg.interfaces.ISecurityPolicy" factory="repoze.bfg.security.RepozeWhoIdentityACLSecurityPolicy" />
To:
<utility provides="repoze.bfg.interfaces.ISecurityPolicy" factory="repoze.bfg.security.WhoACLSecurityPolicy" />
0.8a4 (2009-05-04)¶
Features¶
zope.testingis no longer a direct dependency, although our dependencies (such aszope.interface,repoze.zcml, etc) still depend on it.- Tested on Google App Engine. Added a tutorial to the documentation explaining how to deploy a BFG app to GAE.
Backwards Incompatibilities¶
- Applications which rely on
zope.testing.cleanup.cleanUpin unit tests can still use that function indefinitely. However, for maximum forward compatibility, they should importcleanUpfromrepoze.bfg.testinginstead of fromzope.testing.cleanup. The BFG paster templates and docs have been changed to use this function instead of thezope.testing.cleanupversion.
0.8a3 (2009-05-03)¶
Features¶
- Don’t require a successful import of
zope.testingat BFG application runtime. This allows us to get rid ofzope.testingon platforms like GAE which have file limits.
0.8a2 (2009-05-02)¶
Features¶
- We no longer include the
configure.zcmlof thechameleon.zptpackage within theconfigure.zcmlof the “repoze.bfg.includes” package. This has been a no-op for some time now. - The
repoze.bfg.chameleon_zptpackage no longer imports fromchameleon.zptat module scope, deferring the import until later within a method call. Thechameleon.zptpackage can’t be imported on platforms like GAE.
0.8a1 (2009-05-02)¶
Deprecation Warning and Import Alias Removals¶
- Since version 0.6.1, a deprecation warning has been emitted when the
name
model_urlis imported from therepoze.bfg.traversalmodule. This import alias (and the deprecation warning) has been removed. Any import of themodel_urlfunction will now need to be done fromrepoze.bfg.url; any import of the namemodel_urlfromrepoze.bfg.traversalwill now fail. This was done to remove a dependency on zope.deferredimport. - Since version 0.6.5, a deprecation warning has been emitted when the
name
RoutesModelTraverseris imported from therepoze.bfg.traversalmodule. This import alias (and the deprecation warning) has been removed. Any import of theRoutesModelTraverserclass will now need to be done fromrepoze.bfg.urldispatch; any import of the nameRoutesModelTraverserfromrepoze.bfg.traversalwill now fail. This was done to remove a dependency on zope.deferredimport.
Features¶
This release of
repoze.bfgis “C-free”. This means it has no hard dependencies on any software that must be compiled from C source at installation time. In particular,repoze.bfgno longer depends on thelxmlpackage.This change has introduced some backwards incompatibilities, described in the “Backwards Incompatibilities” section below.
This release was tested on Windows XP. It appears to work fine and all the tests pass.
Backwards Incompatibilities¶
Incompatibilities related to making repoze.bfg “C-free”:
- Removed the
repoze.bfg.chameleon_genshimodule, and thus support for Genshi-style chameleon templates. Genshi-style Chameleon templates depend uponlxml, which is implemented in C (as opposed to pure Python) and therepoze.bfgcore is “C-free” as of this release. You may get Genshi-style Chameleon support back by installing therepoze.bfg.chameleon_genshipackage availalable from http://svn.repoze.org/repoze.bfg.chameleon_genshi (also available in the index at http://dist.repoze.org/bfg/0.8/simple). All existing code that depended on thechameleon_genshimodule prior to this release ofrepoze.bfgshould work without change after this addon is installed. - Removed the
repoze.bfg.xsltmodule and thus support for XSL templates. Therepoze.bfg.xsltmodule depended uponlxml, which is implemented in C, and therepoze.bfgcore is “C-free” as of this release. You bay get XSL templating back by installing therepoze.bfg.xsltpackage available from http://svn.repoze.org/repoze.bfg.xslt/ (also available in the index at http://dist.repoze.org/bfg/0.8/simple). All existing code that depended upon thexsltmodule prior to this release ofrepoze.bfgshould work without modification after this addon is installed. - Removed the
repoze.bfg.interfaces.INodeTemplateRendererinterface and the an old b/w compat aliases from that interface torepoze.bfg.interfaces.INodeTemplate. This interface must now be imported from therepoze.bfg.xslt.interfacespackage after installation of therepoze.bfg.xsltaddon package described above asrepoze.bfg.interfaces.INodeTemplateRenderer. This interface was never part of any public API.
Other backwards incompatibilities:
- The
render_templatefunction inrepoze.bfg.chameleon_zptreturns Unicode instead of a string. Likewise, the individual values returned by the iterable created by therender_template_to_iterablefunction are also each Unicode. This is actually a backwards incompatibility inherited from our new use of the combination ofchameleon.core1.0b32 (the non-lxml-depending version) andchameleon.zpt1.0b16+ ; thechameleon.zptPageTemplateFile implementation used to return a string, but now returns Unicode.
0.7.1 (2009-05-01)¶
Features¶
The “paster create” templates have been modified to use links to the new “bfg.repoze.org” and “docs.repoze.org” websites.
Added better documentation for virtual hosting at a URL prefix within the virtual hosting docs chapter.
The interface for
repoze.bfg.interfaces.ITraverserand the built-in implementations that implement the interface (repoze.bfg.traversal.ModelGraphTraverser, andrepoze.bfg.urldispatch.RoutesModelTraverser) now expect the__call__method of an ITraverser to return 3 additional arguments:traversed,virtual_root, andvirtual_root_path(the old contract was that the__call__method of an ITraverser returned; three arguments, the contract new is that it returns six).traversedwill be a sequence of Unicode names that were traversed (including the virtual root path, if any) orNoneif no traversal was performed,virtual_rootwill be a model object representing the virtual root (or the physical root if traversal was not performed), andvirtual_root_pathwill be a sequence representing the virtual root path (a sequence of Unicode names) orNoneif 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, andvirtual_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 orNoneif traversal was not performed),virtual_root(the model object representing the virtual root, including the virtual root path if any), andvirtual_root_path(the seuquence of names representing the virtual root path orNoneif traversal was not performed).A new decorator named
wsgiapp2was added to therepoze.bfg.wsgimodule. This decorator performs the same function asrepoze.bfg.wsgi.wsgiappexcept it fixes up theSCRIPT_NAME, andPATH_INFOenvironment values before invoking the WSGI subapplication.The
repoze.bfg.testing.DummyRequestobject now has default attributes fortraversed,virtual_root, andvirtual_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 likehttp://foo/*path_info). When this is the case, thePATH_INFOenvironment variable is set to the value in the match dict, and theSCRIPT_NAMEis appended to with the prefix of the originalPATH_INFOnot 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 previous releases, the
repoze.bfg.url.model_url,repoze.bfg.traversal.model_pathandrepoze.bfg.traversal.model_path_tuplefunctions always ignored the__name__argument of the root object in a model graph ( effectively replacing it with a leading/in the returned value) when a path or URL was generated. The code required to perform this operation was not efficient. As of this release, the root object in a model graph must have a__name__attribute that is eitherNoneor the empty string ('') for URLs and paths to be generated properly from these APIs. If your root model object has a__name__argument that is not one of these values, you will need to change your code for URLs and paths to be generated properly. If your model graph has a root node with a string__name__that is not null, the value of__name__will be prepended to every path and URL generated.The
repoze.bfg.location.LocationProxyclass and therepoze.bfg.location.ClassAndInstanceDescrclass have both been removed in order to be able to eventually shed a dependency onzope.proxy. Neither of these classes was ever an API.In all previous releases, the
repoze.bfg.location.locatefunction worked like so: if a model did not explicitly provide therepoze.bfg.interfaces.ILocationinterface,locatereturned aLocationProxyobject representingmodelwith its__parent__attribute assigned toparentand a__name__attribute assigned to__name__. In this release, therepoze.bfg.location.locatefunction simply jams the__name__and__parent__attributes on to the supplied model unconditionally, no matter if the object implements ILocation or not, and it never returns a proxy. This was done because the LocationProxy behavior has now moved into an add-on package (repoze.bfg.traversalwrapper), in order to eventually be able to shed a dependency onzope.proxy.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,repoze.bfgprovided some implicit help during traversal. This traversal feature wrapped subobjects from the root (and thereafter) that did not implementILocationin 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 removed from the baserepoze.bfgpackage for purposes of eventually shedding a dependency onzope.proxy.In order to re-enable the wrapper behavior for older applications which cannot be changed, register the “traversalwrapper”
ModelGraphTraverseras the traversal policy, rather than the defaultModelGraphTraverser. To use this feature, you will need to install therepoze.bfg.traversalwrapperpackage (an add-on package, available at http://svn.repoze.org/repoze.bfg.traversalwrapper) Then change your application’sconfigure.zcmlto include the following stanza:- <adapter
factory=”repoze.bfg.traversalwrapper.ModelGraphTraverser” provides=”repoze.bfg.interfaces.ITraverserFactory” for=”*” />
When this ITraverserFactory is used instead of the default, 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, andzope.proxyfor forward compatibility reasons (zope.componentwill stop relying onzope.deferredimportsoon and although we use it directly, it’s only a transitive dependency, and ‘’zope.deprecation`` andzope.proxyare used directly even though they’re only transitive dependencies as well). - Using
model_urlormodel_pathagainst a broken model graph (one with models that had a non-root model with a__name__ofNone) 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.DummyTemplateRendererreturn some nondefault string representation. - Added a new
anchorkeyword argument tomodel_url. Ifanchoris present, its string representation will be used as a named anchor in the generated URL (e.g. ifanchoris passed asfooand the model URL ishttp://example.com/model/url, the generated URL will behttp://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 viarequest.params,request.GET, andrequest.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 fromrequest.params,request.GETandrequest.POST, or you’ll need to explicitly reenable the previous behavior. To reenable the previous behavior, add the following to your application’sconfigure.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)”.
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_urlbased 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_urlwill generatehttp://foo/bar//bazif 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, andrepoze.bfg.url.urlencode. - add zip_safe = false to setup.cfg.
Documentation¶
- Add a note to the
repoze.bfg.traversal.quote_path_segmentAPI docs about caching of computed values.
Implementation Changes¶
- Simplification of
repoze.bfg.traversal.TraversalContextURL.__call__(it now usesrepoze.bfg.traversal.model_pathinstead of rolling its own path-generation).
0.6.8 (2009-02-05)¶
Backwards Incompatibilities¶
The
repoze.bfg.traversal.model_pathAPI 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 expectsmodel_pathto 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-importedmodel_pathin your code with this function (this is the code of the “old”model_pathimplementation):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_modelAPI 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 byrepoze.bfg.traversal.model_path, or tuple values returned by the result ofrepoze.bfg.traversal.model_path_tupleor they should use the guidelines about passing a stringpathargument described in thefind_modelAPI documentation.
Bugfixes¶
- Each argument contained in
elementspassed torepoze.bfg.traversal.model_pathwill now have any/characters contained within quoted to%2Fin the returned string. Previously,/characters in elements were left unquoted (a bug).
Features¶
- A
repoze.bfg.traversal.model_path_tupleAPI was added. This API is an alternative tomodel_path(which returns a string);model_path_tuplereturns a model path as a tuple (much like Zope’sgetPhysicalPath). - A
repoze.bfg.traversal.quote_path_segmentAPI was added. This API will quote an individual path segment (string or unicode object). See therepoze.bfg.traversalAPI documentation for more information. - The
repoze.bfg.traversal.find_modelAPI now accepts “path tuples” (see the above note regardingmodel_path_tuple) as well as string path representations (fromrepoze.bfg.traversal.model_path) as apathargument. - 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.traversalfromrepoze.bfg.url. This is not an API.
0.6.7 (2009-01-27)¶
Features¶
- The
repoze.bfg.url.model_urlAPI now works against contexts derived from Routes URL dispatch (Routes.util.url_foris 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
repoze.bfgmodel 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_rootAPI 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.RoutesModelTraverserhas been moved torepoze.bfg.urldispatch.model_urlURL generation is now performed via an adapter lookup based on the context and the request.- ZCML which registers two adapters for the
IContextURLinterface has been added to the configure.zcml inrepoze.bfg.includes.
0.6.6 (2009-01-26)¶
Implementation Changes¶
- There is an indirection in
repoze.bfg.url.model_urlnow 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
repoze.bfggenerates 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_pathAPI to the traversal module; see the “traversal” API chapter in the docs. This was a function previously known assplit_paththat was not an API but people were using it anyway. Unlikesplit_path, it now returns a tuple instead of a list (as its values are cached).
Behavior Changes¶
- The
repoze.bfg.view.render_view_to_responseAPI 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 theis_responsefunction inrepoze.bfg.view, and raised aValueErrorif theis_responsecheck 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.RoutesRootFactorynow injects thewsgiorg.routing_argsenvironment 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.RoutesModelTraverserclass now wants to obtain theview_nameandsubpathfrom thewsgiorgs.routing_argsenvironment variable. It falls back to obtaining these from the context for backwards compatibility.
Implementation Changes¶
- Get rid of
repoze.bfg.security.ACLAuthorizer: theACLSecurityPolicynow does what it did inline. - Get rid of
repoze.bfg.interfaces.NoAuthorizationInformationexception: it was used only byACLAuthorizer. - 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_cacheddecorator now uses functools.wraps in order to make documentation of LRU-cached functions possible. - Various speed micro-tweaks.
Bug Fixes¶
repoze.bfg.testing.DummyModeldid not have agetmethod; it now does.
0.6.4 (2009-01-23)¶
Backwards Incompatibilities¶
- The
unicode_path_segmentsconfiguration variable and theBFG_UNICODE_PATH_SEGMENTSconfiguration 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_pathnow also handles decoding path segments to unicode (for speed, because its results are cached).repoze.bfg.traversal.stepwas made a method of theModelGraphTraverser.
Use “precooked” Request subclasses (e.g.
repoze.bfg.request.GETRequest) that correspond to HTTP request methods withinrouter.pywhen constructing a request object rather than usingalsoProvidesto attach the proper interface to an unsubclassedwebob.Request. This pattern is purely an optimization (e.g. preventing calls toalsoProvidesmeans 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 asrepoze.bfg.registry.Registry); it has anotifymethod, aregisterSubscriptionAdapterand aregisterHandlermethod. If no subscribers are registered viaregisterHandlerorregisterSubscriptionAdapter,notifyis a noop for speed.The Allowed and Denied classes in
repoze.bfg.securitynow are lazier about constructing the representation of a reason message for speed;repoze.bfg.view_execution_permittedtakes advantage of this.The
is_responsecheck was sped up by about half at the expense of making its code slightly uglier.
New Modules¶
repoze.bfg.lruimplements an LRU cache class and a decorator for internal use.
0.6.3 (2009-01-19)¶
Bug Fixes¶
- Readd
root_policyattribute 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
routedirective has been added to the available list of ZCML directives. Eachroutedirective inserted into your application’sconfigure.zcmlestablishes a Routes mapper connection. If anyroutedeclarations are made via ZCML within a particular application, theget_rootcallable passed in torepoze.bfg.router.make_appwill automatically be wrapped in the equivalent of a RoutesMapper. Additionally, the newroutedirective allows the specification of acontext_interfacesattribute for a route, this will be used to tag the manufactured routes context with specific interfaces when a route specifying acontext_interfacesattribute is matched. - A new interface
repoze.bfg.interfaces.IContextNotFoundwas 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_starterandbfg_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.statichelper to be passed a relativeroot_pathname; it will be considered relative to the file in which it was called. - The functionality of
repoze.bfg.conventionhas been merged into the core. Applications which make use ofrepoze.bfg.conventionwill continue to work indefinitely, but it is recommended that apps stop depending upon it. To do so, substitute imports ofrepoze.bfg.convention.bfg_viewwith imports ofrepoze.bfg.view.bfg_view, and change the stanza in ZCML from<convention package=".">to<scan package=".">. 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.cachefile from being written to disk). - Instead of invariably using
webob.Requestas the “request factory” (e.g. in theRouterclass) andwebob.Responseand the “response factory” (e.g. inrender_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.RoutesContexthas been renamed torepoze.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.wsgiappdecorator now useswebob.Request.get_responseto do its work rather than relying on homegrown WSGI code. - The
repoze.bfg.view.statichelper now useswebob.Request.get_responseto do its work rather than relying on homegrown WSGI code. - The
repoze.bfg.urldispatch.RoutesModelTraverserclass has been moved torepoze.bfg.traversal.RoutesModelTraverser. - The
repoze.bfg.registry.makeRegistryfunction was renamed torepoze.bfg.registry.populateRegistryand now accepts aregistryargument (which should be an instance ofzope.component.registry.Components).
Documentation Additions¶
- Updated narrative urldispatch chapter with changes required by
<route..>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
noseinstalled in the interpreter which you use to run tests. Using an interpreter withnoseinstalled, dopython setup.py nosetestswithin a checkout of therepoze.bfgpackage to see test coverage output. - Added a
postargument to therepoze.bfg.testing:DummyRequestconstructor. - Added
__len__and__nonzero__torepoze.bfg.testing:DummyModel. - The
repoze.bfg.registry.get_optionscallable (now renamed torepoze.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 theISettingsutility from within BFG. - Renamed the existing BFG paster template to
bfg_starter. Added another template (bfg_zodb) showing default ZODB setup usingrepoze.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.interfacesand areIGETRequest,IPOSTRequest,IPUTRequest,IDELETERequestandIHEADRequest. These interfaces can be specified as therequest_typeattribute 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 generalIRequestinterface can be used as the request_type to catch all requests (and this is indeed the default). All requests implementIRequest. 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’sBFG_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_modelAPI did not work properly when passed apathargument which was unicode and contained high-order bytes when theunicode_path_segmentsorBFG_UNICODE_PATH_SEGMENTSconfiguration variables were “true”. - A new module was added:
repoze.bfg.settings. This contains deployment-settings-related code.
Implementation Changes¶
- The
make_appcallable withinrepoze.bfg.routernow registers theroot_policyargument as a utility (unnamed, using the newrepoze.bfg.interfaces.IRootFactoryas a provides interface) rather than passing it as the first argument to therepoze.bfg.router.Routerclass. As a result, therepoze.bfg.router.Routerrouter class only accepts a single argument:registry. Therepoze.bfg.router.Routerclass retrieves the root policy via a utility lookup now. Therepoze.bfg.router.make_appAPI also now performs some important application registrations that were previously handled insiderepoze.bfg.registry.makeRegistry.
New Modules¶
- A
repoze.bfg.settingsmodule was added. It contains code related to deployment settings. Most of the code it contains was moved to it from therepoze.bfg.registrymodule.
Behavior Changes¶
- The
repoze.bfg.settings.Settingsclass (an instance of which is registered as a utility providingrepoze.bfg.interfaces.ISettingswhen any application is started) now automatically callsrepoze.bfg.settings.get_optionson the options passed to its constructor. This means that usage ofget_optionswithin an application’smake_appfunction is no longer required (the “raw”optionsdict or None may be passed). - Remove old cold which attempts to recover from trying to unpickle a
z3c.pttemplate; Chameleon has been the templating engine for a good long time now. Running repoze.bfg against a sandbox that has pickledz3c.pttemplates 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.Settingsclass. This has been moved torepoze.bfg.settings.Settings. A deprecation warning is issued when it is imported from the older location. - Moved the
repoze.bfg.registry.get_optionsfunction This has been moved torepoze.bfg.settings.get_options. A deprecation warning is issued when it is imported from the older location. - The
repoze.bfg.interfaces.IRootPolicyinterface was renamed within the interfaces package. It has been renamed toIRootFactory. 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.urlhas been added. It contains themodel_urlAPI (moved fromrepoze.bfg.traversal) and an implementation ofurlencode(like Python’surllib.urlencode) which can handle Unicode keys and values in parameters to thequeryargument.
Deprecations¶
- The
model_urlfunction has been moved fromrepoze.bfg.traversalintorepoze.bfg.url. It can still be imported fromrepoze.bfg.traversalbut an import fromrepoze.bfg.traversalwill emit a DeprecationWarning.
Features¶
- A
statichelper class was added to therepoze.bfg.viewsmodule. Instances of this class are willing to act as BFG views which return static resources using files on disk. See therepoze.bfg.viewdocs for more info. - The
repoze.bfg.url.model_urlAPI (nee’repoze.bfg.traversal.model_url) now accepts and honors a keyword argument namedquery. 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.configurationpackage for use underrepoze.bfg,repoze.bfgnow makes available the implementations of directives from therepoze.zcmlpackage (see http://static.repoze.org/zcmldocs). As a result, therepoze.bfgpackage now depends on therepoze.zcmlpackage, and no longer depends directly on thezope.component,zope.configuration,zope.interface, orzope.proxypackages.The primary reason for this change is to enable us to eventually reduce the number of inappropriate
repoze.bfgZope package dependencies, as well as to shed features of dependent package directives that don’t make sense forrepoze.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.componentZCML directive implementations (e.g.adapter,subscriber, orutility) to function now must either 1) include themeta.zcmlfile fromzope.componentmanually (e.g.<include package="zope.component" file="meta.zcml">) and include thezope.securitypackage as aninstall_requiresdependency or 2) change the ZCML in their applications to use the declarations from repoze.zcml instead of the stock declarations.repoze.zcmlonly makes available theadapter,subscriberandutilitydirectives.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.securityto the “install_requires” of your BFG application’ssetup.py, then add the following ZCML anywhere in your application’sconfigure.zcml:<include package="zope.component" file="meta.zcml">
Then re-
setup.py developor reinstall your application.The
http://namespaces.repoze.org/bfgXML 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.zcmlandconfigure.zcmlwere removed from the root of therepoze.bfgpackage. In 0.3.6, a new package namedrepoze.bfg.includeswas added, which contains the “correct” copies of these ZCML files; the ones that were removed were for backwards compatibility purposes.The BFG
viewZCML directive no longer callszope.component.interface.provideInterfacefor theforinterface. We don’t supportprovideInterfacein BFG because it mutates the global registry.
Other¶
- The minimum requirement for
chameleon.coreis now 1.0b13. The minimum requirement forchameleon.zptis now 1.0b8. The minimum requirement forchameleon.genshiis now 1.0b2. - Updated paster template “ez_setup.py” to one that requires setuptools 0.6c9.
- Turn
view_execution_permittedfrom therepoze.bfg.viewmodule 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_urlexecution by using a custom url quoting function instead of Python’surllib.quote, by caching URL path segment quoting and encoding results, by disusing Python’surlparse.urljoinin favor of a simple string concatenation, and by usingob.__class__ is unicoderather thanisinstance(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 (astrobject). Now, by default the ModelGraphTraverser attempts to decode the path segment to Unicode (aunicodeobject) 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_urlAPI 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 aTypeErrorwith 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 theunicode_path_segmentsconfiguration 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_SEGMENTenvvar 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
**elementsto thetraversal.model_urlAPI. 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 aselementsto 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_urlAPI. 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.roottorouter.Routerin order to have easy access to the application root.
0.5.3 (2008-12-07)¶
- Remove the
ITestingTemplateRendererinterface. Whentesting.registerDummyRendereris used, it instead registers a dummy implementation usingITemplateRendererinterface, 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 againstITemplateRenderer; 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 forfor_andrequest_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 dozope.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, andvaluesmethods totesting.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.locatenow 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_viewdecorator when they’re stacked. - Add content_length attribute to testing.DummyRequest.
- Change paster template
tests.pyto include a true unit test. Retain old test as an integration test. Update documentation. - Document view registrations against classes and
repoze.bfg.conventionin 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_urlnow always appends a slash to all generated URLs unless further elements are passed in as the third and following arguments. Rationale: views often usemodel_urlwithout 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 technicallyhttp://mysite/as opposed tohttp://mysite(browsers happen to ask for ‘/’ implicitly in the GET request). Because URLs are never automatically generated for anything except models bymodel_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.registerEventListenerto 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_pathandmodel_urltraversal APIs returned the wrong value for the root object (e.g.model_pathreturned''for the root object, while it should have been returning'/').
0.4.5 (2008-11-09)¶
Features¶
- Added a
clonemethod 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
selfas its implementation.
0.4.4 (2008-11-08)¶
Features¶
- Added a
repoze.bfg.testingmodule 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
ITestingTemplateRendererusing a relative pathname. This is exposed indirectly through the API namedregisterTemplateRendererinrepoze.bfg.testing.
Deprecations¶
- The names
repoze.bfg.interfaces.ITemplate,repoze.bfg.interfaces.ITemplateFactoryandrepoze.bfg.interfaces.INodeTemplatehave been deprecated. These should now be imported asrepoze.bfg.interfaces.ITemplateRendererandrepoze.bfg.interfaces.ITemplateRendererFactory, andINodeTemplateRendererrespectively. - The name
repoze.bfg.chameleon_zpt.ZPTTemplateFactoryis deprecated. Userepoze.bfg.chameleon_zpt.ZPTTemplateRenderer. - The name
repoze.bfg.chameleon_genshi.GenshiTemplateFactoryis deprecated. Userepoze.bfg.chameleon_genshi.GenshiTemplateRenderer. - The name
repoze.bfg.xslt.XSLTemplateFactoryis deprecated. Userepoze.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_authorizationanddebug_notfound. - Return an instance of
Allowed(rather thanTrue) fromhas_permissionwhen no security policy is in use. - Fix bug where default deny in authorization check would throw a TypeError
(use
ACLDeniedinstead ofDenied).
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_AUTHORIZATIONenvvar and thedebug_authorizationconfig file value now only imply debugging of view-invoked security checks. Previously, information was printed for every call tohas_permissionas well, which made output confusing. To debughas_permissionchecks 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_authorizationis true. - The format of authorization debug messages was improved.
- A new
BFG_DEBUG_NOTFOUNDenvvar was added and a symmetricdebug_notfoundconfig 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. AllowedandDeniedresponses from the security machinery are now specialized into two types: ACL types, and non-ACL types. The ACL-related responses are instances ofrepoze.bfg.security.ACLAllowedandrepoze.bfg.security.ACLDenied. The non-ACL-related responses arerepoze.bfg.security.Allowedandrepoze.bfg.security.Denied. The allowed-type responses continue to evaluate equal to things that themselves evaluate equal to theTrueboolean, while the denied-type responses continue to evaluate equal to things that themselves evaluate equal to theFalseboolean. The only difference between the two types is the information attached to them for debugging purposes.- Added a new
BFG_DEBUG_ALLenvvar and a symmetricdebug_allconfig file value. When either is true, all other debug-related flags are set true unconditionally (e.g.debug_notfoundanddebug_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#httpserver rather thanPasteScript#cherrpyserver. The cherrypy server has a security risk in it whenREMOTE_USERis trusted by the downstream application.
0.4.1 (2008-10-28)¶
Bug Fixes¶
- If the
render_view_to_responsefunction 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_TEMPLATESis now available (serves the same purpose asreload_templatesin the config file). - A new configuration file option
debug_authorizationwas added. This turns on printing of security authorization debug statements tosys.stderr. TheBFG_DEBUG_AUTHORIZATIONenvironment variable was also added; this performs the same duty.
Bug Fixes¶
- The environment variable
BFG_SECURITY_DEBUGdid not always work. It has been renamed toBFG_DEBUG_AUTHORIZATIONand fixed.
Deprecations¶
- A deprecation warning is now issued when old API names from the
repoze.bfg.templatesmodule are imported.
Backwards incompatibilities¶
- The
BFG_SECURITY_DEBUGenvironment variable was renamed toBFG_DEBUG_AUTHORIZATION.
0.3.9 (2008-08-27)¶
Features¶
- A
repoze.bfg.locationAPI module was added.
Backwards incompatibilities¶
Applications must now use the
repoze.bfg.interfaces.ILocationinterface rather thanzope.location.interfaces.ILocationto represent that a model object is “location-aware”. We’ve removed a dependency onzope.locationfor cleanliness purposes: as new versions of zope libraries are released which have improved dependency information, getting rid of our dependence onzope.locationwill prevent a newly installed repoze.bfg application from requiring thezope.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.bfgrecommended using thezope.location.interfaces.ILocationinterface to represent that a model object is “location-aware”. This documentation has been changed to reflect that this interface should now be imported fromrepoze.bfg.interfaces.ILocationinstead.
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_permissionAPI to security module. - Replace
z3c.ptsupport with support forchameleon.zpt. Chameleon is the new name for the package that used to be namedz3c.pt. NOTE: If you update arepoze.bfgSVN 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.ptis no longer supported byrepoze.bfg. All API functions that used to renderz3c.pttemplates will work fine with the new packages, and your templates should render almost identically. - Add a
repoze.bfg.chameleon_zptmodule. This module provides Chameleon ZPT support. - Add a
repoze.bfg.xsltmodule. This module provides XSLT support. - Add a
repoze.bfg.chameleon_genshimodule. This provides direct Genshi support, which did not exist previously.
Deprecations¶
- Importing API functions directly from
repoze.bfg.templateis now deprecated. Theget_template,render_template,render_template_to_responsefunctions should now be imported fromrepoze.chameleon_zpt. Therender_transform, andrender_transform_to_responsefunctions should now be imported fromrepoze.bfg.xslt. Therepoze.bfg.templatemodule 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_modelfunction 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.includespackage so we can use repoze.bfg better as a namespace package. Adjust the code generator to use it. We’ve left around theconfigure.zcmlin 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 namedrender_view_to_response,render_view_to_iterable,render_viewandis_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.bfga 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 therepoze.bfgmodule directly. This change will break all existing apps generated by the paster code generator. Instead, you need to import these functions asrepoze.bfg.router:make_appandrepoze.bfg.registry:get_options, respectively. Sorry folks, it has to be done now or never, and definitely better now.
Features¶
- Add
model_pathAPI 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
sampleappsample 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.ptversion 1.0a1 (which requires the[lxml]extra currently). - Read and write a pickled ZCML actions list, stored as
configure.zcml.cachenext 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_appentry point renamed toappin order to have a different name than the bfg function of the same name, to prevent confusion. - Add “options” processing to bfg’s
make_appto support runtime options. A new API function namedget_optionswas added to the registry module. This function is typically used in an application’sappentry point. The Paste config file section for the app can now supply thereload_templatesoption, which, if true, will prevent the need to restart the appserver in order forz3c.ptor 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_templateAPI 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_modelandfind_roottraversal 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_typeattribute to the available attributes of abfg:viewconfigure.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
connectmethod of theurldispatch.RoutesMapperobject now accepts a keyword parameter namedcontext_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
apidirectory.
0.2.5 (2008-07-28)¶
- Add
model_urlAPI.
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
factoryattribute in the bfg:view ZCML statement has been renamed toview. Various interface names were changed also. render_templateandrender_transformno longer return a Response object. Instead, these return strings. The old behavior can be obtained by usingrender_template_to_responseandrender_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.