Public Member Functions | |
def | __new__ |
def | configurable_base |
def | configurable_default |
def | configure |
def | configured_class |
def | initialize |
Private Member Functions | |
def | _restore_configuration |
def | _save_configuration |
Static Private Attributes | |
__impl_class = None | |
__impl_kwargs = None |
Base class for configurable interfaces. A configurable interface is an (abstract) class whose constructor acts as a factory function for one of its implementation subclasses. The implementation subclass as well as optional keyword arguments to its initializer can be set globally at runtime with `configure`. By using the constructor as the factory method, the interface looks like a normal class, `isinstance` works as usual, etc. This pattern is most useful when the choice of implementation is likely to be a global decision (e.g. when `~select.epoll` is available, always use it instead of `~select.select`), or when a previously-monolithic class has been split into specialized subclasses. Configurable subclasses must define the class methods `configurable_base` and `configurable_default`, and use the instance method `initialize` instead of ``__init__``.
def tornado.util.Configurable.__new__ | ( | cls, | |
kwargs | |||
) |
def tornado.util.Configurable._restore_configuration | ( | cls, | |
saved | |||
) | [private] |
def tornado.util.Configurable._save_configuration | ( | cls | ) | [private] |
def tornado.util.Configurable.configurable_base | ( | cls | ) |
Returns the base class of a configurable hierarchy. This will normally return the class in which it is defined. (which is *not* necessarily the same as the cls classmethod parameter).
Reimplemented in tornado.ioloop.IOLoop, and tornado.httpclient.AsyncHTTPClient.
Returns the implementation class to be used if none is configured.
Reimplemented in tornado.ioloop.IOLoop, and tornado.httpclient.AsyncHTTPClient.
def tornado.util.Configurable.configure | ( | cls, | |
impl, | |||
kwargs | |||
) |
Sets the class to use when the base class is instantiated. Keyword arguments will be saved and added to the arguments passed to the constructor. This can be used to set global defaults for some parameters.
Reimplemented in tornado.httpclient.AsyncHTTPClient.
def tornado.util.Configurable.configured_class | ( | cls | ) |
def tornado.util.Configurable.initialize | ( | self | ) |
Initialize a `Configurable` subclass instance. Configurable classes should use `initialize` instead of ``__init__``.
Reimplemented in tornado.ioloop.IOLoop, tornado.platform.asyncio.AsyncIOLoop, and tornado.platform.asyncio.AsyncIOMainLoop.
tornado::util.Configurable::__impl_class = None [static, private] |
tornado::util.Configurable::__impl_kwargs = None [static, private] |