'Called by the parent Cluster instance when the user registers a new
mapping from a user-defined type to a class.  Intended for internal
use only.'

def user_type_registered(self, keyspace, user_type, klass):

    try:
        ks_meta = self.cluster.metadata.keyspaces[keyspace]
    except KeyError:
        raise UserTypeDoesNotExist(('Keyspace    %s    does    not    exist    or    has    not    been    discovered    by    the    driver' % (keyspace,)))
    try:
        type_meta = ks_meta.user_types[user_type]
    except KeyError:
        raise UserTypeDoesNotExist(('User    type    %s    does    not    exist    in    keyspace    %s' % (user_type, keyspace)))
    field_names = type_meta.field_names
    if six.PY2:
        field_names = [fn.encode('utf-8') for fn in field_names]
    def encode(val):
        return ('{    %s    }' % '    ,    '.join((('%s    :    %s' % (field_name, self.encoder.cql_encode_all_types(getattr(val, field_name, None)))) for field_name in field_names)))
    self.encoder.mapping[klass] = encode
