Flask-PluginKit is a Flask extension for extending web application functionality. It provides an easy way to create plugins for your application. It is possible to create extension points which can then be used to extend your application without the need to modify your core code.
Flask-PluginKit can also be said to be a glue, or a bridge, for connecting web and web plugins. It supports native plugins and third-party plugins from pypi, git, svn, and so on. In addition, the plugin is also very simple to write.
The following is a Chinese-English comparison:
- Extension Point
- TEP / tep / Template Extension Point
- HEP / hep / Hook Extension Point
- BEP / bep / Blueprint Extension Point
- VEP / vep / View function Extension Point
- DCP / dcp / Dynamic Connection Point
- TCP / tcp / Template Context Processor / Context Processor
- Developer / developer
It is a local directory, it should be located in the plugins directory of
the web application (of course, can also be defined as other directories),
and is a legal python package, that is: plugins contain
plugiin directories also Contains
__init__.py, this file identifies
the directory as a package, and also identifies the plugin,
which is the core code, plugin entry.
Third-party plugins are non-web application subdirectories, but local modules from installations such as pip or easy_install.
The third-party plugins are free to use. The web application does not need
to put the plugin code into a subdirectory. It only needs to be installed
to the local machine using pip install or easy_install, and then pass
plugin_packages parameter when
PluginManager is initialized.
This means that anyone can write a package and publish it to pypi; the user writes requirements.txt and installs the dependencies, which are called in the initialization, in one go, and almost no need to worry about subsequent third-party plugin upgrades.
For instructions on how to write third-party plugins, see Third party plugin
For official plugin’s github group: https://github.com/saintic
Developers who are not Flask-PluginKit or its plugins can ignore this part.
The plugin load starts when the program starts.
The load class is
its destructor allows you to pass
(the default program directory),
(the directory where the plugin is located),
set the plugin absolute path directory, and also support factory mode,
see the API documentation for more parameters.
The loading process is as follows:
PluginManagernormal mode or factory mode to initialize the extension.
Scan the plugins_folder plugin directory and the packages that match the plugin rules will be dynamically loaded.
Load third-party plugins in
Add template global variable.
Support for multiple template directories.
Add a view function that supports access to plugin directory static resources.
Register hep, bep.
Append the instance to app.extensions.