[Kimchi-devel] [PATCH] Issue #737: fix to remove twice call of resource lookup in GET Operation

Aline Manera alinefm at linux.vnet.ibm.com
Thu Oct 15 19:10:31 UTC 2015


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 at linux.vnet.ibm.com wrote:
> 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':




More information about the Kimchi-devel mailing list