VirtualMailManager/account.py
branchv0.7.x
changeset 638 0de0b9e75c9f
parent 614 1ec3497a6733
child 643 df1e3b67882a
equal deleted inserted replaced
637:ca6621caff2f 638:0de0b9e75c9f
    84         dbc.close()
    84         dbc.close()
    85         if result:
    85         if result:
    86             self._uid, _mid, _qid, _ssid, _tid, _note = result
    86             self._uid, _mid, _qid, _ssid, _tid, _note = result
    87 
    87 
    88             def load_helper(ctor, own, field, dbresult):
    88             def load_helper(ctor, own, field, dbresult):
    89                 #  Py25: cur = None if own is None else getattr(own, field)
    89                 cur = None if own is None else getattr(own, field)
    90                 if own is None:
       
    91                     cur = None
       
    92                 else:
       
    93                     cur = getattr(own, field)
       
    94                 if cur != dbresult:
    90                 if cur != dbresult:
    95                     kwargs = {field: dbresult}
    91                     kwargs = {field: dbresult}
    96                     if dbresult is None:
    92                     if dbresult is None:
    97                         return dbresult
    93                         return dbresult
    98                     else:
    94                     else:
   246             raise AErr(_(u"No password set for account: '%s'") % self._addr,
   242             raise AErr(_(u"No password set for account: '%s'") % self._addr,
   247                        ACCOUNT_MISSING_PASSWORD)
   243                        ACCOUNT_MISSING_PASSWORD)
   248         self._prepare(MailLocation(self._dbh, mbfmt=cfg_dget('mailbox.format'),
   244         self._prepare(MailLocation(self._dbh, mbfmt=cfg_dget('mailbox.format'),
   249                                    directory=cfg_dget('mailbox.root')))
   245                                    directory=cfg_dget('mailbox.root')))
   250         dbc = self._dbh.cursor()
   246         dbc = self._dbh.cursor()
   251         qid = ssid = tid = None
       
   252         if self._qlimit:
       
   253             qid = self._qlimit.qid
       
   254         if self._services:
       
   255             ssid = self._services.ssid
       
   256         if self._transport:
       
   257             tid = self._transport.tid
       
   258         dbc.execute('INSERT INTO users (local_part, passwd, uid, gid, mid, '
   247         dbc.execute('INSERT INTO users (local_part, passwd, uid, gid, mid, '
   259                     'qid, ssid, tid, note) '
   248                     'qid, ssid, tid, note) '
   260                     'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
   249                     'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
   261                     (self._addr.localpart,
   250                     (self._addr.localpart,
   262                      pwhash(self._passwd, user=self._addr), self._uid,
   251                      pwhash(self._passwd, user=self._addr), self._uid,
   263                      self._domain.gid, self._mail.mid, qid, ssid, tid,
   252                      self._domain.gid, self._mail.mid,
   264 #                     self._qlimit.qid if self._qlimit else None,
   253                      self._qlimit.qid if self._qlimit else None,
   265 #                     self._services.ssid if self._services else None,
   254                      self._services.ssid if self._services else None,
   266 #                     self._transport.tid if self._transport else None,
   255                      self._transport.tid if self._transport else None,
   267                      self._note))
   256                      self._note))
   268         self._dbh.commit()
   257         self._dbh.commit()
   269         dbc.close()
   258         dbc.close()
   270         self._new = False
   259         self._new = False
   271 
   260