'Add information to the knowledge I have about the user'

def add_metadata(self, environ, identity):

    name_id = identity['repoze.who.userid']
    if isinstance(name_id, basestring):
        try:
            name_id = decode(name_id)
        except:
            pass
    _cli = self.saml_client
    logger.debug(('[add_metadata]    for    %s' % name_id))
    try:
        logger.debug(('Issuers:    %s' % _cli.users.sources(name_id)))
    except KeyError:
        pass
    if ('user' not in identity):
        identity['user'] = {}
    try:
        (ava, _) = _cli.users.get_identity(name_id)
        logger.debug(('[add_metadata]    adds:    %s' % ava))
        identity['user'].update(ava)
    except KeyError:
        pass
    if (('pysaml2_vo_expanded' not in identity) and _cli.vorg):
        for vo in _cli.vorg.values():
            try:
                if vo.do_aggregation(name_id):
                    identity['user'] = _cli.users.get_identity(name_id)[0]
                    identity['pysaml2_vo_expanded'] = 1
            except KeyError:
                logger.exception('Failed    to    do    attribute    aggregation,    missing    common    attribute')
    logger.debug(('[add_metadata]    returns:    %s' % (dict(identity),)))
    if (not identity['user']):
        pass
