diff options
| author | ced <> | 2007-07-26 08:31:36 +0000 |
|---|---|---|
| committer | ced <> | 2007-07-26 08:31:36 +0000 |
| commit | cfbf7686547d7c9ac2c4165ea5b8d66af3c17b03 (patch) | |
| tree | e8dec50cc406474504c194e29e6a0282e149cbcd /bin/workflow/wkf_service.py | |
| parent | 1029e1323b2a303c707bfc3872abe67744cf310b (diff) | |
kernel: improve workflow
- add index on workitem, instance
- add cache on wkf
bzr revid: ced-81afcda4514578d17d998c4e3a8ff516d3346b97
Diffstat (limited to 'bin/workflow/wkf_service.py')
| -rw-r--r-- | bin/workflow/wkf_service.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/workflow/wkf_service.py b/bin/workflow/wkf_service.py index 707ce97eb9c..5700896181d 100644 --- a/bin/workflow/wkf_service.py +++ b/bin/workflow/wkf_service.py @@ -42,6 +42,11 @@ class workflow_service(netsvc.Service): self.exportMethod(self.trg_validate) self.exportMethod(self.trg_redirect) self.exportMethod(self.trg_trigger) + self.exportMethod(self.clear_cache) + self.wkf_on_create_cache={} + + def clear_cache(self, cr, uid): + self.wkf_on_create_cache[cr.dbname]={} def trg_write(self, uid, res_type, res_id, cr): ident = (uid,res_type,res_id) @@ -63,8 +68,14 @@ class workflow_service(netsvc.Service): def trg_create(self, uid, res_type, res_id, cr): ident = (uid,res_type,res_id) - cr.execute('select id from wkf where osv=%s and on_create=True', (res_type,)) - for (wkf_id,) in cr.fetchall(): + self.wkf_on_create_cache.setdefault(cr.dbname, {}) + if res_type in self.wkf_on_create_cache[cr.dbname]: + wkf_ids = self.wkf_on_create_cache[cr.dbname][res_type] + else: + cr.execute('select id from wkf where osv=%s and on_create=True', (res_type,)) + wkf_ids = cr.fetchall() + self.wkf_on_create_cache[cr.dbname][res_type] = wkf_ids + for (wkf_id,) in wkf_ids: instance.create(cr, ident, wkf_id) def trg_validate(self, uid, res_type, res_id, signal, cr): |
