Docs for octoprint.printer.factory hook
This commit is contained in:
parent
015b99fa14
commit
b41c1d89f4
2 changed files with 43 additions and 12 deletions
|
|
@ -676,6 +676,38 @@ octoprint.filemanager.preprocessor
|
|||
:return: The `file_object` as passed in or None, or a replaced version to use instead for further processing.
|
||||
:rtype: AbstractFileWrapper or None
|
||||
|
||||
.. _sec-plugins-hook-printer-factory:
|
||||
|
||||
octoprint.printer.factory
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: hook(components, *args, **kwargs)
|
||||
|
||||
Return a :class:`~octoprint.printer.PrinterInstance` instance to use as global printer object. This will
|
||||
be called only once during initial server startup.
|
||||
|
||||
The provided ``components`` is a dictionary containing the already initialized system components:
|
||||
|
||||
* ``plugin_manager``: The :class:`~octoprint.plugin.core.PluginManager`
|
||||
* ``printer_profile_manager``: The :class:`~octoprint.printer.profile.PrinterProfileManager`
|
||||
* ``event_bus``: The :class:`~octoprint.events.EventManager`
|
||||
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
||||
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
||||
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
||||
* ``app_session_manager``: The :class:`~octoprint.server.util.flask.AppSessionManager`
|
||||
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
||||
* ``user_manager``: The :class:`~octoprint.users.UserManager`
|
||||
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
||||
|
||||
If the factory returns anything but ``None``, it will be assigned to the global ``printer`` instance.
|
||||
|
||||
If no of the registered factories return a printer instance, the default :class:`~octoprint.printer.standard.Printer`
|
||||
class will be instantiated.
|
||||
|
||||
:param dict components: System components to use for printer instance initialization
|
||||
:return: The ``printer`` instance to use globally.
|
||||
:rtype: PrinterInterface subclass or None
|
||||
|
||||
.. _sec-plugins-hook-server-http-bodysize:
|
||||
|
||||
octoprint.server.http.bodysize
|
||||
|
|
|
|||
|
|
@ -196,6 +196,17 @@ class Server(object):
|
|||
pluginLifecycleManager = LifecycleManager(pluginManager)
|
||||
preemptiveCache = PreemptiveCache(os.path.join(self._settings.getBaseFolder("data"), "preemptive_cache_config.yaml"))
|
||||
|
||||
# setup access control
|
||||
userManagerName = self._settings.get(["accessControl", "userManager"])
|
||||
try:
|
||||
clazz = octoprint.util.get_class(userManagerName)
|
||||
userManager = clazz()
|
||||
except AttributeError as e:
|
||||
self._logger.exception("Could not instantiate user manager {}, falling back to FilebasedUserManager!".format(userManagerName))
|
||||
userManager = octoprint.users.FilebasedUserManager()
|
||||
finally:
|
||||
userManager.enabled = self._settings.getBoolean(["accessControl", "enabled"])
|
||||
|
||||
components = dict(
|
||||
plugin_manager=pluginManager,
|
||||
printer_profile_manager=printerProfileManager,
|
||||
|
|
@ -223,18 +234,6 @@ class Server(object):
|
|||
printer = Printer(fileManager, analysisQueue, printerProfileManager)
|
||||
components.update(dict(printer=printer))
|
||||
|
||||
# setup access control
|
||||
userManagerName = self._settings.get(["accessControl", "userManager"])
|
||||
try:
|
||||
clazz = octoprint.util.get_class(userManagerName)
|
||||
userManager = clazz()
|
||||
except AttributeError as e:
|
||||
self._logger.exception("Could not instantiate user manager {}, falling back to FilebasedUserManager!".format(userManagerName))
|
||||
userManager = octoprint.users.FilebasedUserManager()
|
||||
finally:
|
||||
userManager.enabled = self._settings.getBoolean(["accessControl", "enabled"])
|
||||
components["user_manager"] = userManager
|
||||
|
||||
def octoprint_plugin_inject_factory(name, implementation):
|
||||
if not isinstance(implementation, octoprint.plugin.OctoPrintPlugin):
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue