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/serializer.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'cobbler/serializer.py') diff --git a/cobbler/serializer.py b/cobbler/serializer.py index 15dcd10..bdfbb65 100644 --- a/cobbler/serializer.py +++ b/cobbler/serializer.py @@ -22,6 +22,7 @@ import yaml # Howell-Clark version from cexceptions import * import utils import api as cobbler_api +import modules.serializer_yaml as serializer_yaml MODULE_CACHE = {} @@ -40,19 +41,9 @@ def deserialize(obj,topological=False): storage_module = __get_storage_module(obj.collection_type()) return storage_module.deserialize(obj,topological) - def __get_storage_module(collection_type): - if MODULE_CACHE.has_key(collection_type): - return MODULE_CACHE[collection_type] - config = cobbler_api.BootAPI()._config - settings = config.settings() - storage_module_name = settings.storage_modules.get(collection_type, None) - if not storage_module_name: - raise CX(_("Storage module not set for objects of type %s") % collection_type) - storage_module = config.modules.get(storage_module_name, None) - if not storage_module: - raise CX(_("Storage module %s not present") % storage_module_name) - MODULE_CACHE[collection_type] = storage_module - return storage_module + # FIXME: this is always fixed currently, and should not be. + return cobbler_api.BootAPI().modules["serializer_yaml"] + -- cgit