Skip to content
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

[16.0][MIG] base_binary_url_import: Migration to 16.0 #618

Merged
merged 4 commits into from
Jun 28, 2023

Conversation

lehoangan
Copy link
Contributor

@lehoangan lehoangan commented Mar 20, 2023

Dependency on old rfc6266-parser removed, and replaced by a simple function relying on werkzeug

@lehoangan lehoangan force-pushed the 16.0-mig-base_binary_url_import branch 8 times, most recently from 0a2c0d2 to 8514e17 Compare March 21, 2023 03:19
@lehoangan lehoangan changed the title [16.0][MIG] base_binary_url_import [16.0][MIG] base_binary_url_import: Migration to 16.0 Mar 21, 2023
@lehoangan lehoangan force-pushed the 16.0-mig-base_binary_url_import branch from 2b0632b to b96dcd1 Compare March 21, 2023 04:01
@lehoangan lehoangan mentioned this pull request Mar 23, 2023
26 tasks
else:
raise UserError(_("Identifier %s is not an Integer or XMLID") % target_id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else:
raise UserError(_("Identifier %s is not an Integer or XMLID") % target_id)
raise UserError(_("Identifier %s is not an Integer or XMLID") % target_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to modify as your suggestion

Copy link

@StephaneMangin StephaneMangin Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved it anyway ;)

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the OCA we don't consider usefull to add license in __init__.py

@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

# from . import tes_binary_url_import

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the test deactivated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it. I don't have this test in the module

Copy link
Contributor

@grindtildeath grindtildeath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the mig. But what's the reason behind not keeping the test module and rewriting everything?

Comment on lines 279 to 289
def _import_content_from_url(self, request_session):
def get_filename(respone):
content_disposition = respone.headers.get("Content-Disposition")
if content_disposition:
param, options = werkzeug.http.parse_options_header(content_disposition)
if param == "attachment" and options.get("filename"):
return options.get("filename")

path = urlparse(respone.url).path
name = path[path.rfind("/") + 1 :]
return name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we would like to maintain such code when an external library is doing it for us 😕

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @grindtildeath

  • rfc6266-parser depends on LEPL, which is not compatible with python 3.6+:
    import rfc6266_parser
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/rfc6266_parser.py", line 14, in <module>
    from lepl import (
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/__init__.py", line 113, in <module>
    from lepl.contrib.matchers import SmartSeparator2
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/contrib/matchers.py", line 41, in <module>
    from lepl.matchers.derived import Optional
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/matchers/derived.py", line 38, in <module>
    from lepl.matchers.combine import And, DepthFirst, BreadthFirst, \
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/matchers/combine.py", line 45, in <module>
    from lepl.matchers.core import Literal
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/matchers/core.py", line 45, in <module>
    from lepl.matchers.support import OperatorMatcher, coerce_, \
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/matchers/support.py", line 37, in <module>
    from lepl.core.config import ParserMixin
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/core/config.py", line 40, in <module>
    from lepl.stream.factory import DEFAULT_STREAM_FACTORY
  File "/home/nils/.local/share/virtualenvs/venv-odoo16/lib/python3.10/site-packages/lepl/stream/factory.py", line 31, in <module>
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/home/nils/.pythonz/pythons/CPython-3.10.10/lib/python3.10/collections/__init__.py)
  • rfc6266-parser was forked to make it compatible with python 3.6+ and published as uc-rfc6266-parser;
  • BUT the way to make it compatible with python 3.6+ was to drop LEPL in favor of werkzeug, pinned to 1.0.1, which makes it incompatible with odoo, that also needs a specific werkzeug version
  • a PR to unpin werkzeug exists, but the format git+https://github.com/genme/python-rfc6266-parser.git@4af2f324be019bdd6ca6543bc36d1d031ca609d5#egg=rfc6266-parser is not compatible with odoo's external_dependencies manifest key;
  • as an alternative, we could have published our own fork on pypi, BUT at that point we just decided to drop the dependency in favor of a simple function based on werkzeug
  • NOW that we're having a second look, we just noticed that there is another quite recent fork from the original rfc6266 that took the option of using pyparsing instead of LEPL: it could do the job, we'll look into it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nilshamerlinck Thank you very much for the explanation. 👍

IMO we should better use a lib as long as it does the job, but if we cannot let's just keep the function in the module, but move it to a dedicated rfc6266_parser.py file outside of the models folder.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyrfc6266 does the job, so custom function has been removed; test module has been included also

@lehoangan lehoangan force-pushed the 16.0-mig-base_binary_url_import branch 2 times, most recently from b22acd3 to daf98a5 Compare April 25, 2023 04:15
@lehoangan lehoangan force-pushed the 16.0-mig-base_binary_url_import branch from daf98a5 to 0eb1997 Compare April 25, 2023 04:18
@gurneyalex
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-618-by-gurneyalex-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit cc5eec1 into OCA:16.0 Jun 28, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at b771eeb. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants