pyramid.config¶
- class Configurator(registry=None, package=None, settings=None, root_factory=None, security_policy=None, authentication_policy=None, authorization_policy=None, renderers=None, debug_logger=None, locale_negotiator=None, request_factory=None, response_factory=None, default_permission=None, session_factory=None, default_view_mapper=None, autocommit=False, exceptionresponse_view=<function default_exceptionresponse_view>, route_prefix=None, introspection=True, root_package=None)[source]¶
 A Configurator is used to configure a Pyramid application registry.
The Configurator lifecycle can be managed by using a context manager to automatically handle calling
pyramid.config.Configurator.begin()andpyramid.config.Configurator.end()as well aspyramid.config.Configurator.commit().with Configurator(settings=settings) as config: config.add_route('home', '/') app = config.make_wsgi_app()
If the
registryargument is notNone, it must be an instance of thepyramid.registry.Registryclass representing the registry to configure. IfregistryisNone, the configurator will create apyramid.registry.Registryinstance itself; it will also perform some default configuration that would not otherwise be done. After its construction, the configurator may be used to add further configuration to the registry.Warning
If
registryis assigned the above-mentioned class instance, all other constructor arguments are ignored, with the exception ofpackage.If the
packageargument is passed, it must be a reference to a Python package (e.g.sys.modules['thepackage']) or a dotted Python name to the same. This value is used as a basis to convert relative paths passed to various configuration methods, such as methods which accept arendererargument, into absolute paths. IfNoneis passed (the default), the package is assumed to be the Python package in which the caller of theConfiguratorconstructor lives.If the
root_packageis passed, it will propagate through the configuration hierarchy as a way for included packages to locate resources relative to the package in which the mainConfiguratorwas created. IfNoneis passed (the default), theroot_packagewill be derived from thepackageargument. Thepackageattribute is always pointing at the package being included when usinginclude(), whereas theroot_packagedoes not change.If the
settingsargument is passed, it should be a Python dictionary representing the deployment settings for this application. These are later retrievable using thepyramid.registry.Registry.settingsattribute (akarequest.registry.settings).If the
root_factoryargument is passed, it should be an object representing the default root factory for your application or a dotted Python name to the same. If it isNone, a default root factory will be used.If
security_policyis passed, it should be an instance of a security policy or a dotted Python name to the same.If
authentication_policyis passed, it should be an instance of an authentication policy or a dotted Python name to the same.If
authorization_policyis passed, it should be an instance of an authorization policy or a dotted Python name to the same.Note
A
ConfigurationErrorwill be raised when an authorization policy is supplied without also supplying an authentication policy (authorization requires authentication).If
renderersisNone(the default), a default set of renderer factories is used. Else, it should be a list of tuples representing a set of renderer factories which should be configured into this application, and each tuple representing a set of positional values that should be passed topyramid.config.Configurator.add_renderer().If
debug_loggeris not passed, a default debug logger that logs to a logger will be used (the logger name will be the package name of the caller of this configurator). If it is passed, it should be an instance of thelogging.Logger(PEP 282) standard library class or a Python logger name. The debug logger is used by Pyramid itself to log warnings and authorization debugging information.If
locale_negotiatoris passed, it should be a locale negotiator implementation or a dotted Python name to same. See Using a Custom Locale Negotiator.If
request_factoryis passed, it should be a request factory implementation or a dotted Python name to the same. See Changing the Request Factory. By default it isNone, which means use the default request factory.If
response_factoryis passed, it should be a response factory implementation or a dotted Python name to the same. See Changing the Response Factory. By default it isNone, which means use the default response factory.If
default_permissionis passed, it should be a permission string to be used as the default permission for all view configuration registrations performed against this Configurator. An example of a permission string:'view'. Adding a default permission makes it unnecessary to protect each view configuration with an explicit permission, unless your application policy requires some exception for a particular view. By default,default_permissionisNone, meaning that view configurations which do not explicitly declare a permission will always be executable by entirely anonymous users (any authorization policy in effect is ignored).See also
See also Setting a Default Permission.
If
session_factoryis passed, it should be an object which implements the session factory interface. If a nondefault value is passed, thesession_factorywill be used to create a session object whenrequest.sessionis accessed. Note that the same outcome can be achieved by callingpyramid.config.Configurator.set_session_factory(). By default, this argument isNone, indicating that no session factory will be configured (and thus accessingrequest.sessionwill throw an error) unlessset_session_factoryis called later during configuration.If
autocommitisTrue, every method called on the configurator will cause an immediate action, and no configuration conflict detection will be used. IfautocommitisFalse, most methods of the configurator will defer their action untilpyramid.config.Configurator.commit()is called. Whenpyramid.config.Configurator.commit()is called, the actions implied by the called methods will be checked for configuration conflicts unlessautocommitisTrue. If a conflict is detected, aConfigurationConflictErrorwill be raised. Callingpyramid.config.Configurator.make_wsgi_app()always implies a final commit.If
default_view_mapperis passed, it will be used as the default view mapper factory for view configurations that don't otherwise specify one (seepyramid.interfaces.IViewMapperFactory). Ifdefault_view_mapperis not passed, a superdefault view mapper will be used.If
exceptionresponse_viewis passed, it must be a view callable orNone. If it is a view callable, it will be used as an exception view callable when an exception response is raised. Ifexceptionresponse_viewisNone, no exception response view will be registered, and all raised exception responses will be bubbled up to Pyramid's caller. By default, thepyramid.httpexceptions.default_exceptionresponse_viewfunction is used as theexceptionresponse_view.If
route_prefixis passed, all routes added withpyramid.config.Configurator.add_route()will have the specified path prepended to their pattern.If
introspectionis passed, it must be a boolean value. If it'sTrue, introspection values during actions will be kept for use for tools like the debug toolbar. If it'sFalse, introspection values provided by registrations will be ignored. By default, it isTrue.New in version 1.1: The
exceptionresponse_viewargument.New in version 1.2: The
route_prefixargument.New in version 1.3: The
introspectionargument.New in version 1.6: The
root_packageargument. Theresponse_factoryargument.New in version 1.9: The ability to use the configurator as a context manager with the
with-statement to make threadlocal configuration available for further configuration with an implicit commit.Controlling Configuration State
- commit()¶
 Commit any pending configuration actions. If a configuration conflict is detected in the pending configuration actions, this method will raise a
