Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3293 Prikazi

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
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
sep. 18
2880
1
mar. 15
5343
0
apr. 15
4644
1
feb. 21
4827
1
apr. 20
7315