VirtualMailManager/Domain.py
branchv0.6.x
changeset 198 02d467e4fbab
parent 185 6e1ef32fbd82
child 199 0684790fff7c
--- a/VirtualMailManager/Domain.py	Wed Feb 10 07:38:19 2010 +0000
+++ b/VirtualMailManager/Domain.py	Wed Feb 10 08:55:51 2010 +0000
@@ -278,6 +278,7 @@
             aliasdomains = [aname[0] for aname in anames]
         return aliasdomains
 
+
 def search(dbh, pattern=None, like=False):
     if pattern is not None and like is False:
         pattern = chk_domainname(pattern)
@@ -311,3 +312,18 @@
     del doms
     return order, domdict
 
+def get_gid(dbh, domainname):
+    """Returns the *GID* of the domain *domainname*.
+
+    Raises an `VMMDomainException` if the domain does not exist.
+    """
+    domainname = chk_domainname(domainname)
+    dbc = dbh.cursor()
+    dbc.execute('SELECT gid FROM domain_name WHERE domainname=%s', domainname)
+    gid = dbc.fetchone()
+    dbc.close()
+    if gid:
+        return gid[0]
+    else:
+        raise VMMDE(_(u"The domain ā€œ%sā€ doesn't exist.") % domainname,
+                    NO_SUCH_DOMAIN)