Code review comment for lp://qastaging/~u-matt-h/nova/aws-api-validation

Revision history for this message
Christopher MacGown (0x44) wrote :

Hi Matt,

Just one more fix to make your code more pythonix, then it should be good:
1174 +DEFAULT_VALIDATOR = {
1175 + 'instance_id': (validate_ec2_id,),
           ...
1186 +}

Shouldn't have a tuple value and should be:

DEFAULT_VALIDATOR = {
    'instance_id': validate_ec2_id,
    ...
}

Which would make your validate function look like this:

for key, value in validator.items():
    if not key in args:
        continue

    assert callable(f)
    if not f(args[key]):
        ...

instead of:

1210 + for key in validator:
1211 + if key not in args:
1212 + continue
1213 +
1214 + for f in validator[key]:
1215 + assert callable(f)
1216 +
1217 + if not f(args[key]):
1218 + msg = "%s with value %s failed validator %s" % (
1219 + key, args[key], f.__name__)
1220 + LOG.debug(_(msg))
1221 + return False
1222 + return True

review: Needs Fixing

« Back to merge proposal