VirtualMailManager/account.py
branchv0.7.x
changeset 735 ddcad86f7386
parent 726 46b37d7c848a
equal deleted inserted replaced
734:8167ba72235c 735:ddcad86f7386
   259         self._new = False
   259         self._new = False
   260 
   260 
   261     def modify(self, field, value):
   261     def modify(self, field, value):
   262         """Update the Account's *field* to the new *value*.
   262         """Update the Account's *field* to the new *value*.
   263 
   263 
   264         Possible values for *field* are: 'name' and 'note'.
   264         Possible values for *field* are: 'name', 'note' and 'pwhash'.
   265 
   265 
   266         Arguments:
   266         Arguments:
   267 
   267 
   268         `field` : str
   268         `field` : str
   269           The attribute name: 'name', or 'note'
   269           The attribute name: 'name', 'note' or 'pwhash'
   270         `value` : str
   270         `value` : str
   271           The new value of the attribute.
   271           The new value of the attribute.
   272         """
   272         """
   273         if field not in ('name', 'note'):
   273         if field not in ('name', 'note', 'pwhash'):
   274             raise AErr(_("Unknown field: '%s'") % field, INVALID_ARGUMENT)
   274             raise AErr(_("Unknown field: '%s'") % field, INVALID_ARGUMENT)
       
   275         if field == 'pwhash':
       
   276             field = 'passwd'
   275         self._chk_state()
   277         self._chk_state()
   276         dbc = self._dbh.cursor()
   278         dbc = self._dbh.cursor()
   277         dbc.execute('UPDATE users SET %s = %%s WHERE uid = %%s' % field,
   279         dbc.execute('UPDATE users SET %s = %%s WHERE uid = %%s' % field,
   278                     (value, self._uid))
   280                     (value, self._uid))
   279         if dbc.rowcount > 0:
   281         if dbc.rowcount > 0: