
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':