Author: dmeyer
Date: Sat Feb 10 15:20:37 2007
New Revision: 9184
Modified:
trunk/core/src/conf.py
Log:
update xmlconfig
Modified: trunk/core/src/conf.py
==============================================================================
--- trunk/core/src/conf.py (original)
+++ trunk/core/src/conf.py Sat Feb 10 15:20:37 2007
@@ -10,7 +10,7 @@
# the virtual filesystem (util.vfs) to work and this has it's own data
# directory. A different problem is the python encoding handling. It is
# fixed to 'ascii' (you can change it in site.py, but that doesn't always
-# work and is a bad solution).
+# work and is a bad solution).
#
# This module provides some basic settings to solve that problems. It reads
# a config file and stores everything in a struct. It will create necessary
@@ -84,7 +84,7 @@
if os.getuid() > 0:
cfgdir = os.path.expanduser('~/.freevo')
KaaConfig.load(self, os.path.join(cfgdir, '%s.conf' % self._app))
-
+
def _cfg_string(self, prefix, print_desc=True):
cfgfile = '/etc/freevo/%s.conf' % self._app
msg = ''
@@ -93,12 +93,12 @@
msg += '# Please also check the system wide config file\n# %s\n' %
cfgfile
msg += '#
*************************************************************\n\n'
return msg + KaaConfig._cfg_string(self, prefix, print_desc)
-
+
def xmlconfig(configfile, sources):
import kaa.distribution.xmlconfig
import kaa.xml
-
+
def get_parent(tree, name, position=''):
for child in tree:
if child.name == 'group':
@@ -107,14 +107,14 @@
raise RuntimeError('bad tree')
if name.startswith(position + child.getattr('name')):
# print 'deeper'
- return get_parent(child, name, position +
child.getattr('name'))
+ return get_parent(child, name, position +
child.getattr('name') + '.')
for name in name[len(position):].strip(' .').split('.'):
# print 'create', name
node = kaa.xml.Node('group', name=name)
tree.add_child(node)
tree = node
return tree
-
+
hashkey = [ f+str(os.stat(f)[stat.ST_MTIME]) for f in sources ]
hashkey = md5.new(''.join(hashkey)).hexdigest()
@@ -130,15 +130,21 @@
for cfg in sources:
# load cxml file
m = kaa.xml.Document(cfg, 'config')
- # FIXME: ugly hack
if m.getattr('name'):
+ # FIXME: ugly hack
+ # No idea why this is needed, m.unlink() should do the
+ # trick. One day I will understand the memory management
+ # from libxml2.
m._doc._doc = True
+ m.unlink()
if not m.getattr('name').endswith('plugin'):
modules.append(m)
continue
# list of plugins
for plugin in m.children:
if plugin.name == 'group':
+ # unlink node to add later to a new doc
+ plugin.unlink()
name = '%s.%s' % (m.getattr('name'), plugin.getattr('name'))
plugin.setattr('name', name)
modules.append(plugin)
@@ -161,6 +167,7 @@
else:
doc = '<?xml version="1.0"?><config name=""></config>'
tree = kaa.xml.Document(doc, 'config')
+
for m in modules:
parent = get_parent(tree, m.getattr('name'))
if m.hasattr('plugin'):
@@ -170,6 +177,7 @@
parent.add_child(node)
parent.setattr('is_plugin', 'yes')
for child in m:
+ child.unlink()
parent.add_child(child)
if configfile.endswith('.cxml'):
@@ -193,6 +201,14 @@
out.write('\nplugins = [')
find_plugins(tree)
out.write(']\n')
+
+ def find_code(node):
+ for child in node:
+ if child.name == 'code':
+ out.write(kaa.distribution.xmlconfig.format_content(child) +
'\n\n')
+ if child.name == 'group':
+ find_code(child)
+ find_code(tree)
out.close()
@@ -273,7 +289,7 @@
syslogfile = os.path.splitext(os.path.basename(sys.argv[0]))[0]
if syslogfile.startswith('freevo-'):
syslogfile = syslogfile[7:]
-
+
syslogfile = '%s/%s-%s' % (LOGDIR, syslogfile, os.getuid())
handler = RotatingFileHandler(syslogfile, maxBytes=1000000, backupCount=2)
handler.setFormatter(formatter)
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog