equal
deleted
inserted
replaced
181 self._dbh.commit() |
181 self._dbh.commit() |
182 dbc.close() |
182 dbc.close() |
183 else: |
183 else: |
184 raise VMMAccountException(("Account doesn't exists", |
184 raise VMMAccountException(("Account doesn't exists", |
185 ERR.NO_SUCH_ACCOUNT)) |
185 ERR.NO_SUCH_ACCOUNT)) |
|
186 |
|
187 |
|
188 def getAccountByID(uid, dbh): |
|
189 try: |
|
190 uid = long(uid) |
|
191 except ValueError: |
|
192 raise VMMAccountException(('uid must be an int/long.', |
|
193 ERR.INVALID_AGUMENT)) |
|
194 if uid < 1: |
|
195 raise VMMAccountException(('uid must be greater than 0.', |
|
196 ERR.INVALID_AGUMENT)) |
|
197 dbc = dbh.cursor() |
|
198 dbc.execute("SELECT local_part||'@'||domains.domainname AS address, uid,\ |
|
199 gid FROM users LEFT JOIN domains USING(gid) WHERE uid=%s", uid) |
|
200 info = dbc.fetchone() |
|
201 dbc.close() |
|
202 if info is None: |
|
203 raise VMMAccountException(("Account doesn't exists", |
|
204 ERR.NO_SUCH_ACCOUNT)) |
|
205 keys = ['address', 'uid', 'gid'] |
|
206 info = dict(zip(keys, info)) |
|
207 return info |
|
208 |