entities/schemaobjs.py
changeset 6944 0cf10429ad39
parent 6912 b61b844f2dad
child 7370 96923d75610b
--- a/entities/schemaobjs.py	Mon Feb 07 15:13:05 2011 +0100
+++ b/entities/schemaobjs.py	Mon Feb 07 18:19:36 2011 +0100
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -19,12 +19,7 @@
 
 __docformat__ = "restructuredtext en"
 
-import re
-from socket import gethostname
-
 from logilab.common.decorators import cached
-from logilab.common.textutils import text_to_dict
-from logilab.common.configuration import OptionError
 
 from yams.schema import role_name
 
@@ -34,58 +29,6 @@
 from cubicweb.entities import AnyEntity, fetch_config
 
 
-class _CWSourceCfgMixIn(object):
-    @property
-    def dictconfig(self):
-        return self.config and text_to_dict(self.config) or {}
-
-    def update_config(self, skip_unknown=False, **config):
-        from cubicweb.server import SOURCE_TYPES
-        from cubicweb.server.serverconfig import (SourceConfiguration,
-                                                  generate_source_config)
-        cfg = self.dictconfig
-        cfg.update(config)
-        options = SOURCE_TYPES[self.type].options
-        sconfig = SourceConfiguration(self._cw.vreg.config, options=options)
-        for opt, val in cfg.iteritems():
-            try:
-                sconfig.set_option(opt, val)
-            except OptionError:
-                if skip_unknown:
-                    continue
-                raise
-        cfgstr = unicode(generate_source_config(sconfig), self._cw.encoding)
-        self.set_attributes(config=cfgstr)
-
-
-class CWSource(_CWSourceCfgMixIn, AnyEntity):
-    __regid__ = 'CWSource'
-    fetch_attrs, fetch_order = fetch_config(['name', 'type'])
-
-    @property
-    def host_config(self):
-        dictconfig = self.dictconfig
-        host = gethostname()
-        for hostcfg in self.host_configs:
-            if hostcfg.match(host):
-                self.info('matching host config %s for source %s',
-                          hostcfg.match_host, self.name)
-                dictconfig.update(hostcfg.dictconfig)
-        return dictconfig
-
-    @property
-    def host_configs(self):
-        return self.reverse_cw_host_config_of
-
-
-class CWSourceHostConfig(_CWSourceCfgMixIn, AnyEntity):
-    __regid__ = 'CWSourceHostConfig'
-    fetch_attrs, fetch_order = fetch_config(['match_host', 'config'])
-
-    def match(self, hostname):
-        return re.match(self.match_host, hostname)
-
-
 class CWEType(AnyEntity):
     __regid__ = 'CWEType'
     fetch_attrs, fetch_order = fetch_config(['name'])