webmcp
changeset 28:ea2e8f3a2776
allow webmcp path to be set in cgi script
this allows another script to include the webmcp script when the cwd is not the cgi-bin. the script needs to set the WEBMCP_PATH variable.
this allows another script to include the webmcp script when the cwd is not the cgi-bin. the script needs to set the WEBMCP_PATH variable.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Sun Sep 19 01:36:08 2010 +0200 (2010-09-19) |
parents | 1da1078a87b1 |
children | 0b7e87f2dc91 |
files | framework/cgi-bin/webmcp.lua |
line diff
1.1 --- a/framework/cgi-bin/webmcp.lua Wed Sep 15 02:43:06 2010 +0200 1.2 +++ b/framework/cgi-bin/webmcp.lua Sun Sep 19 01:36:08 2010 +0200 1.3 @@ -3,8 +3,12 @@ 1.4 _WEBMCP_VERSION = "1.1.1" 1.5 1.6 -- include "../lib/" in search path for libraries 1.7 +if not WEBMCP_PATH then 1.8 + WEBMCP_PATH = "../" 1.9 +end 1.10 + 1.11 do 1.12 - package.path = '../lib/?.lua;' .. package.path 1.13 + package.path = WEBMCP_PATH..'lib/?.lua;' .. package.path 1.14 -- find out which file name extension shared libraries have 1.15 local slib_exts = {} 1.16 for ext in string.gmatch(package.cpath, "%?%.([A-Za-z0-9_-]+)") do 1.17 @@ -12,10 +16,10 @@ 1.18 end 1.19 local paths = {} 1.20 for ext in pairs(slib_exts) do 1.21 - paths[#paths+1] = "../accelerator/?." .. ext 1.22 + paths[#paths+1] = WEBMCP_PATH.."accelerator/?." .. ext 1.23 end 1.24 for ext in pairs(slib_exts) do 1.25 - paths[#paths+1] = "../lib/?." .. ext 1.26 + paths[#paths+1] = WEBMCP_PATH.."lib/?." .. ext 1.27 end 1.28 paths[#paths+1] = package.cpath 1.29 package.cpath = table.concat(paths, ";") 1.30 @@ -159,7 +163,7 @@ 1.31 not string.find(key, "^__") 1.32 then 1.33 category = "env" 1.34 - base_path = "../env/" 1.35 + base_path = WEBMCP_PATH.."/env/" 1.36 merge = true 1.37 merge_base_path = app_base .. "/env/" 1.38 file_key = key 1.39 @@ -215,7 +219,7 @@ 1.40 return rawget(self, key) 1.41 end 1.42 install_autoloader(_G, nil, {}) 1.43 - try_exec("../env/__init.lua") 1.44 + try_exec(WEBMCP_PATH.."env/__init.lua") 1.45 end 1.46 1.47 -- interactive console mode