[IMP] web: allow manifest files to contain remote js/css/qweb files
bzr revid: chs@openerp.com-20130528104352-b1qf79d6bdm8x2ec
This commit is contained in:
parent
10ef73f60b
commit
d086a71131
|
@ -308,7 +308,7 @@ def fs2web(path):
|
|||
"""convert FS path into web path"""
|
||||
return '/'.join(path.split(os.path.sep))
|
||||
|
||||
def manifest_glob(req, extension, addons=None, db=None):
|
||||
def manifest_glob(req, extension, addons=None, db=None, include_remotes=False):
|
||||
if addons is None:
|
||||
addons = module_boot(req, db=db)
|
||||
else:
|
||||
|
@ -322,8 +322,12 @@ def manifest_glob(req, extension, addons=None, db=None):
|
|||
addons_path = os.path.join(manifest['addons_path'], '')[:-1]
|
||||
globlist = manifest.get(extension, [])
|
||||
for pattern in globlist:
|
||||
for path in glob.glob(os.path.normpath(os.path.join(addons_path, addon, pattern))):
|
||||
r.append((path, fs2web(path[len(addons_path):])))
|
||||
if pattern.startswith(('http://', 'https://', '//')):
|
||||
if include_remotes:
|
||||
r.append((None, pattern))
|
||||
else:
|
||||
for path in glob.glob(os.path.normpath(os.path.join(addons_path, addon, pattern))):
|
||||
r.append((path, fs2web(path[len(addons_path):])))
|
||||
return r
|
||||
|
||||
def manifest_list(req, extension, mods=None, db=None):
|
||||
|
@ -331,14 +335,16 @@ def manifest_list(req, extension, mods=None, db=None):
|
|||
mods: a comma separated string listing modules
|
||||
db: a database name (return all installed modules in that database)
|
||||
"""
|
||||
files = manifest_glob(req, extension, addons=mods, db=db, include_remotes=True)
|
||||
if not req.debug:
|
||||
path = '/web/webclient/' + extension
|
||||
if mods is not None:
|
||||
path += '?' + urllib.urlencode({'mods': mods})
|
||||
elif db:
|
||||
path += '?' + urllib.urlencode({'db': db})
|
||||
return [path]
|
||||
files = manifest_glob(req, extension, addons=mods, db=db)
|
||||
|
||||
remotes = [wp for fp, wp in files if fp is None]
|
||||
return [path] + remotes
|
||||
return [wp for _fp, wp in files]
|
||||
|
||||
def get_last_modified(files):
|
||||
|
|
|
@ -1144,7 +1144,8 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
|
|||
}
|
||||
qs = '?' + $.param(params);
|
||||
}
|
||||
return this.prefix + path + qs;
|
||||
var prefix = _.any(['http://', 'https://', '//'], _.bind(_.str.startsWith, null, path)) ? '' : self.prefix;
|
||||
return prefix + path + qs;
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue