[trunk] Addons path incorrect algorithm to load files.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Incomplete
|
Medium
|
OpenERP's Framework R&D |
Bug Description
Hello.
This error took from us some time to solve, but i think it is important.
When you define the first addons base in a folder called addons and in the same directory that your other addons branches i mean:
/working/
/working/
/working/
/working/
And you start server with addons path:
/working/
When the second addons is taken in account the algorithm already in server brakes telling you can not load __opener__.py server that dont existe, the traceback looks like this:
2012-11-08 15:08:29,685 27703 ERROR tgaby openerp: Failed to initialize database `tgaby`.
Traceback (most recent call last):
File "openerp-server", line 94, in preload_registry
db, registry = openerp.
File "/home/
registry = RegistryManager
File "/home/
update_module, pooljobs)
File "/home/
openerp.
File "/home/
processed = load_marked_
File "/home/
graph.
File "/home/
info = openerp.
File "/home/
f = tools.file_
File "/home/
return _fileopen(name, mode=mode, basedir=base, pathinfo=pathinfo, basename=basename)
File "/home/
raise IOError('File not found: %s' % basename)
IOError: File not found: /home/nhomar/
then the error have to parts:
1.- The file /home/nhomar/
here is where the first diff comes out:
=== modified file 'openerp/
--- openerp/
+++ openerp/
@@ -218,7 +218,7 @@
# Not found
if name.endswith(
raise IOError('Report %r doesn\'t exist or deleted' % basename)
- raise IOError('File not found: %s' % basename)
+ raise IOError('File not found: %s' % name)
#-----
We must use "name" (modified name that is realle used to find __openerp__.py file) and not "basename" (original name first used to compare if it is base module or not).
2.- The second part is "Why the file is bad named?" if all folders worked __exactly__ in this naming convention on 6.1?:
The reason is the commit 4420 done for Stephan:
The diff of this revno 4420 :
http://
For some reason, he replace basename = name with a new return, imho it was not necesary, but bte, just changing veriable it works very well.
3rd. Part: Bad Algorithm:.
The algorithm to find the path that is in misc.py file IMHO is incorrect, because compare "String of path" and not "Path itself" to decide if it is or not base-addons.
You can see:
line ~139 openerp/
for root in adps + [rtp]:
if name.startswith
What is wrong, is that we are using 'startswith' instead a path tool to compare and strip folders name, the in case you use a second folder with a second list of addons it is striping incorrectly, and giving an incorrect message (corrected in point [2])
Printing root, adps and
[u'/home/
/home/nhomar/
/home/nhomar/
In my case as you can see:
When you make name.startswith
/home/nhomar/
/home/nhomar/
This case will pass and:
name = name[len(base) + 1:]
will become:
vauxoo/
what is incorrect, because this folder doesn't exists.
Solution:
I will make an MP, solving the problem with 'os' library, soon in touch
Related branches
- Olivier Dony (Odoo): Pending requested
- Raphaël Valyi - http://www.akretion.com: Pending requested
- OpenERP R&D Team: Pending (approve) requested
-
Diff: 26 lines (+5/-3)1 file modifiedopenerp/tools/misc.py (+5/-3)
description: | updated |
Hello,
I fix the issue, in this way, we avoid use string features without os.path verifications.
Regards/.