From 321084391b0115dd2b68b03f367a8f859717d3c6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 5 Sep 2007 18:15:33 -0400 Subject: Further work on interchangeable backends. Rather than keeping the config file format choice in settings (which is something of a Catch-22 situation), this may end up being a config file setting in /etc. Module loaders work and still default to yaml, though I've coded up a sample simple_json serializer that will be functional if users install simple-json. This is just demoware, JSON isn't replacing yaml and is (at least in this case) not as readable because of the way it escapes slashes. This is primarily to enable future work to integrate with other config file formats, such as possibly getting some of the system info from LDAP. Possibly. --- cobbler/module_loader.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cobbler/module_loader.py') diff --git a/cobbler/module_loader.py b/cobbler/module_loader.py index 98ca487..5b27a01 100644 --- a/cobbler/module_loader.py +++ b/cobbler/module_loader.py @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ - import distutils.sysconfig import os import sys @@ -24,7 +23,6 @@ from rhpl.translate import _, N_, textdomain, utf8 plib = distutils.sysconfig.get_python_lib() mod_path="%s/cobbler/modules" % plib -print "DEBUG: adding to python path: %s" % mod_path sys.path.insert(0, mod_path) sys.path.insert(1, "%s/cobbler" % plib) @@ -35,7 +33,6 @@ def load_modules(module_path=mod_path, blacklist=None): mods = {} - print sys.path for fn in filenames: basename = os.path.basename(fn) @@ -50,10 +47,12 @@ def load_modules(module_path=mod_path, blacklist=None): try: blip = __import__("modules.%s" % ( modname), globals(), locals(), [modname]) if not hasattr(blip, "register"): - errmsg = _("%(module_path)s/%(modname)s is not a proper module") - print errmsg % {'module_path': module_path, 'modname':modname} + if not modname.startswith("__init__"): + errmsg = _("%(module_path)s/%(modname)s is not a proper module") + print errmsg % {'module_path': module_path, 'modname':modname} continue - mods[modname] = blip + if blip.register(): + mods[modname] = blip except ImportError, e: print e raise -- cgit