lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello.

When I recently was configuring Xavante to run an orbit app I found
that the example configuration posted on the site doesn't work with
the current Xavante API.

The code mentioned is:

    { -- cgiluahandler example
      match = {"%.lp$", "%.lp/.*$", "%.lua$", "%.lua/.*$" },
      with = xavante.cgiluahandler.makeHandler (webDir)
    },

which should be

    { -- cgiluahandler example
      match = {"%.lp$", "%.lp/.*$", "%.lua$", "%.lua/.*$" },
      with = xavante.cgiluahandler.makeHandler (webDir, {})
    },

The error I got:

...m/.luarocks/share/lua/5.1//xavante/cgiluahandler.lua:37: attempt to
index local 'params' (a nil value)

With the definition of the function that the line belongs to of:

function makeHandler (diskpath, params)
   params = setmetatable({ modname = params.modname or "wsapi.sapi",
bootstrap = bootstrap }, { __index = params or {} })
   local sapi_loader = wsapi.common.make_isolated_launcher(params)
   return wsapi.xavante.makeHandler(sapi_loader, nil, diskpath)
end

makes me suggest to write it as:

function makeHandler (diskpath, params)
   params = params or {}
   params = setmetatable({ modname = params.modname or "wsapi.sapi",
bootstrap = bootstrap }, { __index = params or {} })
   local sapi_loader = wsapi.common.make_isolated_launcher(params)
   return wsapi.xavante.makeHandler(sapi_loader, nil, diskpath)
end

Or would this be considered bad coding practice?

gr,

Tom Wieland