'Given a cursor and email address, return a verification nonce.'

def get_email_verification_nonce(self, c, email):

    nonce = str(uuid.uuid4())
    existing = c.one(u'SELECT    *    FROM    emails    WHERE    address=%s    AND    participant_id=%s', (email, self.id))
    if (existing is None):
        c.run(u'INSERT    INTO    emails    (participant_id,    address,    nonce)    VALUES    (%s,    %s,    %s)', (self.id, email, nonce))
    else:
        if existing.nonce:
            c.run(u'DELETE    FROM    claims    WHERE    nonce=%s', (existing.nonce,))
        c.run(u'\n                                                                UPDATE    emails\n                                                                            SET    nonce=%s\n                                                                                    ,    verification_start=now()\n                                                                    WHERE    participant_id=%s\n                                                                            AND    address=%s\n                                                ', (nonce, self.id, email))
    return nonce
