94 def _check_for_addresses(self): |
94 def _check_for_addresses(self): |
95 """Checks dependencies for deletion. Raises a DomainError if there |
95 """Checks dependencies for deletion. Raises a DomainError if there |
96 are accounts, aliases and/or relocated users. |
96 are accounts, aliases and/or relocated users. |
97 """ |
97 """ |
98 dbc = self._dbh.cursor() |
98 dbc = self._dbh.cursor() |
99 dbc.execute('SELECT count(gid) FROM users WHERE gid = %(gid)u ' |
99 dbc.execute('SELECT ' |
100 'UNION SELECT count(gid) FROM alias WHERE gid = %(gid)u ' |
100 '(SELECT count(gid) FROM users WHERE gid = %(gid)u)' |
101 'UNION SELECT count(gid) FROM relocated WHERE gid = ' |
101 ' as account_count, ' |
102 '%(gid)u' % {'gid': self._gid}) |
102 '(SELECT count(gid) FROM alias WHERE gid = %(gid)u)' |
|
103 ' as alias_count, ' |
|
104 '(SELECT count(gid) FROM relocated WHERE gid = %(gid)u)' |
|
105 ' as relocated_count' |
|
106 % {'gid': self._gid}) |
103 result = dbc.fetchall() |
107 result = dbc.fetchall() |
104 dbc.close() |
108 dbc.close() |
105 result = [count[0] for count in result] |
109 result = result[0] |
106 if any(result): |
110 if any(result): |
107 keys = ('account_count', 'alias_count', 'relocated_count') |
111 keys = ('account_count', 'alias_count', 'relocated_count') |
108 raise DomErr(_(u'There are %(account_count)u accounts, ' |
112 raise DomErr(_(u'There are %(account_count)u accounts, ' |
109 u'%(alias_count)u aliases and %(relocated_count)u ' |
113 u'%(alias_count)u aliases and %(relocated_count)u ' |
110 u'relocated users.') % dict(zip(keys, result)), |
114 u'relocated users.') % dict(zip(keys, result)), |