comparison roundup/xmlrpc.py @ 5378:35ea9b1efc14

Python 3 preparation: "raise" syntax. Changing "raise Exception, value" to "raise Exception(value)". Tool-assisted patch. Particular cases to check carefully are the one place in frontends/ZRoundup/ZRoundup.py where a string exception needed to be fixed, and the one in roundup/cgi/client.py involving raising an exception with a traceback (requires three-argument form of raise in Python 2, which as I understand it requires exec() to avoid a Python 3 syntax error).
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 21:39:58 +0000
parents db8659c4e8eb
children 0942fe89e82e
comparison
equal deleted inserted replaced
5377:12fe83f90f0d 5378:35ea9b1efc14
37 if isinstance(arg, Binary): 37 if isinstance(arg, Binary):
38 arg = arg.data 38 arg = arg.data
39 try : 39 try :
40 key, value = arg.split('=', 1) 40 key, value = arg.split('=', 1)
41 except ValueError : 41 except ValueError :
42 raise UsageError, 'argument "%s" not propname=value'%arg 42 raise UsageError('argument "%s" not propname=value'%arg)
43 if isinstance(key, unicode): 43 if isinstance(key, unicode):
44 try: 44 try:
45 key = key.encode ('ascii') 45 key = key.encode ('ascii')
46 except UnicodeEncodeError: 46 except UnicodeEncodeError:
47 raise UsageError, 'argument %r is no valid ascii keyword'%key 47 raise UsageError('argument %r is no valid ascii keyword'%key)
48 if isinstance(value, unicode): 48 if isinstance(value, unicode):
49 value = value.encode('utf-8') 49 value = value.encode('utf-8')
50 if value: 50 if value:
51 try: 51 try:
52 props[key] = hyperdb.rawToHyperdb(db, cl, itemid, 52 props[key] = hyperdb.rawToHyperdb(db, cl, itemid,
53 key, value) 53 key, value)
54 except hyperdb.HyperdbValueError as message: 54 except hyperdb.HyperdbValueError as message:
55 raise UsageError, message 55 raise UsageError(message)
56 else: 56 else:
57 # If we're syncing a file the contents may not be None 57 # If we're syncing a file the contents may not be None
58 if key == 'content': 58 if key == 'content':
59 props[key] = '' 59 props[key] = ''
60 else: 60 else:
139 props = props_from_args(self.db, cl, args) 139 props = props_from_args(self.db, cl, args)
140 140
141 # check for the key property 141 # check for the key property
142 key = cl.getkey() 142 key = cl.getkey()
143 if key and not props.has_key(key): 143 if key and not props.has_key(key):
144 raise UsageError, 'you must provide the "%s" property.'%key 144 raise UsageError('you must provide the "%s" property.'%key)
145 145
146 for key in props: 146 for key in props:
147 if not self.db.security.hasPermission('Create', self.db.getuid(), 147 if not self.db.security.hasPermission('Create', self.db.getuid(),
148 classname, property=key): 148 classname, property=key):
149 raise Unauthorised('Permission to create %s.%s denied'%(classname, key)) 149 raise Unauthorised('Permission to create %s.%s denied'%(classname, key))

Roundup Issue Tracker: http://roundup-tracker.org/