* Introducing LuCI HTTPD as testing environment
[project/luci.git] / libs / web / luasrc / dispatcher.lua
index 8516c6f..6017874 100644 (file)
@@ -29,11 +29,6 @@ require("luci.http")
 require("luci.sys")
 require("luci.fs")
 
--- Dirty OpenWRT fix
-if (os.time() < 1000000000) then
-       os.execute('date -s '..os.date('%m%d%H%M%Y', luci.fs.mtime(luci.sys.libpath() .. "/dispatcher.lua"))..' > /dev/null 2>&1')
-end
-
 context = luci.util.threadlocal()
 
 -- Index table
@@ -89,7 +84,7 @@ end
 function httpdispatch(request)
        luci.http.context.request = request
        context.request = {}
-       local pathinfo = request.env.PATH_INFO or ""
+       local pathinfo = request:getenv("PATH_INFO") or ""
 
        for node in pathinfo:gmatch("[^/]+") do
                table.insert(context.request, node)
@@ -272,7 +267,7 @@ function createtree()
        luci.i18n.loadc("default")
        
        local scope = luci.util.clone(_G)
-       for k,v in pairs(_M) do
+       for k,v in pairs(luci.dispatcher) do
                if type(v) == "function" then
                        scope[k] = v
                end
@@ -281,10 +276,10 @@ function createtree()
        for k, v in pairs(index) do
                scope._NAME = k
                setfenv(v, scope)
-               
+
                local stat, err = luci.util.copcall(v)
                if not stat then
-                       error500(err)   
+                       error500("createtree failed: " .. k .. ": " .. err)
                        os.exit(1)
                end
        end