Skip to content
Snippets Groups Projects
Commit e4423172 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Replace the function get_extjs_path by get_plugin_path.

parent a3f6f096
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment