This question has been flagged

Hi i have a custom class called cloud.user -> class CloudUser(models.Model):

I am overriding write method with this code:

@api.multi
def write(self, vals):
if vals.get('c_username') or vals.get('c_password'):
vals['c_access'] = False
res = super(CloudUser, self).write(vals)
self.action_update_cloud_user()
return res

The problem is it was taking to long, and while debugged i noticed that it enters to many times in the write method, (but not infinite, since it ends after a while), and in action_update_cloud_user() i am only doing stuff against an external service, not writing or modifiying the model at all.

# noinspection PyUnresolvedReferences
@api.multi
def action_update_cloud_user(self):
conn =
connect2cloud('http://127.0.0.1')
if not conn:
return

for user in self:
username, password, quota = user.c_username, user.c_password, user.c_quota

if user.c_access:
user.c_status == 'nonexistent' and conn.create_user(username, password)
conn.set_quota(username, quota)



Avatar
Discard