11. Plugin base functions¶
11.3. lazy_property¶
- plugin_base.lazy_property()¶
The
@lazy_propertydecorator is used to mark attributes that should only be evaluated when accessed. This is useful when the calculation of the attribute is heavy, but not always necessary.Usage
To use
self.foobaras a lazy property, simply define it on the Plugin class, and decorate it with@lazy_propertydecorator:from safeguard.sessions.plugin import AAPlugin from safeguard.sessions.plugin.plugin_base import lazy_property class MyPlugin(AAPlugin): @lazy_property def foobar(self): return calculate_answer() def do_authenticate(self): if need_foobar: print(self.foobar)
11.5. PluginBase¶
- class safeguard.sessions.plugin.plugin_base.PluginBase(configuration, defaults=None, logger=None)¶
The
PluginBaseclass is a common base class for every kind of plugins. This class is not meant to be used directly.- cookie¶
The
self.cookieattribute is a dict that retains its contents between invocations of plugin hooks of the same plugin instance. This is the way to pass data between these functions.
- session_cookie¶
The
self.session_cookieis similar toself.cookie, but it is also visible in other plugins in the same session.
- plugin_configuration¶
The
self.plugin_configurationattribute provides access to the plugin configuration via thePluginConfigurationclass.
- logger¶
The
self.loggerattribute should be used to access Python logging. Its log level is set up from the plugin configuration.
- https_proxy_enabled¶
The
self.https_proxy_enabledattribute enables or disables the HTTPS proxy which is set either system wide or in the plugin configuration via the https_proxy section.
- https_proxy_server¶
The
self.https_proxy_serverattribute contains the IP address or hostname of the HTTPS proxy which is set either system wide or in the plugin configuration via the https_proxy section.
- https_proxy_port¶
The
self.https_proxy_portattribute contains the port number of the HTTPS proxy which is set either system wide or in the plugin configuration via the https_proxy section.
- https_proxy_username¶
The
self.https_proxy_usernameattribute contains the basic authentication username of the HTTPS proxy which is set either system wide or in the plugin configuration via the https_proxy section.
- https_proxy_password¶
The
self.https_proxy_passwordattribute contains the basic authentication password of the HTTPS proxy which is set either system wide or in the plugin configuration via the https_proxy section.
- proxy_settings¶
The
self.proxy_settingsattribute is a dictionary of the HTTPS settings.
- box_configuration¶
The
self.box_configurationattribute provides access to system settings.
The
__init__()constructor method parses the configuration and sets up logging and http proxy environment variables.