webmcp
annotate framework/env/execute/file_path.lua @ 11:d76a8857ba62
Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"
Documentation for added functions is not yet complete.
| author | jbe/bsw |
|---|---|
| date | Fri Feb 12 18:40:22 2010 +0100 (2010-02-12) |
| parents | 9fdfb27f8e67 |
| children | 82cc171e8510 |
| rev | line source |
|---|---|
| jbe/bsw@0 | 1 --[[-- |
| jbe/bsw@0 | 2 status_code = -- status code returned by the executed lua file (a string) |
| jbe/bsw@0 | 3 execute.file_path{ |
| jbe/bsw@0 | 4 file_path = file_path, -- path to a lua source or byte-code file |
| jbe/bsw@0 | 5 id = id, -- id to be returned by param.get_id(...) during execution |
| jbe/bsw@0 | 6 params = params -- parameters to be returned by param.get(...) during execution |
| jbe/bsw@0 | 7 } |
| jbe/bsw@0 | 8 |
| jbe/bsw@0 | 9 This function loads and executes a lua file specified by a given path. If an "id" or "params" are provided, the param.get_id(...) and/or param.get(...) functions will return the provided values during execution. The lua routine must return true, false, nil or a string. In case of true or nil, this function returns the string "ok", in case of false, this function returns "error", otherwise the string returned by the lua routine will be returned by this function as well. |
| jbe/bsw@0 | 10 |
| jbe/bsw@0 | 11 --]]-- |
| jbe/bsw@0 | 12 |
| jbe/bsw@0 | 13 function execute.file_path(args) |
| jbe/bsw@0 | 14 local file_path = args.file_path |
| jbe/bsw@0 | 15 local id = args.id |
| jbe/bsw@0 | 16 local params = args.params |
| jbe/bsw@0 | 17 local func, load_errmsg = loadfile(file_path) |
| jbe/bsw@0 | 18 if not func then |
| jbe/bsw@0 | 19 error('Could not load file "' .. file_path .. '": ' .. load_errmsg) |
| jbe/bsw@0 | 20 end |
| jbe/bsw@0 | 21 if id or params then |
| jbe/bsw@0 | 22 param.exchange(id, params) |
| jbe/bsw@0 | 23 end |
| jbe/bsw@0 | 24 local result = func() |
| jbe/bsw@0 | 25 if result == nil or result == true then |
| jbe/bsw@0 | 26 result = 'ok' |
| jbe/bsw@0 | 27 elseif result == false then |
| jbe/bsw@0 | 28 result = 'error' |
| jbe/bsw@0 | 29 elseif type(result) ~= "string" then |
| jbe/bsw@0 | 30 error("Unexpected type of result: " .. type(result)) |
| jbe/bsw@0 | 31 end |
| jbe/bsw@0 | 32 if id or params then |
| jbe/bsw@0 | 33 param.restore() |
| jbe/bsw@0 | 34 end |
| jbe/bsw@0 | 35 return result |
| jbe/bsw@0 | 36 end |