ConfigurationConflictError; within the traceback of this error will be information about the source of the conflict, usually including file names and line numbers of the cause of the configuration conflicts.Warning
You should think very carefully before manually invoking
commit(). Especially not as part of any reusable configuration methods. Normally it should only be done by an application author at the end of configuration in order to override certain aspects of an addon.
- begin(request=<object object>)[source]¶
 Indicate that application or test configuration has begun. This pushes a dictionary containing the application registry implied by
registryattribute of this configurator and the request implied by therequestargument onto the thread local stack consulted by variouspyramid.threadlocalAPI functions.If
requestis not specified and the registry owned by the configurator is already pushed as the current threadlocal registry then this method will keep the current threadlocal request unchanged.Changed in version 1.8: The current threadlocal request is propagated if the current threadlocal registry remains unchanged.
- end()[source]¶
 Indicate that application or test configuration has ended. This pops the last value pushed onto the thread local stack (usually by the
beginmethod) and returns that value.
- include(callable, route_prefix=None)[source]¶
 Include a configuration callable, to support imperative application extensibility.
Warning
In versions of Pyramid prior to 1.2, this function accepted
*callables, but this has been changed to support only a single callable.A configuration callable should be a callable that accepts a single argument named
config, which will be an instance of a Configurator. However, be warned that it will not be the same configurator instance on which you call this method. The code which runs as a result of calling the callable should invoke methods on the configurator passed to it which add configuration state. The return value of a callable will be ignored.Values allowed to be presented via the
callableargument to this method: any callable Python object or any dotted Python name which resolves to a callable Python object. It may also be a Python module, in which case, the module will be searched for a callable namedincludeme, which will be treated as the configuration callable.For example, if the
includemefunction below lives in a module namedmyapp.myconfig:1# myapp.myconfig module 2 3def my_view(request): 4 from pyramid.response import Response 5 return Response('OK') 6 7def includeme(config): 8 config.add_view(my_view)
You might cause it to be included within your Pyramid application like so:
1from pyramid.config import Configurator 2 3def main(global_config, **settings): 4 config = Configurator() 5 config.include('myapp.myconfig.includeme')
Because the function is named
includeme, the function name can also be omitted from the dotted name reference:1from pyramid.config import Configurator 2 3def main(global_config, **settings): 4 config = Configurator() 5 config.include('myapp.myconfig')
Included configuration statements will be overridden by local configuration statements if an included callable causes a configuration conflict by registering something with the same configuration parameters.
If the
route_prefixis supplied, it must be a string and will have a similar effect to usingpyramid.config.Configurator.route_prefix_context(). Any calls topyramid.config.Configurator.add_route()within the included callable will have their pattern prefixed with the value ofroute_prefix. This can be used to help mount a set of routes at a different location than the included callable's author intended, while still maintaining the same route names. For example:1from pyramid.config import Configurator 2 3def included(config): 4 config.add_route('show_users', '/show') 5 6def main(global_config, **settings): 7 config = Configurator() 8 config.include(included, route_prefix='/users')
In the above configuration, the
show_usersroute will have an effective route pattern of/users/show, instead of/showbecause theroute_prefixargument will be prepended to the pattern.New in version 1.2: The
route_prefixparameter.Changed in version 1.9: The included function is wrapped with a call to
pyramid.config.Configurator.begin()andpyramid.config.Configurator.end()while it is executed.
- make_wsgi_app()[source]¶
 Commits any pending configuration statements, sends a
