require "proto" require "lfs" require "umake" require "upath" -- Metaacls: path meta user call constr -- #metaacl# /_uwiki/ type Admin new recursive -- #metaacl# /_uwiki/ requires Admin new recursive -- #metaacl# /_uwiki/ requires Admin delete recursive -- #metaacl# /_uwiki/ generates Admin new recursive -- #metaacl# /_uwiki/ generates Admin delete recursive local metaacl_import = Object:clone() function metaacl_import:invoke(session, request, response) response:write("
")

    local scm = session:scm_load(session.path)
    local thefile = scm:enter(session.path)

    assert(upath.exists(thefile), "EEXIST:File does not exist")

    -- check that file is an action
    local isaction = false
    for _,typename in pairs(session:meta_get(session.path, "type", "type")) do
        if typename == 'lua_action' then
            isaction = true
        end
    end
    assert(isaction, "ERANGE:not an action")

    local action = thefile:match("([^/]*)$")

    local cleared = false

    -- parse metaacl comments in
    for line in io.lines(thefile) do
        local path, meta, user, call, constr = line:match("#metaacl%# (%S+) (%S+) (%S+) (%S+) (%S+)")

        if constr then
            if not cleared then
                session:metaacl_clear(action)
                cleared = true
            end

            session:metaacl_new(path, meta, user, action, call, constr)
        end
    end

    response:write("
") scm:leave() session:done() return response:finish() end return metaacl_import -- Local Variables: -- mode: lua -- lua-indent-level: 4 -- indent-tabs-mode: nil -- End: