ajenti.api¶
-
class
ajenti.api.BasePlugin[source]¶ A base plugin class that provides
AppContextandclassconfigfunctionality.-
classconfig_editor= None¶ Override this in your class with an ajenti.plugins.configurator.api.ClassConfigEditor derivative
-
classconfig_name= None¶ Override this in your class if you want this plugin to be configurable through Configure > Plugins
-
classconfig_root= False¶ When True, classconfig will be stored in root’s config section disregarding current user
-
context= None¶ Automatically receives a reference to the current
AppContext
-
default_classconfig= None¶ Override this in your class with a default config object (must be JSON-serializable)
-
init()[source]¶ Do your initialization here. Correct bottom-to-up inheritance call order guaranteed.
-
load_classconfig()[source]¶ Loads the content of
classconfigattribute from the user’s configuration section.
-
-
class
ajenti.api.AppContext(parent, httpcontext)[source]¶ A session-specific context provided to everyone who inherits
BasePlugin.-
session¶ current HTTP session:
ajenti.middleware.Session
-
user¶ current logged in user:
reconfigure.items.ajenti.UserData
Methods injected by MainPlugin:
-
notify(text)¶ Parameters: text – Notification text to show
-
launch(id, *args, **kwargs)¶ Parameters: id – Intent ID to be launched
-
-
ajenti.api.plugin(cls)[source]¶ A decorator to create plugin classes:
@plugin class SomePlugin (ISomething): pass
If the class has a
verifymethod returningbool, it’s invoked. If the method returnedFalse, plugin is rejected and removed from implementation lists.If the class has a
platformsattribute, which is a list of supported platform names, it’s compared against the current runtime OS platform. If the current platform is not in the list, plugin is also rejected.Following class methods are injected.
-
.get(context=<current context>)¶ Returns: any existing instance or creates a new one
-
.new(*args, context=<current context>, **kwargs)¶ Returns: a new instance. Use this method instead of constructor, since it invokes the proper initialization chain and registers the instance
Return type: class, None -
-
ajenti.api.rootcontext(cls)[source]¶ Enforces use of root PluginContext by default for .get() and .new() classmethods.
-
ajenti.api.notrack(cls)[source]¶ Disables instance tracking of plugin (and derivative) instances within PluginContext via get/get_all and similar methods.
Return type: class
-
ajenti.api.notrack_this(cls)[source]¶ Disables instance tracking of plugin instances within PluginContext via get/get_all and similar methods.
Return type: class
-
ajenti.api.track(cls)[source]¶ Enables previously disabled instance tracking of plugin.
Return type: class
-
ajenti.api.extract_context()[source]¶ An utility function that extracts and returns the nearest
AppContextfrom the current call stack.Return type: ajenti.plugins.PluginContext, None
-
ajenti.api.interface(cls)[source]¶ A decorator to create plugin interfaces:
@interface class ISomething (object): def contract(self): pass
Following class methods are injected:
-
.get(context=<current context>) Returns: any existing instance or creates a new one
-
.get_all(context=<current context>)¶ Returns: list of instances for each implementation
-
.get_class()¶ Returns: any implementation class
-
.get_classes()¶ Returns: list of implementation classes
-
.get_instances(context=<current context>)¶ Returns: list of all existing instances
Return type: class -