Commit Graph
15 Commits
Author SHA1 Message Date
Xavier Morel d634fbd9ab [FIX] P3: reorder finders in meta_path
So that was a fun one: mock.patch calls would regularly fail refusing
to find the addon in odoo.addon (e.g. essentially getattr(odoo.addon,
'account_budget' deep within the bowels of mock).

Turns out the answer is that our import hooks would not be used for
many imports: while in Python 2, sys.meta_path is empty and the
default finders are run after all meta_path finders fail as noted by
the documentation[0].

However when the import system was rewritten in Python 3.3[1]
meta_path was "despecialised" and the default finders were moved to
meta_path rather than be a hidden part of the import machinery[2]:

> sys.meta_path and sys.path_hooks now store all of the meta path
> finders and path entry hooks used by import. Previously the finders
> were implicit and hidden within the C code of import instead of
> being directly exposed.

The result of this change is that ``sys.meta_path.append`` means the
default finders should take priority and the custom ones should be
fallback. This is the exact opposite of what we want.

Fix issue by ``sys.meta_path.insert``-ing our finders at the start of
the path rather than appending them at the end. This should change
nothing in Python 2 but seems to fix the issue in P3.

[0]
https://docs.python.org/2/library/sys.html?highlight=meta_path#sys.meta_path
[1] https://docs.python.org/3/whatsnew/3.3.html#importlib
[2] https://docs.python.org/3/whatsnew/3.3.html#visible-changes
2017-08-19 02:34:24 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
xmo-odoo 2e6a589f41 [FIX] builtins removed from Python 3
* Reverse wrapper courtesy of @rco-odoo's original P3 branch
* thin compat module stripped down from werkzeug (to augment as needed)

issue 8530
2017-04-27 13:59:33 +02:00
Christophe Simonis e92ae40d71 [MERGE] forward port branch saas-15 up to b0992d082d 2017-04-14 13:32:15 +02:00
Raphael Collet 00e169c05a [FIX] modules: do not log warnings for studio_customization 2017-04-13 12:17:05 +02:00
Xavier Morel 3979f6802e [#8530] convert exception handlers to except..as syntax
Futurize fixers:
* lib2to3.fixes.fix_except
2017-04-11 14:53:29 +02:00
Olivier Dony 8235f03f56 [FIX] module: allow disabling 1-click install
As discussed on issue #15225, it should be possible for system administrators
to disable the 1-click installation system.
The plan is to disable the feature by default, but make it relatively easy
to turn on when it is explicitly desired.

1. At the moment we cannot guarantee that all Apps published on the Odoo Apps
   Store are safe. And it is a security risk to let end-users deploy Python
   code on their Odoo servers without requiring any review/deployment by a
   competent system administrator.
   We will work on improving the validation process of the Store, but this
   will require time, and won't probably be a 100% safe process in any case.
2. The one-click install feature is however really useful to help
   non-technical users install Apps, as long as the feature has been
   explicitly allowed by the system administrator. This is a common feature
   in other software suites as well. So we'd like to keep it as an opt-in
   feature.
3. Administrators of multi-tenant servers, cloud hosting services, etc.
   understandably expect to be able to turn off the feature for
   security/control reasons.
4. By turning off the feature by default, but still exposing it in the UI,
   we keep it *discoverable* for users. The error message should be
   helpful to direct users to their sysadmins.
5. By using the permissions of the download folder as a flag for turning
   off the feature, we avoid introducing an extra server parameter.
   The folder is still created (read-only) by default, for the sole purpose
   of making it easier to locate.

Fixes #15225
2017-01-27 13:56:05 +01:00
angelfentanez e965ac14dd [FIX] modules: add missing parameter to find_module
AddonsImportHook's find_module method to follow PEP302 by setting None as
default for the path parameter
Similar to edeb5a8c

Fixes #14087
Closes #14088
2016-11-22 14:51:05 +01:00
=?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= 389c2ba97b [REF] packaging: make odoo a namespaced package
by auto-extending addons path with odoo.addons.__path__.

This patch also introduce
  * an explicit declaration of odoo.addons as a namespace package
    This is necessary because the standard way of declaring namespace
    packages in setup.py does not work as long as odoo/__init__.py
    contains code.
  * a more reliable way to find odoo root path.
2016-09-30 12:05:49 +02:00
Christophe Simonis a256e1ed34 [FIX] core: adpat 9874892b9 to multiple manifest files 2016-09-16 11:34:22 +02:00
Christophe Simonis f4fc3985b6 [MERGE] forward port branch saas-12 up to 10cde43 2016-09-16 11:03:50 +02:00
Olivier Dony 4339196e52 [IMP] support v10 manifest file naming convention
- As of v10, manifest files should be named `__manifest__.py`
- For backwards-compatibility, __openerp__.py manifest files
  will still be supported for the time being
- Limited refactoring, to add support for the 2 different
  naming conventions
- All textual references to __openerp_.py updated in
  documentation and examples
2016-09-05 11:57:50 +02:00
Olivier Dony c0566b2896 [IMP] module: parse manifest files with literal_eval
Manifest files are literal Python dictionaries, and
aren't supposed to contain expressions that require
a full-fledged eval.
`literal_eval` is therefore sufficient *and* safer.

This parsing method was already used when listing addons
during startup of the Root controller (http.py, load_addons())
2016-09-05 11:57:50 +02:00
Raphael Collet 4a700d0ad9 [FIX] odoo: rename imports and adapt import hooks 2016-09-02 17:28:12 +02:00
Raphael Collet 9e64f9f951 [REF] openerp: move openerp to odoo 2016-09-02 17:28:12 +02:00