diff --git a/modules/plugin_dbui/__init__.py b/modules/plugin_dbui/__init__.py index da8f052fb5b90ae30ab884dcda3b07b0e90d55d4..1a363393e59396ba67feb93f7ac2632b87fa729c 100644 --- a/modules/plugin_dbui/__init__.py +++ b/modules/plugin_dbui/__init__.py @@ -9,9 +9,9 @@ from fieldmodifier import FieldModifier from foreignfield import ForeignField from formmodifier import configure_forms, FormModifier from gridmodifier import configure_grids, GridModifier -from helper import (get_extjs_path, - get_js_files, - get_language, +from helper import (get_js_files, + get_language, + get_plugin_path, get_reference_paths, get_script_path) from mapper import map_default, map_tabpanel diff --git a/modules/plugin_dbui/helper.py b/modules/plugin_dbui/helper.py index 4000810df338b6fbd2dce9baaab940e902bf9b79..f40bddf474df4c9c931ff20cae2a6a036975face 100644 --- a/modules/plugin_dbui/helper.py +++ b/modules/plugin_dbui/helper.py @@ -52,28 +52,34 @@ def encode_field(*args): return ''.join([el[0].upper()+el[1:].lower() for el in args if len(el)]) -def get_extjs_path(environment): - """Helper function returning the local path of the ExtJS plugin. - It is defined with respect to the application directory. - +def get_plugin_path(environment, plugin_name): + """Helper function returning the local path of the plugin name: + plugin_extjs, plugin_mathjax, ... + The local path defined with respect to the application directory. + + The function return the path of the first directory starting with + plugin_name. It is useful to handle plugin with a version number + like plugin_extjs_3.3.2. + The dictionary environment contains the keys request, response, session, plugins, .... Raise the exception HTTP(500) if the plugin is not found. """ - application = environment['request'].application - - # check the absolute path on the server - server_path = os.path.join('applications', application) - path = os.path.join(server_path, 'static', 'plugin_extjs') - if not os.path.exists(path): - raise HTTP(500, 'The plugin ExtJS is not install !') + server_path, client_path = get_reference_paths(environment) - # return the local path - return os.path.join(os.path.sep, application, 'static', 'plugin_extjs') + # look for the full name of the plugin directory + p_static = os.path.join(server_path, 'static') + for el in os.listdir(p_static): + if os.path.isdir(os.path.join(p_static, el)): + if el.startswith(plugin_name): + return os.path.join(client_path, 'static', el) + # Nothing found + raise HTTP(500, 'The plugin %s is not install !' % plugin_name) + def get_js_files(server_path, client_path, directory): """Return a list of javascript files stored in the directory. The alphabetic order is preserved.