From: schlatterbeck Date: Fri, 9 Apr 2010 09:49:06 +0000 (+0000) Subject: - fix coding style from yesterday X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=db4c2e6f8f43080f51c832d2fbad73c8ffdd16ec;p=roundup.git - fix coding style from yesterday - Allow encoding of parameters as "Binary" (this is encoded as base64 in xmlrpc). Example: s.create("file", "name=bla", "type=application/octet-stream", xmlrpclib.Binary("content=\0")) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4477 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/xmlrpc.py b/roundup/xmlrpc.py index 88ddb34..111a0b7 100644 --- a/roundup/xmlrpc.py +++ b/roundup/xmlrpc.py @@ -10,6 +10,7 @@ from roundup.exceptions import UsageError from roundup.date import Date, Range, Interval from roundup import actions from SimpleXMLRPCServer import * +from xmlrpclib import Binary def translate(value): """Translate value to becomes valid for XMLRPC transmission.""" @@ -32,19 +33,19 @@ def props_from_args(db, cl, args, itemid=None): props = {} for arg in args: - if arg.find('=') == -1: - raise UsageError, 'argument "%s" not propname=value'%arg + if isinstance(arg, Binary): + arg = arg.data try : key, value = arg.split('=', 1) except ValueError : raise UsageError, 'argument "%s" not propname=value'%arg - if isinstance (key, unicode) : - try : + if isinstance(key, unicode): + try: key = key.encode ('ascii') except UnicodeEncodeError: raise UsageError, 'argument %r is no valid ascii keyword'%key - if isinstance (value, unicode) : - value = value.encode ('utf-8') + if isinstance(value, unicode): + value = value.encode('utf-8') if value: try: props[key] = hyperdb.rawToHyperdb(db, cl, itemid,