pyramid.events.ApplicationCreatedevent to all listeners, adds this configuration's registry topyramid.config.global_registries, and returns a Pyramid WSGI application representing the committed configuration state.
- route_prefix_context(route_prefix)¶
 Return this configurator with a route prefix temporarily set.
When the context exits, the
route_prefixis reset to the original.route_prefixis a string suitable to be used as a route prefix, orNone.Example Usage:
config = Configurator() with config.route_prefix_context('foo'): config.add_route('bar', '/bar')
New in version 1.10.
- scan(package=None, categories=('pyramid',), onerror=None, ignore=None, **kw)[source]¶
 Scan a Python package and any of its subpackages for objects marked with configuration decoration such as
pyramid.view.view_config. Any decorated object found will influence the current configuration state.The
packageargument should be a Python package or module object (or a dotted Python name which refers to such a package or module). IfpackageisNone, the package of the caller is used.The
categoriesargument, if provided, should be the Venusian 'scan categories' to use during scanning. Providing this argument is not often necessary; specifying scan categories is an extremely advanced usage. By default,categoriesis['pyramid']which will execute only Pyramid-related Venusian decorator callbacks such as frompyramid.view.view_config. See the Venusian documentation for more information about limiting a scan by using an explicit set of categories. PassNoneto pick up all Venusian decorators.The
onerrorargument, if provided, should be a Venusianonerrorcallback function. The onerror function is passed tovenusian.Scanner.scan()to influence error behavior when an exception is raised during the scanning process. See the Venusian documentation for more information aboutonerrorcallbacks.The
ignoreargument, if provided, should be a Venusianignorevalue. Providing anignoreargument allows the scan to ignore particular modules, packages, or global objects during a scan.ignorecan be a string or a callable, or a list containing strings or callables. The simplest usage ofignoreis to provide a module or package by providing a full path to its dotted name. For example:config.scan(ignore='my.module.subpackage')would ignore themy.module.subpackagepackage during a scan, which would prevent the subpackage and any of its submodules from being imported and scanned. See the Venusian documentation for more information about theignoreargument.To perform a
scan, Pyramid creates a VenusianScannerobject. Thekwargument represents a set of keyword arguments to pass to the VenusianScannerobject's constructor. See the venusian documentation (itsScannerclass) for more information about the constructor. By default, the only keyword arguments passed to the Scanner constructor are{'config':self}whereselfis this configurator object. This services the requirement of all built-in Pyramid decorators, but extension systems may require additional arguments. Providing this argument is not often necessary; it's an advanced usage.New in version 1.1: The
**kwargument.New in version 1.3: The
ignoreargument.Changed in version 2.0: The
categoriesargument now defaults to['pyramid']instead ofNoneto control which decorator callbacks are executed.
Adding Routes and Views
Adding an Event Subscriber
Using Security
- add_permission(permission_name)¶
 A configurator directive which registers a free-standing permission without associating it with a view callable. This can be used so that the permission shows up in the introspectable data under the
permissionscategory (permissions mentioned viaadd_viewalready end up in there). For example:config = Configurator() config.add_permission('view')
Extending the Request Object
Using I18N
Overriding Assets
Getting and Adding Settings
- add_settings(settings=None, **kw)¶
 Augment the deployment settings with one or more key/value pairs.
You may pass a dictionary:
config.add_settings({'external_uri':'http://example.com'})
Or a set of key/value pairs:
config.add_settings(external_uri='http://example.com')
This function is useful when you need to test code that accesses the
pyramid.registry.Registry.settingsAPI (or thepyramid.config.Configurator.get_settings()API) and which uses values from that API.
- get_settings()¶
 Return a deployment settings object for the current application. A deployment settings object is a dictionary-like object that contains key/value pairs based on the dictionary passed as the
settingsargument to thepyramid.config.Configuratorconstructor.Note
the
pyramid.registry.Registry.settingsAPI performs the same duty.
Hooking Pyramid Behavior
- add_tween(tween_factory, under=None, over=None)¶
 New in version 1.2.
Add a 'tween factory'. A tween (a contraction of 'between') is a bit of code that sits between the Pyramid router's main request handling function and the upstream WSGI component that uses Pyramid as its 'app'. Tweens are a feature that may be used by Pyramid framework extensions, to provide, for example, Pyramid-specific view timing support, bookkeeping code that examines exceptions before they are returned to the upstream WSGI application, or a variety of other features. Tweens behave a bit like WSGI 'middleware' but they have the benefit of running in a context in which they have access to the Pyramid application registry as well as the Pyramid rendering machinery.
Note
You can view the tween ordering configured into a given Pyramid application by using the
ptweenscommand. See ptweens: Displaying "Tweens".The
tween_factoryargument must be a dotted Python name to a global object representing the tween factory.The
underandoverarguments allow the caller ofadd_tweento provide a hint about where in the tween chain this tween factory should be placed when an implicit tween chain is used. These hints are only used when an explicit tween chain is not used (when thepyramid.tweensconfiguration value is not set). Allowable values forunderorover(or both) are:None(the default).A dotted Python name to a tween factory: a string representing the dotted name of a tween factory added in a call to
add_tweenin the same configuration session.One of the constants
pyramid.tweens.MAIN,pyramid.tweens.INGRESS, orpyramid.tweens.EXCVIEW.An iterable of any combination of the above. This allows the user to specify fallbacks if the desired tween is not included, as well as compatibility with multiple other tweens.
undermeans 'closer to the main Pyramid application than',overmeans 'closer to the request ingress than'.For example, calling
add_tween('myapp.tfactory', over=pyramid.tweens.MAIN)will attempt to place the tween factory represented by the dotted namemyapp.tfactorydirectly 'above' (inptweensorder) the main Pyramid request handler. Likewise, callingadd_tween('myapp.tfactory', over=pyramid.tweens.MAIN, under='mypkg.someothertween')will attempt to place this tween factory 'above' the main handler but 'below' (a fictional) 'mypkg.someothertween' tween factory.If all options for
under(orover) cannot be found in the current configuration, it is an error. If some options are specified purely for compatibility with other tweens, just add a fallback of MAIN or INGRESS. For example,under=('mypkg.someothertween', 'mypkg.someothertween2', INGRESS). This constraint will require the tween to be located under both the 'mypkg.someothertween' tween, the 'mypkg.someothertween2' tween, and INGRESS. If any of these is not in the current configuration, this constraint will only organize itself based on the tweens that are present.Specifying neither
overnorunderis equivalent to specifyingunder=INGRESS.Implicit tween ordering is obviously only best-effort. Pyramid will attempt to present an implicit order of tweens as best it can, but the only surefire way to get any particular ordering is to use an explicit tween order. A user may always override the implicit tween ordering by using an explicit
pyramid.tweensconfiguration value setting.under, andoverarguments are ignored when an explicit tween chain is specified using thepyramid.tweensconfiguration value.For more information, see Registering Tweens.
Extension Author APIs
- action(discriminator, callable=None, args=(), kw=None, order=0, introspectables=(), **extra)¶
 Register an action which will be executed when
pyramid.config.Configurator.commit()is called (or executed immediately ifautocommitisTrue).Warning
This method is typically only used by Pyramid framework extension authors, not by Pyramid application developers.
The
discriminatoruniquely identifies the action. It must be given, but it can beNone, to indicate that the action never conflicts. It must be a hashable value.The
callableis a callable object which performs the task associated with the action when the action is executed. It is optional.argsandkware tuple and dict objects respectively, which are passed tocallablewhen this action is executed. Both are optional.orderis a grouping mechanism; an action with a lower order will be executed before an action with a higher order (has no effect when autocommit isTrue).introspectablesis a sequence of introspectable objects (or the empty sequence if no introspectable objects are associated with this action). If this configurator'sintrospectionattribute isFalse, these introspectables will be ignored.extraprovides a facility for inserting extra keys and values into an action dictionary.
- add_directive(name, directive, action_wrap=True)[source]¶
 Add a directive method to the configurator.
