VirtualMailManager/account.py
branchv0.7.x
changeset 670 f374ef062c94
parent 662 9ec7770193ad
child 676 2bc11dada296
equal deleted inserted replaced
669:d765a878f0fc 670:f374ef062c94
   131 
   131 
   132         Arguments:
   132         Arguments:
   133 
   133 
   134         `column` : basestring
   134         `column` : basestring
   135           Name of the table column. Currently: qid, ssid and tid
   135           Name of the table column. Currently: qid, ssid and tid
   136         `value` : long
   136         `value` : int
   137           The referenced key
   137           The referenced key
   138         """
   138         """
   139         if column not in ('qid', 'ssid', 'tid'):
   139         if column not in ('qid', 'ssid', 'tid'):
   140             raise ValueError('Unknown column: %r' % column)
   140             raise ValueError('Unknown column: %r' % column)
   141         dbc = self._dbh.cursor()
   141         dbc = self._dbh.cursor()
   458     This function returns a dict (keys: 'address', 'gid' and 'uid'), if an
   458     This function returns a dict (keys: 'address', 'gid' and 'uid'), if an
   459     Account with the given *uid* exists.
   459     Account with the given *uid* exists.
   460 
   460 
   461     Argument:
   461     Argument:
   462 
   462 
   463     `uid` : long
   463     `uid` : int
   464       The Account unique ID.
   464       The Account unique ID.
   465     `dbh` : pyPgSQL.PgSQL.Connection
   465     `dbh` : pyPgSQL.PgSQL.Connection
   466       a database connection for the database access.
   466       a database connection for the database access.
   467     """
   467     """
   468     try:
   468     try:
   469         uid = int(uid)
   469         uid = int(uid)
   470     except ValueError:
   470     except ValueError:
   471         raise AErr(_('UID must be an int/long.'), INVALID_ARGUMENT)
   471         raise AErr(_('UID must be an integer.'), INVALID_ARGUMENT)
   472     if uid < 1:
   472     if uid < 1:
   473         raise AErr(_('UID must be greater than 0.'), INVALID_ARGUMENT)
   473         raise AErr(_('UID must be greater than 0.'), INVALID_ARGUMENT)
   474     dbc = dbh.cursor()
   474     dbc = dbh.cursor()
   475     dbc.execute("SELECT local_part||'@'|| domain_name.domainname AS address, "
   475     dbc.execute("SELECT local_part||'@'|| domain_name.domainname AS address, "
   476                 "uid, users.gid, note FROM users LEFT JOIN domain_name ON "
   476                 "uid, users.gid, note FROM users LEFT JOIN domain_name ON "