[PATCH] Issue #737: fix to remove twice call of resource lookup

From: Archana Singh <archus@linux.vnet.ibm.com> Issue #737: fix to remove twice call of resource lookup Archana Singh (1): Issue #737: fix to remove twice call of resource lookup in GET Operation src/wok/control/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 1.9.1

From: Archana Singh <archus@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@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

Patch looks good, but send the commit message with no more than 80 columns per line. Tested-By: Paulo Vital <pvital@linux.vnet.ibm.com> Reviewed-By: Paulo Vital <pvital@linux.vnet.ibm.com> On Wed, 2015-10-14 at 19:57 +0530, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@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@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':

This patch introduces more errors on test cases. Before this patch I got the following output from "make check" on Kimchi: ---------------------------------------------------------------------- Ran 112 tests in 91.188s FAILED (failures=17, errors=43, skipped=1) After this patch: ---------------------------------------------------------------------- Ran 112 tests in 79.692s FAILED (failures=24, errors=45, skipped=1) Please, make sure your changes does not break anything else. You can test them by running "make check" on wok and kimchi. Regards, Aline Manera On 14/10/2015 11:27, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@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@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':
participants (3)
-
Aline Manera
-
archus@linux.vnet.ibm.com
-
Paulo Ricardo Paz Vital