-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documented that nothing should be defined outside the plugin class in Python storage plugins #867
Conversation
…n storage plugins.
:::{danger} | ||
**When writing a Python storage plugin, do not define any variables or functions outside the `DLiteStorageBase` subclass!** | ||
|
||
The reason for this requirement is that all plugins will be loaded into the same shared scope within the built-in interpreter. | ||
Hence, variables or functions outside the plugin class may interfere with other plugins, resulting in confusing and hard-to-find bugs. | ||
::: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, but can we add an example in https://github.com/SINTEF/dlite/blob/master/doc/user_guide/storage_plugin.py (doen't matter if it is not used), and in the template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, but can we add an example in https://github.com/SINTEF/dlite/blob/master/doc/user_guide/storage_plugin.py (doen't matter if it is not used), and in the template?
Do you mean the note added on line 3 in https://github.com/SINTEF/dlite/blob/81261950afd235dd4c280103bcca798c46ec9463/doc/user_guide/storage_plugin.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I was thinking more along the lines
class plugin....:
....
...
def _local_help_function():
""" An optional class method or a function if desired.
Note that no functions or variables should be set outside the class
for a DLite plugin python file.
""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an example help method to the storage plugin template
…-define-anything-outside-the-plugin-class
…ing-outside-the-plugin-class' of github.com:SINTEF/dlite into 866-document-that-dlite-plugins-should-not-define-anything-outside-the-plugin-class
…-define-anything-outside-the-plugin-class
Description
Documented that nothing should be defined outside the plugin class in Python storage plugins,
Type of change
Checklist for the reviewer
This checklist should be used as a help for the reviewer.