Merge lp:~j-launchpad-dennis/ladon/ladon into lp:ladon

Proposed by Dennis Plöger
Status: Needs review
Proposed branch: lp:~j-launchpad-dennis/ladon/ladon
Merge into: lp:ladon
Diff against target: 218 lines (+61/-59)
1 file modified
frameworks/python/src/ladon/interfaces/xmlrpc.py (+61/-59)
To merge this branch: bzr merge lp:~j-launchpad-dennis/ladon/ladon
Reviewer Review Type Date Requested Status
Ladon Developer Pending
Review via email: mp+151956@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Dennis Plöger (j-launchpad-dennis) wrote :

Hello? Could this be integrated please?

Unmerged revisions

99. By Dennis Ploeger <email address hidden>

errors in xmlrpc type handling on responses

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'frameworks/python/src/ladon/interfaces/xmlrpc.py'
--- frameworks/python/src/ladon/interfaces/xmlrpc.py 2013-03-03 21:17:57 +0000
+++ frameworks/python/src/ladon/interfaces/xmlrpc.py 2013-03-06 13:36:38 +0000
@@ -58,7 +58,8 @@
58 _content_type = 'text/xml'58 _content_type = 'text/xml'
59 _special_types = []59 _special_types = []
6060
61 def _get_type_name(self, type_class):61 @staticmethod
62 def get_type_name(type_class):
6263
63 try:64 try:
6465
@@ -68,7 +69,8 @@
6869
69 return type(type_class).__name__70 return type(type_class).__name__
7071
71 def _type_to_xmlrpc(self, type_name):72 @staticmethod
73 def type_to_xmlrpc(type_name):
7274
73 if type_name in ['str', 'unicode']:75 if type_name in ['str', 'unicode']:
7476
@@ -84,7 +86,7 @@
8486
85 elif type_name == 'datetime.time':87 elif type_name == 'datetime.time':
8688
87 return 'dateTime8601'89 return 'dateTime.iso8601'
8890
89 elif type_name == 'bool':91 elif type_name == 'bool':
9092
@@ -122,7 +124,7 @@
122124
123 for type_class in type_dict:125 for type_class in type_dict:
124126
125 self._special_types.append(self._get_type_name(type_class))127 self._special_types.append(get_type_name(type_class))
126128
127 impl = getDOMImplementation()129 impl = getDOMImplementation()
128130
@@ -160,8 +162,8 @@
160162
161 member_el.setAttribute(163 member_el.setAttribute(
162 'type',164 'type',
163 self._type_to_xmlrpc(165 type_to_xmlrpc(
164 self._get_type_name(member_type)166 get_type_name(member_type)
165 )167 )
166 )168 )
167169
@@ -188,8 +190,8 @@
188 method_el.setAttribute('name', method.name())190 method_el.setAttribute('name', method.name())
189 method_el.setAttribute(191 method_el.setAttribute(
190 'result',192 'result',
191 self._type_to_xmlrpc(193 type_to_xmlrpc(
192 self._get_type_name(method_info['rtype'][0])194 get_type_name(method_info['rtype'][0])
193 )195 )
194 )196 )
195197
@@ -199,8 +201,8 @@
199201
200 param_el.setAttribute(202 param_el.setAttribute(
201 'type',203 'type',
202 self._type_to_xmlrpc(204 type_to_xmlrpc(
203 self._get_type_name(param['type'])205 get_type_name(param['type'])
204 )206 )
205 )207 )
206208
@@ -346,65 +348,65 @@
346348
347 value_el = resp_doc.createElement('value')349 value_el = resp_doc.createElement('value')
348350
349 if isinstance(value, (str, unicode)):351 type = XMLRPCServiceDescriptor.type_to_xmlrpc(XMLRPCServiceDescriptor.get_type_name(value))
350352
351 # Check for special cases base64, dateTime.iso8601353 if type == 'base64':
352354
353 if is_binary(value):355 base64_el = resp_doc.createElement('base64')
354356 base64_el.appendChild(
355 base64_el = resp_doc.createElement('base64')357 resp_doc.createTextNode(base64.b64encode(str(value)))
356 base64_el.appendChild(358 )
357 resp_doc.createTextNode(base64.b64encode(str(value)))359
358 )360 value_el.appendChild(base64_el)
359361
360 value_el.appendChild(base64_el)362 elif type == 'string' and self.datetime_re.match(value):
361363
362 elif self.datetime_re.match(value):364 # Special case of a string, that is in dateTime.iso8601 format
363365
364 datetime_el = resp_doc.createElement('dateTime.iso8601')366 datetime_el = resp_doc.createElement('dateTime.iso8601')
365 datetime_el.appendChild(367 datetime_el.appendChild(
366 resp_doc.createTextNode(value)368 resp_doc.createTextNode(value)
367 )369 )
368370
369 value_el.appendChild(datetime_el)371 value_el.appendChild(datetime_el)
370372
371 elif isinstance(value, unicode):373 elif type == 'string' and XMLRPCServiceDescriptor.get_type_name(value) == 'unicode':
372374
373 string_el = resp_doc.createElement('string')375 string_el = resp_doc.createElement('string')
374 string_el.appendChild(376 string_el.appendChild(
375 resp_doc.createTextNode(value)377 resp_doc.createTextNode(value)
376 )378 )
377379
378 value_el.appendChild(string_el)380 value_el.appendChild(string_el)
379381
380 else:382 elif type == 'string':
381383
382 string_el = resp_doc.createElement('string')384 string_el = resp_doc.createElement('string')
383 string_el.appendChild(385 string_el.appendChild(
384 resp_doc.createTextNode(u(value))386 resp_doc.createTextNode(u(value))
385 )387 )
386388
387 value_el.appendChild(string_el)389 value_el.appendChild(string_el)
388390
389 elif isinstance(value, int):391 elif type == 'int':
390392
391 int_el = resp_doc.createElement('int')393 int_el = resp_doc.createElement('int')
392 int_el.appendChild(394 int_el.appendChild(
393 resp_doc.createTextNode(value)395 resp_doc.createTextNode(u(str(value)))
394 )396 )
395397
396 value_el.appendChild(int_el)398 value_el.appendChild(int_el)
397399
398 elif isinstance(value, float):400 elif type == 'double':
399401
400 double_el = resp_doc.createElement('double')402 double_el = resp_doc.createElement('double')
401 double_el.appendChild(403 double_el.appendChild(
402 resp_doc.createTextNode(value)404 resp_doc.createTextNode(u(str(value)))
403 )405 )
404406
405 value_el.appendChild(double_el)407 value_el.appendChild(double_el)
406408
407 elif isinstance(value, bool):409 elif type == 'boolean':
408410
409 if value:411 if value:
410 value = 1412 value = 1
@@ -413,12 +415,12 @@
413415
414 boolean_el = resp_doc.createElement('boolean')416 boolean_el = resp_doc.createElement('boolean')
415 boolean_el.appendChild(417 boolean_el.appendChild(
416 resp_doc.createTextNode(value)418 resp_doc.createTextNode(u(str(value)))
417 )419 )
418420
419 value_el.appendChild(boolean_el)421 value_el.appendChild(boolean_el)
420422
421 elif isinstance(value, datetime.time):423 elif type == 'dateTime.iso8601':
422424
423 datetime_el = resp_doc.createElement('dateTime.iso8601')425 datetime_el = resp_doc.createElement('dateTime.iso8601')
424 datetime_el.appendChild(426 datetime_el.appendChild(
@@ -429,7 +431,7 @@
429431
430 value_el.appendChild(datetime_el)432 value_el.appendChild(datetime_el)
431433
432 elif isinstance(value, dict):434 elif type == 'struct':
433435
434 struct_el = resp_doc.createElement('struct')436 struct_el = resp_doc.createElement('struct')
435437
@@ -456,7 +458,7 @@
456458
457 value_el.appendChild(struct_el)459 value_el.appendChild(struct_el)
458460
459 elif isinstance(value, list):461 elif type == 'array':
460462
461 array_el = resp_doc.createElement('array')463 array_el = resp_doc.createElement('array')
462 data_el = resp_doc.createElement('data')464 data_el = resp_doc.createElement('data')

Subscribers

People subscribed via source and target branches