|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21585/root/usr/lib64/python2.4/site-packages/ |
Upload File : |
#!/usr/bin/python
## Copyright (C) 2000 Red Hat, Inc.
## Copyright (C) 2000 Crutcher Dunnavant <crutcher@redhat.com>,
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
from pyalchemist import *
class SubspaceEditor:
__dynamic_ctx = None
__dynamic_box = None
__static_ctx = None
def __init__( self,
namespace = None,
subspace = "config",
namespace_cfg = None):
self.subspace = subspace
if (namespace != None):
# extract the subspace_cfg from the system config
swb = readNspCtx(namespace = namespace)
self.namespace_cfg = getNspCfg(
context = swb,
namespace = namespace)
elif (namespace_cfg != None):
if (type(namespace_cfg) == AdmListType):
self.namespace_cfg = namespace_cfg
else:
raise ValueError, \
"namespace_cfg not an AdmListType element"
else:
raise TypeError, \
"expected namespace or namespace_cfg, found neither"
self.subspace_cfg = getSubspCfg(namespace_cfg = self.namespace_cfg,
subspace = self.subspace)
def editReadBox(self, editbox):
# we find out how many boxes are before the one we want to edit
editpos = \
self.subspace_cfg["/read_policy/read_set"][editbox].pos
if editpos != 0:
# Construct the preview context, that we wont edit
# this context represents the tree as it will be when
# the box we are editing merges into it, so that we
# can be a bit clever about how we edit, if we want to
# We do NOT make this call if editpos == 0,
# because depth = 0 means 'all'
s_ctx = readNsp(namespace_cfg = self.namespace_cfg,
subspace = self.subspace,
depth = editpos)
else:
s_ctx = None
# set up the box interface
d_box = getBox( subspace_cfg = self.subspace_cfg,
box_name = editbox)
d_ctx = d_box.read()
return {"static_context" : s_ctx,
"dynamic_box" : d_box,
"dynamic_context" : d_ctx}