[FIX] base: assets' on-disk absolute path computation
Do not use `openerp.http.addons_manifest` dict to find the absolute on-disk path of an asset. This dict is only populated when the first non-xmlrpc http request is made. Avoid crash if this happen by using `get_resource_path` to find ... the resource path we search.
This commit is contained in:
@@ -34,6 +34,7 @@ from openerp.osv import osv, orm, fields
|
||||
from openerp.tools import html_escape as escape
|
||||
from openerp.tools.misc import find_in_path
|
||||
from openerp.tools.translate import _
|
||||
from openerp.modules.module import get_resource_path
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1396,21 +1397,19 @@ class WebAsset(object):
|
||||
|
||||
def stat(self):
|
||||
if not (self.inline or self._filename or self._ir_attach):
|
||||
addon = filter(None, self.url.split('/'))[0]
|
||||
path = filter(None, self.url.split('/'))
|
||||
self._filename = get_resource_path(*path)
|
||||
if self._filename:
|
||||
return
|
||||
try:
|
||||
# Test url against modules static assets
|
||||
mpath = openerp.http.addons_manifest[addon]['addons_path']
|
||||
self._filename = mpath + self.url.replace('/', os.path.sep)
|
||||
# Test url against ir.attachments
|
||||
fields = ['__last_update', 'datas', 'mimetype']
|
||||
domain = [('type', '=', 'binary'), ('url', '=', self.url)]
|
||||
ira = self.registry['ir.attachment']
|
||||
attach = ira.search_read(self.cr, openerp.SUPERUSER_ID, domain, fields, context=self.context)
|
||||
self._ir_attach = attach[0]
|
||||
except Exception:
|
||||
try:
|
||||
# Test url against ir.attachments
|
||||
fields = ['__last_update', 'datas', 'mimetype']
|
||||
domain = [('type', '=', 'binary'), ('url', '=', self.url)]
|
||||
ira = self.registry['ir.attachment']
|
||||
attach = ira.search_read(self.cr, openerp.SUPERUSER_ID, domain, fields, context=self.context)
|
||||
self._ir_attach = attach[0]
|
||||
except Exception:
|
||||
raise AssetNotFound("Could not find %s" % self.name)
|
||||
raise AssetNotFound("Could not find %s" % self.name)
|
||||
|
||||
def to_html(self):
|
||||
raise NotImplementedError()
|
||||
@@ -1619,8 +1618,7 @@ class LessStylesheetAsset(PreprocessedCSS):
|
||||
lessc = find_in_path('lessc')
|
||||
except IOError:
|
||||
lessc = 'lessc'
|
||||
webpath = openerp.http.addons_manifest['web']['addons_path']
|
||||
lesspath = os.path.join(webpath, 'web', 'static', 'lib', 'bootstrap', 'less')
|
||||
lesspath = get_resource_path('web', 'static', 'lib', 'bootstrap', 'less')
|
||||
return [lessc, '-', '--clean-css', '--no-js', '--no-color', '--include-path=%s' % lesspath]
|
||||
|
||||
def rjsmin(script):
|
||||
|
||||
Reference in New Issue
Block a user