def registerProfile( self , name , title , description , path , product=None , profile_type=BASE , for_=None ): """ See IProfileRegistry. """ profile_id = self._computeProfileId(name, product) if self._registered.get(profile_id) is not None: raise KeyError, 'Duplicate profile ID: %s' % profile_id info = { 'id' : profile_id , 'title' : title , 'description' : description , 'path' : path , 'product' : product , 'type': profile_type , 'for': for_ } metadata = ProfileMetadata(path, product=product)() # metadata.xml description trumps ZCML description... awkward info.update( metadata ) self._registered[profile_id] = info
def registerProfile(self, name, title, description, path, product=None, profile_type=BASE, for_=None, pre_handler=None, post_handler=None): """ See IProfileRegistry. """ profile_id = self._computeProfileId(name, product) # Typos in pre/post handler should be caught on zope startup. if pre_handler: if (not isinstance(pre_handler, types.FunctionType) and _resolveDottedName(pre_handler) is None): raise ValueError('pre_handler points to non existing ' 'function: %s' % pre_handler) if post_handler: if (not isinstance(post_handler, types.FunctionType) and _resolveDottedName(post_handler) is None): raise ValueError('post_handler points to non existing ' 'function: %s' % post_handler) info = { 'id': profile_id, 'title': title, 'description': description, 'path': path, 'product': product, 'type': profile_type, 'for': for_, 'pre_handler': pre_handler, 'post_handler': post_handler, } metadata = ProfileMetadata(path, product=product)() # metadata.xml description trumps ZCML description... awkward info.update(metadata) existing_info = self._registered.get(profile_id) if existing_info is not None: # If it is the same, we can safely accept it. # This may happen during tests. if info == existing_info: logger.warn('Duplicate profile ID with same info ignored: %s' % profile_id) return raise KeyError('Duplicate profile ID: %s' % profile_id) self._registered[profile_id] = info
def test_parseXML_empty_dependencies(self): # https://bugs.launchpad.net/bugs/255301 metadata = ProfileMetadata( '') parsed = metadata.parseXML(_METADATA_EMPTY_DEPENDENCIES_XML) self.assertEqual(parsed, _METADATA_MAP_EMPTY_DEPENDENCIES)
def test_parseXML(self): metadata = ProfileMetadata( '' ) parsed = metadata.parseXML( _METADATA_XML ) self.assertEqual(parsed, _METADATA_MAP)
def test_parseXML_empty_dependencies(self): # https://bugs.launchpad.net/bugs/255301 metadata = ProfileMetadata('') parsed = metadata.parseXML(_METADATA_EMPTY_DEPENDENCIES_XML) self.assertEqual(parsed, _METADATA_MAP_EMPTY_DEPENDENCIES)
def test_parseXML(self): metadata = ProfileMetadata('') parsed = metadata.parseXML(_METADATA_XML) self.assertEqual(parsed, _METADATA_MAP)