'Given a cursor, use it to archive ourself.
Archiving means changing to a random username so the username they were
using is released. We also sign them out.'

def archive(self, cursor):

    self.final_check(cursor)
    def reserve(cursor, username):
        check = cursor.one(u'\n\n                                                                UPDATE    participants\n                                                                            SET    username=%s\n                                                                                    ,    username_lower=%s\n                                                                                    ,    claimed_time=NULL\n                                                                                    ,    session_token=NULL\n                                                                                    ,    session_expires=now()\n                                                                                    ,    giving    =    0\n                                                                                    ,    taking    =    0\n                                                                    WHERE    username=%s\n                                                    RETURNING    username\n\n                                                ', (username, username.lower(), self.username), default=NotSane)
        return check
    archived_as = safely_reserve_a_username(cursor, reserve=reserve)
    self.app.add_event(cursor, u'participant', dict(id=self.id, action=u'archive', values=dict(new_username=archived_as, old_username=self.username)))
    return archived_as
