@classmethod
def for_type(cls, tp, hookfn, referencer=None, mode='set'):
    """
        For an object of a given type, apply the hookfn and use the
        specified mode to aggregate the data.

        To allow pickling (or any other defered access) of the target
        object, a referencer (a Reference subclass) may be specified
        to wrap the object as required.

        If mode is 'merge', merge the Layout output by the hook,
        otherwise if 'set', add the output to the path specified by
        the ViewRef.
        """
    cls.type_hooks[tp] = hookfn, mode, referencer
