webmcp

diff framework/env/tempstore/save.lua @ 0:9fdfb27f8e67

Version 1.0.0
author jbe/bsw
date Sun Oct 25 12:00:00 2009 +0100 (2009-10-25)
parents
children 2cb27106aa73
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/framework/env/tempstore/save.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,20 @@
     1.4 +--[[--
     1.5 +key =            -- key to be used with tempstore.pop(...) to regain the stored string
     1.6 +tempstore.save(
     1.7 +  blob           -- string to be stored
     1.8 +)
     1.9 +
    1.10 +This function stores data temporarily. It is used to restore slot information after a 303 HTTP redirect. It returns a key, which can be passed to tempstore.pop(...) to regain the stored data.
    1.11 +
    1.12 +--]]--
    1.13 +
    1.14 +function tempstore.save(blob)
    1.15 +  local key = multirand.string(26, "123456789bcdfghjklmnpqrstvwxyz");
    1.16 +  local filename = encode.file_path(
    1.17 +    request.get_app_basepath(), 'tmp', "tempstore-" .. key .. ".tmp"
    1.18 +  )
    1.19 +  local file = assert(io.open(filename, "w"))
    1.20 +  file:write(blob)
    1.21 +  io.close(file)
    1.22 +  return key
    1.23 +end
    1.24 \ No newline at end of file

Impressum / About Us