'Get handler type of mapping.
Returns:
Handler type determined by which handler id attribute is set.
Raises:
UnknownHandlerType: when none of the no handler id attributes are set.
UnexpectedHandlerAttribute: when an unexpected attribute is set for the
discovered handler type.
HandlerTypeMissingAttribute: when the handler is missing a
required attribute for its handler type.
MissingHandlerAttribute: when a URL handler is missing an attribute'

def GetHandlerType(self):

    if (getattr(self, HANDLER_API_ENDPOINT) is not None):
        mapping_type = HANDLER_API_ENDPOINT
    else:
        for id_field in URLMap.ALLOWED_FIELDS.iterkeys():
            if (getattr(self, id_field) is not None):
                mapping_type = id_field
                break
        else:
            raise appinfo_errors.UnknownHandlerType(('Unknown    url    handler    type.\n%s' % str(self)))
    allowed_fields = URLMap.ALLOWED_FIELDS[mapping_type]
    for attribute in self.ATTRIBUTES.iterkeys():
        if ((getattr(self, attribute) is not None) and (not ((attribute in allowed_fields) or (attribute in URLMap.COMMON_FIELDS) or (attribute == mapping_type)))):
            raise appinfo_errors.UnexpectedHandlerAttribute(('Unexpected    attribute    "%s"    for    mapping    type    %s.' % (attribute, mapping_type)))
    if ((mapping_type == HANDLER_STATIC_FILES) and (not self.upload)):
        raise appinfo_errors.MissingHandlerAttribute(('Missing    "%s"    attribute    for    URL    "%s".' % (UPLOAD, self.url)))
    return mapping_type
