VirtualMailManager/domain.py
branchv0.6.x
changeset 534 6a27c7529cd7
parent 515 09fa019bb330
child 539 5806fb74130b
equal deleted inserted replaced
533:2676dbf43e1c 534:6a27c7529cd7
   127             raise DomErr(_(u"The domain '%s' already exists.") % self._name,
   127             raise DomErr(_(u"The domain '%s' already exists.") % self._name,
   128                          DOMAIN_EXISTS)
   128                          DOMAIN_EXISTS)
   129 
   129 
   130     def _update_tables(self, column, value, force=False):
   130     def _update_tables(self, column, value, force=False):
   131         """Update various columns in the domain_data table. When *force* is
   131         """Update various columns in the domain_data table. When *force* is
   132         `True` also the corresponding column in the users table will be
   132         `True`, the corresponding column in the users table will be reset to
   133         updated.
   133         NULL.
   134 
   134 
   135         Arguments:
   135         Arguments:
   136 
   136 
   137         `column` : basestring
   137         `column` : basestring
   138           Name of the table column. Currently: qid, ssid and tid
   138           Name of the table column. Currently: qid, ssid and tid
   139         `value` : long
   139         `value` : long
   140           The referenced key
   140           The referenced key
   141         `force` : bool
   141         `force` : bool
   142           enforce the new setting also for existing users. Default: `False`
   142           reset existing users. Default: `False`
   143         """
   143         """
   144         if column not in ('qid', 'ssid', 'tid'):
   144         if column not in ('qid', 'ssid', 'tid'):
   145             raise ValueError('Unknown column: %r' % column)
   145             raise ValueError('Unknown column: %r' % column)
   146         dbc = self._dbh.cursor()
   146         dbc = self._dbh.cursor()
   147         dbc.execute('UPDATE domain_data SET %s = %%s WHERE gid = %%s' % column,
   147         dbc.execute('UPDATE domain_data SET %s = %%s WHERE gid = %%s' % column,
   148                     (value, self._gid))
   148                     (value, self._gid))
   149         if dbc.rowcount > 0:
   149         if dbc.rowcount > 0:
   150             self._dbh.commit()
   150             self._dbh.commit()
   151         if force:
   151         if force:
   152             dbc.execute('UPDATE users SET %s = %%s WHERE gid = %%s' % column,
   152             dbc.execute('UPDATE users SET %s = NULL WHERE gid = %%s' % column,
   153                         (value, self._gid))
   153                         (self._gid,))
   154             if dbc.rowcount > 0:
   154             if dbc.rowcount > 0:
   155                 self._dbh.commit()
   155                 self._dbh.commit()
   156         dbc.close()
   156         dbc.close()
   157 
   157 
   158     @property
   158     @property
   279         self._new = True
   279         self._new = True
   280 
   280 
   281     def update_quotalimit(self, quotalimit, force=False):
   281     def update_quotalimit(self, quotalimit, force=False):
   282         """Update the quota limit of the Domain.
   282         """Update the quota limit of the Domain.
   283 
   283 
   284         If *force* is `True` the new *quotalimit* will be applied to
   284         If *force* is `True`, accounts-specific overrides will be reset
   285         all existing accounts of the domain. Otherwise the *quotalimit*
   285         for all existing accounts of the domain. Otherwise, the limit
   286         will be only applied to accounts created from now on.
   286         will only affect accounts that use the default.
   287 
   287 
   288         Arguments:
   288         Arguments:
   289 
   289 
   290         `quotalimit` : VirtualMailManager.quotalimit.QuotaLimit
   290         `quotalimit` : VirtualMailManager.quotalimit.QuotaLimit
   291           the new quota limit of the domain.
   291           the new quota limit of the domain.
   303         self._qlimit = quotalimit
   303         self._qlimit = quotalimit
   304 
   304 
   305     def update_serviceset(self, serviceset, force=False):
   305     def update_serviceset(self, serviceset, force=False):
   306         """Assign a different set of services to the Domain,
   306         """Assign a different set of services to the Domain,
   307 
   307 
   308         If *force* is `True` the *serviceset* will be also assigned to
   308         If *force* is `True`, accounts-specific overrides will be reset
   309         all existing accounts of the Domain.  Otherwise the *serviceset*
   309         for all existing accounts of the domain. Otherwise, the service
   310         will be only the 'default' for accounts created from now on.
   310         set will only affect accounts that use the default.
   311 
   311 
   312         Arguments:
   312         Arguments:
   313         `serviceset` : VirtualMailManager.serviceset.ServiceSet
   313         `serviceset` : VirtualMailManager.serviceset.ServiceSet
   314           the new set of services
   314           the new set of services
   315         `force`
   315         `force`
   323         self._services = serviceset
   323         self._services = serviceset
   324 
   324 
   325     def update_transport(self, transport, force=False):
   325     def update_transport(self, transport, force=False):
   326         """Sets a new transport for the Domain.
   326         """Sets a new transport for the Domain.
   327 
   327 
   328         If *force* is `True` the new *transport* will be assigned to all
   328         If *force* is `True`, accounts-specific overrides will be reset
   329         existing accounts.  Otherwise the *transport* will be only used for
   329         for all existing accounts of the domain. Otherwise, the transport
   330         accounts created from now on.
   330         setting will only affect accounts that use the default.
   331 
   331 
   332         Arguments:
   332         Arguments:
   333 
   333 
   334         `transport` : VirtualMailManager.Transport
   334         `transport` : VirtualMailManager.Transport
   335           the new transport
   335           the new transport