def register(cls, code, name, hash_name=None, hash_new=None):
        if not _is_app_specific_func(code):
            raise ValueError(
                "only application-specific functions can be registered")
        name_mapping_data = [
            (cls._func_from_name, name,
             "function name is already registered for a different function"),
            (cls._func_from_hash, hash_name,
             "hashlib name is already registered for a different function")]
        for (mapping, nameinmap, errmsg) in name_mapping_data:
            existing_func = mapping.get(nameinmap, code)
            if existing_func != code:
                raise ValueError(errmsg, existing_func)
        if code in cls._func_hash:
            cls.unregister(code)
        cls._do_register(code, name, hash_name, hash_new)