diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2015-02-09 19:44:12 +0200 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2015-02-12 16:32:41 +0200 |
commit | 29282b5a7d43e8b5ce12b0ec4b7a7620c19a67b6 (patch) | |
tree | a8ad7d5343c41950ff9c8f96a55f41a80271f72a /aconf/transaction/base.lua | |
parent | 07a0eb180872401b271de40190603df8f3ab3db2 (diff) | |
download | aconf-29282b5a7d43e8b5ce12b0ec4b7a7620c19a67b6.tar.bz2 aconf-29282b5a7d43e8b5ce12b0ec4b7a7620c19a67b6.tar.xz |
proper escaping for back-end addresses
Diffstat (limited to 'aconf/transaction/base.lua')
-rw-r--r-- | aconf/transaction/base.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/aconf/transaction/base.lua b/aconf/transaction/base.lua index 2bdc963..f40dcca 100644 --- a/aconf/transaction/base.lua +++ b/aconf/transaction/base.lua @@ -1,5 +1,5 @@ --[[ -Copyright (c) 2012-2014 Kaarle Ritvanen +Copyright (c) 2012-2015 Kaarle Ritvanen See LICENSE file for license details --]] @@ -10,7 +10,7 @@ local err = require('aconf.error') local object = require('aconf.object') local class = object.class -local pth = require('aconf.path') +local address = require('aconf.path.address') local copy = require('aconf.util').copy -- TODO each transaction backend (i.e. persistence manager or @@ -130,14 +130,14 @@ function M.Transaction:_set_multiple(mods) for _, mod in ipairs(mods) do local path, value = table.unpack(mod) - local ppath = pth.parent(path) + local ppath = address.parent(path) local parent = self:get(ppath) if parent == nil then parent = {} self:set(ppath, parent) end - local name = pth.name(path) + local name = address.name(path) local old = self:get(path) local is_table = type(value) == 'table' @@ -147,7 +147,9 @@ function M.Transaction:_set_multiple(mods) if type(old) == 'table' then if delete then - for _, child in ipairs(old) do self:set(pth.join(path, child)) end + for _, child in ipairs(old) do + self:set(address.join(path, child)) + end elseif is_table then return elseif #old > 0 then error('Cannot assign a primitive value to non-leaf node '..path) @@ -186,7 +188,7 @@ function M.Transaction:commit() local function insert_add(path) if not handled[path] then - local pp = pth.parent(path) + local pp = address.parent(path) if self.added[pp] then insert_add(pp) end insert(path, self.added[path]) end @@ -197,7 +199,7 @@ function M.Transaction:commit() local value = self.backend:get(path) if type(value) == 'table' then for _, child in ipairs(value) do - local cp = pth.join(path, child) + local cp = address.join(path, child) assert(self.deleted[cp]) insert_del(cp) end |