Warning
This method is typically only used by Pyramid framework extension authors, not by Pyramid application developers.
Framework extenders can add directive methods to a configurator by instructing their users to call
config.add_directive('somename', 'some.callable'). This will makesome.callableaccessible asconfig.somename.some.callableshould be a function which acceptsconfigas a first argument, and arbitrary positional and keyword arguments following. It should use config.action as necessary to perform actions. Directive methods can then be invoked like 'built-in' directives such asadd_view,add_route, etc.The
action_wrapargument should beTruefor directives which performconfig.actionwith potentially conflicting discriminators.action_wrapwill cause the directive to be wrapped in a decorator which provides more accurate conflict cause information.add_directivedoes not participate in conflict detection, and later calls toadd_directivewill override earlier calls.
- with_package(package)[source]¶
 Return a new Configurator instance with the same registry as this configurator.
packagemay be an actual Python package object or a dotted Python name representing a package.
- derive_view(view, attr=None, renderer=None)¶
 Create a view callable using the function, instance, or class (or dotted Python name referring to the same) provided as
viewobject.Warning
This method is typically only used by Pyramid framework extension authors, not by Pyramid application developers.
This is API is useful to framework extenders who create pluggable systems which need to register 'proxy' view callables for functions, instances, or classes which meet the requirements of being a Pyramid view callable. For example, a
some_other_frameworkfunction in another framework may want to allow a user to supply a view callable, but he may want to wrap the view callable in his own before registering the wrapper as a Pyramid view callable. Because a Pyramid view callable can be any of a number of valid objects, the framework extender will not know how to call the user-supplied object. Running it throughderive_viewnormalizes it to a callable which accepts two arguments:contextandrequest.For example:
def some_other_framework(user_supplied_view): config = Configurator(reg) proxy_view = config.derive_view(user_supplied_view) def my_wrapper(context, request): do_something_that_mutates(request) return proxy_view(context, request) config.add_view(my_wrapper)
The
viewobject provided should be one of the following:A function or another non-class callable object that accepts a request as a single positional argument and which returns a response object.
A function or other non-class callable object that accepts two positional arguments,
context, requestand which returns a response object.A class which accepts a single positional argument in its constructor named
request, and which has a__call__method that accepts no arguments that returns a response object.A class which accepts two positional arguments named
context, request, and which has a__call__method that accepts no arguments that returns a response object.A dotted Python name which refers to any of the kinds of objects above.
This API returns a callable which accepts the arguments
context, requestand which returns the result of calling the providedviewobject.The
attrkeyword argument is most useful when the view object is a class. It names the method that should be used as the callable. Ifattris not provided, the attribute effectively defaults to__call__. See Defining a View Callable as a Class for more information.The
rendererkeyword argument should be a renderer name. If supplied, it will cause the returned callable to use a renderer to convert the user-supplied view result to a response object. If arendererargument is not supplied, the user-supplied view must itself return a response object.
Utility Methods
- absolute_asset_spec(relative_spec)[source]¶
 Resolve the potentially relative asset specification string passed as
relative_specinto an absolute asset specification string and return the string. Use thepackageof this configurator as the package to which the asset specification will be considered relative when generating an absolute asset specification. If the providedrelative_specargument is already absolute, or if therelative_specis not a string, it is simply returned.
- maybe_dotted(dotted)[source]¶
 Resolve the dotted Python name
dottedto a global Python object. Ifdottedis not a string, return it without attempting to do any name resolution. Ifdottedis a relative dotted name (e.g..foo.bar, consider it relative to thepackageargument supplied to this Configurator's constructor.
ZCA-Related APIs
- hook_zca()¶
 Call
zope.component.getSiteManager.sethook()with the argumentpyramid.threadlocal.get_current_registry, causing the Zope Component Architecture 'global' APIs such aszope.component.getSiteManager(),zope.component.getAdapter()and others to use the Pyramid application registry rather than the Zope 'global' registry.
- unhook_zca()¶
 Call
zope.component.getSiteManager.reset()to undo the action ofpyramid.config.Configurator.hook_zca().
- setup_registry(settings=None, root_factory=None, security_policy=None, authentication_policy=None, authorization_policy=None, renderers=None, debug_logger=None, locale_negotiator=None, request_factory=None, response_factory=None, default_permission=None, session_factory=None, default_view_mapper=None, exceptionresponse_view=<function default_exceptionresponse_view>)[source]¶
 When you pass a non-
Noneregistryargument to the Configurator constructor, no initial setup is performed against the registry. This is because the registry you pass in may have already been initialized for use under Pyramid via a different configurator. However, in some circumstances (such as when you want to use a global registry instead of a registry created as a result of the Configurator constructor), or when you want to reset the initial setup of a registry, you do want to explicitly initialize the registry associated with a Configurator for use under Pyramid. Usesetup_registryto do this initialization.setup_registryconfigures settings, a root factory, security policies, renderers, a debug logger, a locale negotiator, and various other settings using the configurator's current registry, as per the descriptions in the Configurator constructor.
Testing Helper APIs
- testing_add_renderer(path, renderer=None)¶
 Unit/integration testing helper: register a renderer at
path(usually a relative filename alatemplates/foo.ptor an asset specification) and return the renderer object. If therendererargument is None, a 'dummy' renderer will be used. This function is useful when testing code that calls thepyramid.renderers.render()function orpyramid.renderers.render_to_response()function or any otherrender_*orget_*API of thepyramid.renderersmodule.Note that calling this method for with a
pathargument representing a renderer factory type (e.g. forfoo.ptusually implies thechameleon_zptrenderer factory) clobbers any existing renderer factory registered for that type.Note
This method is also available under the alias
testing_add_template(an older name for it).
- testing_resources(resources)¶
 Unit/integration testing helper: registers a dictionary of resource objects that can be resolved via the
pyramid.traversal.find_resource()API.The
pyramid.traversal.find_resource()API is called with a path as one of its arguments. If the dictionary you register when calling this method contains that path as a string key (e.g./foo/barorfoo/bar), the corresponding value will be returned tofind_resource(and thus to your code) whenpyramid.traversal.find_resource()is called with an equivalent path string or tuple.
- testing_securitypolicy(userid=None, identity=None, permissive=True, remember_result=None, forget_result=None)¶
 Unit/integration testing helper. Registers a faux security policy.
This function is most useful when testing code that uses the security APIs, such as
pyramid.request.Request.identity(),pyramid.request.Request.authenticated_userid, orpyramid.request.Request.has_permission(),The behavior of the registered security policy depends on the arguments passed to this method.
- Parameters:
 userid (str) -- If provided, the policy's
authenticated_useridmethod will return this value. As a result,pyramid.request.Request.authenticated_useridwill have this value as well.identity (object) -- If provided, the policy's
identitymethod will return this value. As a result,pyramid.request.Request.identity`will have this value.permissive (bool) -- If true, the policy will allow access to any user for any permission. If false, the policy will deny all access.
remember_result (list) -- If provided, the policy's
remembermethod will return this value. Otherwise,rememberwill return an empty list.forget_result (list) -- If provided, the policy's
forgetmethod will return this value. Otherwise,forgetwill return an empty list.
New in version 1.4: The
remember_resultargument.New in version 1.4: The
forget_resultargument.Changed in version 2.0: Removed
groupidsargument and add identity argument.
Attributes
- introspectable¶
 A shortcut attribute which points to the
pyramid.registry.Introspectableclass (used during directives to provide introspection to actions).New in version 1.3.
- introspector¶
 The introspector related to this configuration. It is an instance implementing the
pyramid.interfaces.IIntrospectorinterface.New in version 1.3.
- registry¶
 The application registry which holds the configuration associated with this configurator.
- global_registries¶
 The set of registries that have been created for Pyramid applications, one for each call to
pyramid.config.Configurator.make_wsgi_app()in the current process. The object itself supports iteration and has alastproperty containing the last registry loaded.The registries contained in this object are stored as weakrefs, thus they will only exist for the lifetime of the actual applications for which they are being used.
- class not_(value)[source]¶
 You can invert the meaning of any predicate value by wrapping it in a call to
pyramid.config.not_.1from pyramid.config import not_ 2 3config.add_view( 4 'mypackage.views.my_view', 5 route_name='ok', 6 request_method=not_('POST') 7 )
The above example will ensure that the view is called if the request method is not
POST, at least if no other view is more specific.This technique of wrapping a predicate value in
not_can be used anywhere predicate values are accepted:pyramid.config.Configurator.add_view()pyramid.config.Configurator.add_route()pyramid.config.Configurator.add_subscriber()
New in version 1.5.
- PHASE0_CONFIG¶
 
- PHASE1_CONFIG¶
 
- PHASE2_CONFIG¶
 
- PHASE3_CONFIG¶