[Kimchi-devel] [PATCH] bug fix: remove decode for resouce ident when use cherrypy's default dispatcher
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Mon Jan 27 02:56:56 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
Now there are two kinds of sub-collection/resource dispatchers.
1. Use cherrypy's default dispatcher
Cherrypy will decode the ident automatically
But now in kimchi we decode the ident manually.
This is a bug.
Kimchi can not list the resources with unicode name.
For examle:
create a pool with kīмсhī-pool name
list this pool
$ curl -u shhfeng -H 'Accept: application/json' \
-H 'Content-type: application/json' \
http://localhost:8000/storagepools/kīмсhī-pool
kimchi will throw an UnicodeEncodeError.
This patch fixes this bug.
2. customized dispatcher by overriding the cherrypy dispatcher
We need to decode the ident explicitly.
Now kimchi handles it correctly.
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/control/storagepools.py | 2 +-
src/kimchi/control/vms.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py
index 3b8ef79..881c61e 100644
--- a/src/kimchi/control/storagepools.py
+++ b/src/kimchi/control/storagepools.py
@@ -85,7 +85,7 @@ class StoragePool(Resource):
self.uri_fmt = "/storagepools/%s"
self.activate = self.generate_action_handler('activate')
self.deactivate = self.generate_action_handler('deactivate')
- self.storagevolumes = StorageVolumes(self.model, ident.decode("utf-8"))
+ self.storagevolumes = StorageVolumes(self.model, ident)
@property
def data(self):
diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
index 06c7be3..60fc8ff 100644
--- a/src/kimchi/control/vms.py
+++ b/src/kimchi/control/vms.py
@@ -41,7 +41,7 @@ class VM(Resource):
self.screenshot = VMScreenShot(model, ident)
self.uri_fmt = '/vms/%s'
for ident, node in sub_nodes.items():
- setattr(self, ident, node(model, self.ident.decode("utf-8")))
+ setattr(self, ident, node(model, self.ident))
self.start = self.generate_action_handler('start')
self.stop = self.generate_action_handler('stop')
self.connect = self.generate_action_handler('connect')
--
1.8.4.2
More information about the Kimchi-devel
mailing list