Skip to content

Commit a172277

Browse files
committed
Improve props_from_args
.. to skip initializing invalid property of the class. committer: Ralf Schlatterbeck <[email protected]>
1 parent ea24c4d commit a172277

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

roundup/rest.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919

2020
def props_from_args(db, cl, args, itemid=None):
21+
class_props = cl.properties.keys()
2122
props = {}
23+
# props = dict.fromkeys(class_props, None)
24+
2225
for arg in args:
23-
try:
24-
key = arg.name
25-
value = arg.value
26-
except ValueError:
27-
raise UsageError('argument "%s" not propname=value' % arg)
26+
key = arg.name
27+
value = arg.value
28+
if key not in class_props:
29+
continue
2830
if isinstance(key, unicode):
2931
try:
3032
key = key.encode('ascii')
@@ -35,8 +37,8 @@ def props_from_args(db, cl, args, itemid=None):
3537
if value:
3638
try:
3739
props[key] = hyperdb.rawToHyperdb(db, cl, itemid, key, value)
38-
except hyperdb.HyperdbValueError:
39-
pass # pass if a parameter is not a property of the class
40+
except hyperdb.HyperdbValueError, msg:
41+
raise UsageError(msg)
4042
else:
4143
props[key] = None
4244

0 commit comments

Comments
 (0)