def METHOD_NAME(self, cls, to_dict, from_dict, typename=None):
    """Register a conversion/restoration.
    The `to_dict` function must return a dictionary; if no `typename` is given,
    the unquallified class name will be used.
    :param cls: the class that will be converted/restored
    :param to_dict: a function that will be called with the object as an argument
    :param from_dict: a function that restores the object from the dict
    :param typename: an optional typename for identifying the converted object
    """
    typename = cls.__name__ if typename is None else typename
    self.typenames[cls] = typename
    self.convert_to_dict[typename] = partial(self.obj_to_dict, typename, to_dict)
    self.convert_from_dict[typename] = partial(self.obj_from_dict, from_dict)