From 65b410ba7dcd29a11b594fa981b5be9a8405b7ea Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Wed, 2 Mar 2011 19:49:08 +0000 Subject: [PATCH] Polish the documentation. Raise an HTTP exception when a script does not exist. --- modules/plugin_dbui/helper.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/plugin_dbui/helper.py b/modules/plugin_dbui/helper.py index 0c59b758..a50353e4 100644 --- a/modules/plugin_dbui/helper.py +++ b/modules/plugin_dbui/helper.py @@ -55,6 +55,9 @@ def encode_field(*args): def get_extjs_path(environment): """Helper function returning the local path of the ExtJS plugin. It is defined with respect to the application directory. + + The dictionary environment contains the keys request, response, + session, plugins, .... Raise the exception HTTP(500) if the plugin is not found. @@ -73,19 +76,25 @@ def get_extjs_path(environment): def get_reference_paths(environment): """Helper method returning a tuple with the server and the local paths. + + The dictionary environment contains the keys request, response, + session, plugins, .... """ request = environment['request'] server_path = os.path.join('applications', request.application) - local_path = os.path.join(os.path.sep, request.application) + client_path = os.path.join(os.path.sep, request.application) - return (server_path, local_path) + return (server_path, client_path) def get_script_path(environment): """Helper method returning the local path of the main script. the local path is defined with respect to the application directory. + + The dictionary environment contains the keys request, response, + session, plugins, .... The script name can be set via the url. @@ -108,19 +117,23 @@ def get_script_path(environment): script_dir = os.path.join(server_path, plugins.dbui.script_path) if script not in os.listdir(script_dir): - return 'Request script "%s" does not exist !!!' % script + raise HTTP(500, 'Request script "%s" does not exist !!!' % script) +# return 'Request script "%s" does not exist !!!' % script script = os.path.join(base, plugins.dbui.script_path, script) return script -def get_language(T): +def get_language(environment): """Helper method returning the application language. The result is compliant with the ExtJS file name. + + The dictionary environment contains the keys request, response, + session, plugins, .... """ - lg = T.accepted_language + lg = environment['T'].accepted_language if len(lg) == 5 and lg[0:2] == lg[3:5]: lg = lg[0:2] -- GitLab