webmcp
annotate framework/env/param/get.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 | 32ec28229bb5 |
| rev | line source |
|---|---|
| jbe/bsw@0 | 1 --[[-- |
| jbe/bsw@0 | 2 value = -- value of the parameter casted to the chosen param_type |
| jbe/bsw@0 | 3 param.get( |
| jbe/bsw@0 | 4 key, -- name of the parameter |
| jbe/bsw@0 | 5 param_type -- desired type of the returned value |
| jbe/bsw@0 | 6 ) |
| jbe/bsw@0 | 7 |
| jbe/bsw@0 | 8 Either a GET or POST request parameter is returned by this function, or if param.exchange(...) was called before, one of the exchanged parameters is returned. You can specify which type the returned value shall have. If an external request parameter was used and there is another GET or POST parameter with the same name but a "__format" suffix, the parser with the name of the specified format will be automatically used to parse and convert the input value. |
| jbe/bsw@0 | 9 |
| jbe/bsw@0 | 10 --]]-- |
| jbe/bsw@0 | 11 |
| jbe/bsw@0 | 12 function param.get(key, param_type) |
| jbe/bsw@0 | 13 local param_type = param_type or atom.string |
| jbe/bsw@0 | 14 if param._exchanged then |
| jbe/bsw@0 | 15 local value = param._exchanged.params[key] |
| jbe/bsw@0 | 16 if value ~= nil and not atom.has_type(value, param_type) then |
| jbe/bsw@0 | 17 error("Parameter has unexpected type.") |
| jbe/bsw@0 | 18 end |
| jbe/bsw@0 | 19 return value |
| jbe/bsw@0 | 20 else |
| jbe/bsw@0 | 21 local str = cgi.params[key] |
| jbe/bsw@0 | 22 local format_info = cgi.params[key .. "__format"] |
| jbe/bsw@0 | 23 if not str then |
| jbe/bsw@0 | 24 if not format_info then |
| jbe/bsw@0 | 25 return nil |
| jbe/bsw@0 | 26 end |
| jbe/bsw@0 | 27 str = "" |
| jbe/bsw@0 | 28 end |
| jbe/bsw@0 | 29 return param._get_parser(format_info, param_type)(str) |
| jbe/bsw@0 | 30 end |
| jbe/bsw@0 | 31 end |