def configure_zca(cls, cache_config): """Configure runtime Zope Component Architecture registry We need a 3 step process to make sure dependencies are met 1. load static package-based ZCML files....standard stuff here. 2. Register the config into the registry (i.e. make it available for lookup) 3. Manually register zcml entries in the config (these entries may be dependent on having the config available for lookup) Args: cache_config: application configuration file name or file object """ # step 1 packages = [sparc.apps.cache] Configure(packages) configure_vocabulary_registry() #step 2 config = ElementTree.parse(cache_config).getroot() for zcml in config.findall('zcml'): zcml_file, package = 'configure.zcml' \ if 'file' not in zcml.attrib else zcml.attrib['file'],\ import_module(zcml.attrib['package']) zope.configuration.xmlconfig.XMLConfig(zcml_file, package)() #step3 alsoProvides(config, IAppElementTreeConfig) sm = getSiteManager() sm.registerUtility(config, IAppElementTreeConfig) return config
def setUp(self): super(SparcCacheRuntimeLayer, self).setUp() configure_vocabulary_registry() parser = getScriptArgumentParser() args = parser.parse_args([ os.path.join(os.path.dirname( sparc.apps.cache.tests.__file__), 'config_test.xml')]) self.cacher = CacheApp(args) self.sm = component.getSiteManager()
def setUp(self): super(SparcCacheLayer, self).setUp() configure_vocabulary_registry()