[Kimchi-devel] [PATCH] kimchi.control.utils: fix request parsing in generate_action_handler()

zhshzhou at linux.vnet.ibm.com zhshzhou at linux.vnet.ibm.com
Sat Mar 1 14:12:38 UTC 2014


From: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>

generate_action_handler() parses the request and collects the action
arguments. The problem is it calls parse_request() in a generation
expression. This implies parse_request() is called for each action
argument. However parse_request() should be called only once, because it
reads over the request body and turns it to a dict. When it is called a
second time, the request body is already over, so parse_request() fails.

This patch stores the result from parse_request() in a variable, and
uses the variable in the generation expression.

Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
---
 src/kimchi/control/base.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index 61b4341..48f1949 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -65,8 +65,8 @@ class Resource(object):
             try:
                 model_args = list(self.model_args)
                 if action_args is not None:
-                    model_args.extend(parse_request()[key]
-                                      for key in action_args)
+                    request = parse_request()
+                    model_args.extend(request[key] for key in action_args)
                 fn = getattr(self.model, model_fn(self, action_name))
                 ident = fn(*model_args)
                 self._redirect(ident)
-- 
1.8.5.3




More information about the Kimchi-devel mailing list