username
¶
-
gratipay.utils.username.
safely_reserve_a_username
(cursor, gen_usernames=<function gen_random_usernames>, reserve=<function insert_into_participants>)[source]¶ Safely reserve a username.
Parameters: - cursor – a
psycopg2.cursor
managed as apostgres
transaction - gen_usernames – a generator of usernames to try
- reserve – a function that takes the cursor and does the SQL stuff
Database: one
INSERT
on averageReturns: a 12-hex-digit unicode
Raises: FailedToReserveUsername
if no acceptable username is found within 100 attempts, orRanOutOfUsernameAttempts
if the username generator runs out firstThe returned value is guaranteed to have been reserved in the database.
- cursor – a