예제 #1
0
 def create(self, connection, params):
     row = execute_action(
         connection,
         """
         insert into user_accounts (first_name, user_name, email)
         values (%(f)s, %(u)s, %(e)s) returning user_account_id
         """,
         {
             'f': params['first_name'],
             'u': params['user_name'],
             'e': params['email']
         },
         True
     )
     
     id = row['user_account_id']
     
     if 0 < len(params['last_name']):
         execute_action(
             connection,
             """
             update user_accounts set last_name = %(l)s
             where user_account_id = %(i)s
             """,
             { 'l': params['last_name'], 'i': id }
         )
         
     return id
예제 #2
0
 def delete(self, connection, sessionKey, requestKey):
     execute_action(
         connection,
         """
         delete from unique_requests
         where session_key = %(s)s and request_key = %(r)s
         """,
         { 's': sessionKey, 'r': requestKey })
예제 #3
0
 def create(self, connection, userAccountId, oidIdentifier):
     execute_action(
         connection,
         """
         insert into openid_accounts (ref_user_account_id, openid_identifier)
         values (%(i)s, %(o)s)
         """,
         { 'i': userAccountId, 'o': oidIdentifier})
     
예제 #4
0
 def create(self, sessionKey, requestKey, data=None):
     """
     Creates a database record in the unique_requests table foor the
     requestKey/sessionKey combination and returns the unique value
     generated.
     """        
     value = binascii.hexlify(os.urandom(20)).decode('ascii')
     print('Random value: {0}'.format(value))
     
     with grab_connection('main') as connection:
         execute_action(connection,
             """
             delete from unique_requests
             where session_key = %(s)s and request_key = %(r)s
             """,
             { 's': sessionKey, 'r': requestKey })
         
         execute_action(connection,
             """
             insert into unique_requests
             (session_key, request_key, request_value)
             values (%(s)s, %(r)s, %(v)s)
             """,
             { 's': sessionKey, 'r': requestKey, 'v': value })
         
         if data:
             execute_action(connection,
                 """
                 update unique_requests
                 set request_data = %(d)s
                 where session_key = %(s)s and request_key = %(r)s
                 """,
                 { 'd': data, 's': sessionKey, 'r': requestKey })
         
     return value