[Kimchi-devel] [PATCH V3] Issue #737: Wok base framework calls resource model's lookup twice

archus at linux.vnet.ibm.com archus at linux.vnet.ibm.com
Mon Nov 23 10:05:03 UTC 2015


From: Archana Singh <archus at linux.vnet.ibm.com>

In case of GET lookup was called twice.
Once before is_authorized() and then in self.get().
This added overhead to system when lookup() is called
for each value in list from get_list() of Collection.
So to avoid this, removed lookup() call from get().
And updated code to call self.lookup() before self.get()
in resource's update() and collection's create().

Signed-off-by: Archana Singh <archus at linux.vnet.ibm.com>
---
 src/wok/control/base.py                        | 5 ++---
 src/wok/plugins/kimchi/control/storagepools.py | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/wok/control/base.py b/src/wok/control/base.py
index fc42cea..f739eae 100644
--- a/src/wok/control/base.py
+++ b/src/wok/control/base.py
@@ -213,11 +213,10 @@ class Resource(object):
         args = list(self.model_args) + [params]
         ident = update(*args)
         self._redirect(ident)
-
+        self.lookup()
         return self.get()
 
     def get(self):
-        self.lookup()
         return wok.template.render(get_class_name(self), self.data)
 
     @property
@@ -286,7 +285,7 @@ class Collection(object):
         cherrypy.response.status = 201
         args = self.resource_args + [name]
         res = self.resource(self.model, *args)
-
+        res.lookup()
         return res.get()
 
     def _get_resources(self, flag_filter):
diff --git a/src/wok/plugins/kimchi/control/storagepools.py b/src/wok/plugins/kimchi/control/storagepools.py
index d66b634..e91305e 100644
--- a/src/wok/plugins/kimchi/control/storagepools.py
+++ b/src/wok/plugins/kimchi/control/storagepools.py
@@ -51,6 +51,7 @@ class StoragePools(Collection):
         name = create(*args)
         args = self.resource_args + [name]
         res = self.resource(self.model, *args)
+        res.lookup()
         resp = res.get()
 
         if 'task_id' in res.data:
-- 
2.1.4




More information about the Kimchi-devel mailing list