Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3279 Weergaven

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
sep. 18
2875
1
mrt. 15
5337
0
apr. 15
4637
1
feb. 21
4820
1
apr. 20
7313