webmcp
annotate framework/env/request/set_allowed_json_request_slots.lua @ 12:f3d3203cd2e4
Documentation for partial loading added
NOTE: Previous changeset d76a8857ba62 also modified behaviour of ui.script: Scripts containing "]]>" are now rejected to avoid ambiguities
NOTE: Previous changeset d76a8857ba62 also modified behaviour of ui.script: Scripts containing "]]>" are now rejected to avoid ambiguities
| author | jbe |
|---|---|
| date | Fri Feb 19 16:43:29 2010 +0100 (2010-02-19) |
| parents | 985024b16520 |
| children | 944642a3e488 |
| rev | line source |
|---|---|
| jbe@1 | 1 --[[-- |
| jbe@1 | 2 request.set_allowed_json_request_slots( |
| jbe@1 | 3 slot_idents -- list of names of slots which can be requested in JSON format |
| jbe@1 | 4 ) |
| jbe@1 | 5 |
| jbe@1 | 6 This function enables JSON requests. The given list of names of slots selects, which slots may be requestd in JSON format (without layout). |
| jbe@1 | 7 |
| jbe@1 | 8 --]]-- |
| jbe@1 | 9 |
| jbe@1 | 10 function request.set_allowed_json_request_slots(slot_idents) |
| jbe@1 | 11 local hash = {} |
| jbe@1 | 12 for idx, slot_ident in ipairs(slot_idents) do |
| jbe@1 | 13 hash[slot_ident] = true |
| jbe@1 | 14 end |
| jbe@1 | 15 if cgi.params["_webmcp_json_slots[]"] then |
| jbe@1 | 16 for idx, slot_ident in ipairs(cgi.params["_webmcp_json_slots[]"]) do |
| jbe@1 | 17 if not hash[slot_ident] then |
| jbe@1 | 18 error('Requesting slot "' .. slot_ident .. '" is forbidden.') |
| jbe@1 | 19 end |
| jbe@1 | 20 end |
| jbe@1 | 21 end |
| jbe@1 | 22 request._json_requests_allowed = true |
| jbe@1 | 23 end |