Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -694,6 +660,5 @@ diff --git a/fs_attachment/tests/test_fs_storage.py b/fs_attachment/tests/test_fs_storage.py index 981e2fcb79..629f8be230 100644 --- a/fs_attachment/tests/test_fs_storage.py +++ b/fs_attachment/tests/test_fs_storage.py @@ -305,6 +305,7 @@ def test_url_for_image_dir_optimized_and_not_obfuscated(self): { "name": "FS Product Image Backend", "code": "file", + "protocol": "odoofs", "base_url": "https://localhost/images", "optimizes_directory_path": True, "use_filename_obfuscation": False, diff --git a/fs_storage/README.rst b/fs_storage/README.rst index 4cdae5cb19..4fc9859c7b 100644 --- a/fs_storage/README.rst +++ b/fs_storage/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ========================== Filesystem Storage Backend ========================== @@ -17,7 +13,7 @@ Filesystem Storage Backend .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github @@ -129,9 +125,6 @@ When you create a new backend, you must specify the following: depend on the protocol used and are described in the fsspec documentation. -- Resolve env vars. This options resolves the protocol options values - starting with $ from environment variables - - Check Connection Method. If set, Odoo will always check the connection before using a storage and it will remove the fs connection from the cache if the check fails. @@ -166,35 +159,6 @@ follows: In this example, the SimpleCacheFileSystem protocol will be used as a wrapper around the odoofs protocol. -Server Environment ------------------- - -To ease the management of the filesystem storages configuration accross -the different environments, the configuration of the filesystem storages -can be defined in environment files or directly in the main -configuration file. For example, the configuration of a filesystem -storage with the code fsprod can be provided in the main configuration -file as follows: - -.. code:: ini - - [fs_storage.fsprod] - protocol=s3 - options={"endpoint_url": "https://my_s3_server/", "key": "KEY", "secret": "SECRET"} - directory_path=my_bucket - -To work, a storage.backend record must exist with the code fsprod into -the database. In your configuration section, you can specify the value -for the following fields: - -- protocol -- options -- directory_path - -When evaluating directory_path, ``{db_name}`` is replaced by the -database name. This is usefull in multi-tenant with a setup completly -controlled by configuration files. - Migration from storage_backend ------------------------------ diff --git a/fs_storage/__manifest__.py b/fs_storage/__manifest__.py index 129a3f3626..201cd0f2be 100644 --- a/fs_storage/__manifest__.py +++ b/fs_storage/__manifest__.py @@ -5,14 +5,14 @@ { "name": "Filesystem Storage Backend", "summary": "Implement the concept of Storage with amazon S3, sftp...", - "version": "18.0.2.1.2", + "version": "18.0.2.1.3", "category": "FS Storage", "website": "https://github.com/OCA/storage", "author": " ACSONE SA/NV, Odoo Community Association (OCA)", "license": "LGPL-3", "development_status": "Beta", "installable": True, - "depends": ["base", "base_sparse_field", "server_environment"], + "depends": ["base", "base_sparse_field"], "data": [ "views/fs_storage_view.xml", "security/ir.model.access.csv", diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py index 0e60422123..0fd189ac9d 100644 --- a/fs_storage/models/fs_storage.py +++ b/fs_storage/models/fs_storage.py @@ -89,7 +89,6 @@ def wrapper(self, *args, **kwargs): class FSStorage(models.Model): _name = "fs.storage" - _inherit = "server.env.mixin" _description = "FS Storage" __slots__ = ("__fs", "__odoo_storage_path") @@ -143,17 +142,6 @@ def __init__(self, env, ids=(), prefetch_ids=()): inverse="_inverse_json_options", ) - eval_options_from_env = fields.Boolean( - string="Resolve env vars", - help="""Resolve options values starting with $ from environment variables. e.g - { - "endpoint_url": "$AWS_ENDPOINT_URL", - } - """, - ) - - # When accessing this field, use the method get_directory_path instead so that - # parameter expansion is done. directory_path = fields.Char( help="Relative path to the directory to store the file", ) @@ -235,8 +223,6 @@ def __init__(self, env, ids=(), prefetch_ids=()): ), ] - _server_env_section_name_field = "code" - @api.constrains("model_xmlids") def _check_model_xmlid_storage_unique(self): """ @@ -302,18 +288,6 @@ def _get_check_connection_method_selection(self): ("ls", _("List File")), ] - @property - def _server_env_fields(self): - return { - "protocol": {}, - "options": {}, - "directory_path": {}, - "eval_options_from_env": {}, - "model_xmlids": {}, - "field_xmlids": {}, - "check_connection_method": {}, - } - @api.model_create_multi @prevent_call_from_safe_eval("create") def create(self, vals_list): @@ -660,32 +634,10 @@ def _recursive_add_odoo_storage_path(self, options: dict) -> dict: self._recursive_add_odoo_storage_path(target_options) return options - def _eval_options_from_env(self, options): - values = {} - for key, value in options.items(): - if isinstance(value, dict): - values[key] = self._eval_options_from_env(value) - elif isinstance(value, str) and value.startswith("$"): - env_variable_name = value[1:] - env_variable_value = os.getenv(env_variable_name) - if env_variable_value is not None: - values[key] = env_variable_value - else: - values[key] = value - _logger.warning( - "Environment variable %s is not set for fs_storage %s.", - env_variable_name, - self.display_name, - ) - else: - values[key] = value - return values - def _get_fs_options(self): - options = self.json_options - if not self.eval_options_from_env: - return options - return self._eval_options_from_env(self.json_options) + # We need this hook to be able to override + # the options in the dependent modules + return self.json_options def _get_filesystem(self) -> fsspec.AbstractFileSystem: """Get the fsspec filesystem for this backend. diff --git a/fs_storage/readme/USAGE.md b/fs_storage/readme/USAGE.md index 82fc3553a9..580c63cc1f 100644 --- a/fs_storage/readme/USAGE.md +++ b/fs_storage/readme/USAGE.md @@ -16,8 +16,6 @@ When you create a new backend, you must specify the following: fsspec python package when creating the filesystem. These options depend on the protocol used and are described in the fsspec documentation. -- Resolve env vars. This options resolves the protocol options values - starting with \$ from environment variables - Check Connection Method. If set, Odoo will always check the connection before using a storage and it will remove the fs connection from the cache if the check fails. @@ -51,34 +49,6 @@ follows: In this example, the SimpleCacheFileSystem protocol will be used as a wrapper around the odoofs protocol. -## Server Environment - -To ease the management of the filesystem storages configuration accross -the different environments, the configuration of the filesystem storages -can be defined in environment files or directly in the main -configuration file. For example, the configuration of a filesystem -storage with the code fsprod can be provided in the main configuration -file as follows: - -``` ini -[fs_storage.fsprod] -protocol=s3 -options={"endpoint_url": "https://my_s3_server/", "key": "KEY", "secret": "SECRET"} -directory_path=my_bucket -``` - -To work, a storage.backend record must exist with the code fsprod into -the database. In your configuration section, you can specify the value -for the following fields: - -- protocol -- options -- directory_path - -When evaluating directory_path, `{db_name}` is replaced by the database name. -This is usefull in multi-tenant with a setup completly controlled by -configuration files. - ## Migration from storage_backend The fs_storage addon can be used to replace the storage_backend addon. diff --git a/fs_storage/static/description/index.html b/fs_storage/static/description/index.html index 3104d3767c..2b1d39316b 100644 --- a/fs_storage/static/description/index.html +++ b/fs_storage/static/description/index.html @@ -3,7 +3,7 @@
-This addon is a technical addon that allows you to define filesystem like storage for your data. It’s used by other addons to store their data in a transparent way into different kind of storages.
@@ -441,42 +436,41 @@When you create a new backend, you must specify the following:
In this example, the SimpleCacheFileSystem protocol will be used as a wrapper around the odoofs protocol.
To ease the management of the filesystem storages configuration accross -the different environments, the configuration of the filesystem storages -can be defined in environment files or directly in the main -configuration file. For example, the configuration of a filesystem -storage with the code fsprod can be provided in the main configuration -file as follows:
--[fs_storage.fsprod] -protocol=s3 -options={"endpoint_url": "https://my_s3_server/", "key": "KEY", "secret": "SECRET"} -directory_path=my_bucket --
To work, a storage.backend record must exist with the code fsprod into -the database. In your configuration section, you can specify the value -for the following fields:
-When evaluating directory_path, {db_name} is replaced by the -database name. This is usefull in multi-tenant with a setup completly -controlled by configuration files.
-The fs_storage addon can be used to replace the storage_backend addon. (It has been designed to be a drop-in replacement for the storage_backend addon). To ease the migration, the fs.storage model @@ -579,7 +545,7 @@
Features
Bugfixes
Bugfixes
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -665,15 +631,15 @@
Do not contact contributors directly about support or help with technical issues.