def check_unique_method_keys(self): keys = {} for s in self.services: for mdesc in s.public_methods.values(): other_mdesc = keys.get(mdesc.internal_key, None) if other_mdesc is not None: logger.error( 'Methods keys for "%s.%s" and "%s.%s" conflict', mdesc.function.__module__, six.get_function_name(mdesc.function), other_mdesc.function.__module__, six.get_function_name(other_mdesc.function)) raise MethodAlreadyExistsError(mdesc.internal_key) keys[mdesc.internal_key] = mdesc
def internal_key(self): """The internal function identifier in '{namespace}name' form.""" return '{%s}%s%s' % ( self.service_class.get_internal_key(), six.get_function_name(self.function), self.internal_key_suffix)
def process_method(self, s, method): assert isinstance(method, MethodDescriptor) method_key = u'{%s}%s' % (self.app.tns, method.name) if issubclass(s, ComplexModelBase): method_object_name = method.name.split('.', 1)[0] if s.get_type_name() != method_object_name: method_key = u'{%s}%s.%s' % (self.app.tns, s.get_type_name(), method.name) key = method.gen_interface_key(s) if key in self.method_id_map: c = self.method_id_map[key].parent_class if c is None: pass elif c is s: pass elif c.__orig__ is None: assert c is s.__orig__, "%r.%s conflicts with %r.%s" % \ (c, key, s.__orig__, key) elif s.__orig__ is None: assert c.__orig__ is s, "%r.%s conflicts with %r.%s" % \ (c.__orig__, key, s, key) else: assert c.__orig__ is s.__orig__, "%r.%s conflicts with %r.%s" % \ (c.__orig__, key, s.__orig__, key) return logger.debug(' adding method %s.%s to match %r tag.', method.get_owner_name(s), six.get_function_name(method.function), method_key) self.method_id_map[key] = method val = self.service_method_map.get(method_key, None) if val is None: val = self.service_method_map[method_key] = [] if len(val) == 0: val.append(method) elif method.aux is not None: val.append(method) elif val[0].aux is not None: val.insert(method, 0) else: om = val[0] os = om.service_class if os is None: os = om.parent_class raise ValueError("\nThe message %r defined in both '%s.%s'" " and '%s.%s'" % (method.name, s.__module__, s.__name__, os.__module__, os.__name__))
def process_method(self, s, method): assert isinstance(method, MethodDescriptor) method_key = '{%s}%s' % (self.app.tns, method.name) if issubclass(s, ComplexModelBase) and method.in_message_name_override: method_object_name = method.name.split('.', 1)[0] if s.get_type_name() != method_object_name: method_key = '{%s}%s' % (self.app.tns, method.gen_interface_key(s)) key = method.gen_interface_key(s) if key in self.method_id_map: c = self.method_id_map[key].parent_class if c is None: pass elif c is s: pass elif c.__orig__ is None: assert c is s.__orig__, "%r.%s conflicts with %r.%s" % \ (c, key, s.__orig__, key) elif s.__orig__ is None: assert c.__orig__ is s, "%r.%s conflicts with %r.%s" % \ (c.__orig__, key, s, key) else: assert c.__orig__ is s.__orig__, "%r.%s conflicts with %r.%s" % \ (c.__orig__, key, s.__orig__, key) return logger.debug(' adding method %s.%s to match %r tag.', method.get_owner_name(s), six.get_function_name(method.function), method_key) self.method_id_map[key] = method val = self.service_method_map.get(method_key, None) if val is None: val = self.service_method_map[method_key] = [] if len(val) == 0: val.append(method) elif method.aux is not None: val.append(method) elif val[0].aux is not None: val.insert(method, 0) else: om = val[0] os = om.service_class if os is None: os = om.parent_class raise ValueError("\nThe message %r defined in both '%s.%s'" " and '%s.%s'" % (method.name, s.__module__, s.__name__, os.__module__, os.__name__))
def check_unique_method_keys(self): class MethodAlreadyExistsError(Exception): def __init__(self, what): super(MethodAlreadyExistsError, self).__init__("Method key %r already exists", what) keys = {} for s in self.services: for mdesc in s.public_methods.values(): other_mdesc = keys.get(mdesc.internal_key, None) if other_mdesc is not None: logger.error( 'Methods keys for "%s.%s" and "%s.%s" conflict', mdesc.function.__module__, six.get_function_name(mdesc.function), other_mdesc.function.__module__, six.get_function_name(other_mdesc.function)) raise MethodAlreadyExistsError(mdesc.internal_key) keys[mdesc.internal_key] = mdesc
def check_unique_method_keys(self): class MethodAlreadyExistsError(Exception): def __init__(self, what): super(MethodAlreadyExistsError, self).__init__( "Method key %r already exists", what) keys = {} for s in self.services: for mdesc in s.public_methods.values(): other_mdesc = keys.get(mdesc.internal_key, None) if other_mdesc is not None: logger.error( 'Methods keys for "%s.%s" and "%s.%s" conflict', mdesc.function.__module__, six.get_function_name(mdesc.function), other_mdesc.function.__module__, six.get_function_name(other_mdesc.function)) raise MethodAlreadyExistsError(mdesc.internal_key) keys[mdesc.internal_key] = mdesc
def internal_key(self): """The internal function identifier in '{namespace}name' form.""" sc = self.service_class if sc is not None: return '{%s}%s%s' % (sc.get_internal_key(), six.get_function_name(self.function), self.internal_key_suffix) pc = self.parent_class if pc is not None: mn = pc.__module__ on = pc.__name__ dn = self.name # prevent duplicate class name. this happens when the class is a # direct subclass of ComplexModel if dn.split('.', 1)[0] != on: return "{%s}%s.%s" % (mn, on, dn) return "{%s}%s" % (mn, dn)
def internal_key(self): """The internal function identifier in '{namespace}name' form.""" pc = self.parent_class if pc is not None: mn = pc.__module__ on = pc.__name__ dn = self.name # prevent duplicate class name. this happens when the class is a # direct subclass of ComplexModel if dn.split('.', 1)[0] != on: return "{%s}%s.%s" % (mn, on, dn) return "{%s}%s" % (mn, dn) sc = self.service_class if sc is not None: return '{%s}%s%s' % (sc.get_internal_key(), six.get_function_name( self.function), self.internal_key_suffix)
def internal_key(self): """The internal function identifier in '{namespace}name' form.""" return '{%s}%s%s' % (self.service_class.get_internal_key(), six.get_function_name( self.function), self.internal_key_suffix)