[Kimchi-devel] [PATCH] Issue #737: fix to remove twice call of resource lookup in GET Operation
archus at linux.vnet.ibm.com
archus at linux.vnet.ibm.com
Wed Oct 14 14:27:56 UTC 2015
From: Archana Singh <archus at linux.vnet.ibm.com>
In case of GET, lookup gets called twice. Once before is_authorized() and then in self.get(). This added overhead to system when lookup() get $
And as is_authorized() uses self.info, which is currently being intialized in exception section of lookup(). So moved it to __init__.
Signed-off-by: Archana Singh <archus at linux.vnet.ibm.com>
---
src/wok/control/base.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/wok/control/base.py b/src/wok/control/base.py
index 5c5c95f..4a4220f 100644
--- a/src/wok/control/base.py
+++ b/src/wok/control/base.py
@@ -58,6 +58,7 @@ class Resource(object):
self.model_args = (ident,)
self.role_key = None
self.admin_methods = []
+ self.info = {}
def _redirect(self, action_result, code=303):
if isinstance(action_result, list):
@@ -145,6 +146,7 @@ class Resource(object):
def delete(self):
try:
+ self.lookup()
fn = getattr(self.model, model_fn(self, 'delete'))
fn(*self.model_args)
cherrypy.response.status = 204
@@ -163,7 +165,6 @@ class Resource(object):
self.role_key, self.admin_methods)
try:
- self.lookup()
if not self.is_authorized():
raise UnauthorizedError('WOKAPI0009E')
@@ -198,6 +199,7 @@ class Resource(object):
def update(self, *args, **kargs):
try:
+ self.lookup()
update = getattr(self.model, model_fn(self, 'update'))
except AttributeError:
e = InvalidOperation('WOKAPI0003E', {'resource':
--
1.9.1
More information about the Kimchi-devel
mailing list