Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3288 Переглядів

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)



Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
вер. 18
2879
1
бер. 15
5340
0
квіт. 15
4639
1
лют. 21
4821
1
квіт. 20
7315