pyramid.registry
¶
- class Registry(package_name=pyramid.path.CALLER_PACKAGE, *args, **kw)[ソース]¶
A registry object is an application registry.
It is used by the framework itself to perform mappings of URLs to view callables, as well as servicing other various framework duties. A registry has its own internal API, but this API is rarely used by Pyramid application developers (it's usually only used by developers of the Pyramid framework and Pyramid addons). But it has a number of attributes that may be useful to application developers within application code, such as
settings
, which is a dictionary containing application deployment settings.For information about the purpose and usage of the application registry, see Using the Zope Component Architecture in Pyramid.
The registry may be used both as an
pyramid.interfaces.IDict
and as a Zope component registry. These two ways of storing configuration are independent. Applications will tend to prefer to store information as key-values whereas addons may prefer to use the component registry to avoid naming conflicts and to provide more complex lookup mechanisms.The application registry is usually accessed as
request.registry
in application code. By the time a registry is used to handle requests it should be considered frozen and read-only. Any changes to its internal state should be done with caution and concern for thread-safety.- settings¶
The dictionary-like deployment settings object. See Deployment Settings for information. This object is often accessed as
request.registry.settings
orconfig.registry.settings
in a typical Pyramid application.
- package_name¶
バージョン 1.6 で追加.
When a registry is set up (or created) by a Configurator, this attribute will be the shortcut for
pyramid.config.Configurator.package_name
.This attribute is often accessed as
request.registry.package_name
orconfig.registry.package_name
orconfig.package_name
in a typical Pyramid application.
- introspector¶
バージョン 1.3 で追加.
When a registry is set up (or created) by a Configurator, the registry will be decorated with an instance named
introspector
implementing thepyramid.interfaces.IIntrospector
interface.参考
See also
pyramid.config.Configurator.introspector
.When a registry is created "by hand", however, this attribute will not exist until set up by a configurator.
This attribute is often accessed as
request.registry.introspector
in a typical Pyramid application.
- notify(*events)[ソース]¶
Fire one or more events. All event subscribers to the event(s) will be notified. The subscribers will be called synchronously. This method is often accessed as
request.registry.notify
in Pyramid applications to fire custom events. See Creating Your Own Events for more information.
- class Introspectable[ソース]¶
バージョン 1.3 で追加.
The default implementation of the interface
pyramid.interfaces.IIntrospectable
used by framework exenders. An instance of this class is created whenpyramid.config.Configurator.introspectable
is called.
- class Deferred(func)[ソース]¶
Can be used by a third-party configuration extender to wrap a discriminator during configuration if an immediately hashable discriminator cannot be computed because it relies on unresolved values. The function should accept no arguments and should return a hashable discriminator.
バージョン 1.4 で追加.
- undefer(v)[ソース]¶
Function which accepts an object and returns it unless it is a
pyramid.registry.Deferred
instance. If it is an instance of that class, itsresolve
method is called, and the result of the method is returned.バージョン 1.4 で追加.