def __init__(self, *nested_rules): """Constructs a new Rule for validating requests. Any nested rules needed for validating parts of the request (such as headers, query string params, etc) should also be passed in. :param nested_rules: Any sub rules that also should be used for validation """ # If we get something that's not a request here, # something bad happened in the server (i.e. # maybe a programming error), so return a 500 # NOTE(TheSriram): One should not be creating a generic empty # RequestRule, a list of rules always needs to be passed in as # arguments. # Example: RequestRule(OffsetMarkerRule, LimitRule) Rule.__init__(self, vfunc=is_request(none_ok=True), # pragma: no cover errfunc=lambda: _abort(500), nested_rules=list(nested_rules))
def __init__(self, *nested_rules): """Constructs a new Rule for validating requests. Any nested rules needed for validating parts of the request (such as headers, query string params, etc) should also be passed in. :param nested_rules: Any sub rules that also should be used for validation """ # If we get something that's not a request here, # something bad happened in the server (i.e. # maybe a programming error), so return a 500 # NOTE(TheSriram): One should not be creating a generic empty # RequestRule, a list of rules always needs to be passed in as # arguments. # Example: RequestRule(OffsetMarkerRule, LimitRule) Rule.__init__( self, vfunc=is_request(none_ok=True), # pragma: no cover errfunc=lambda: _abort(500), nested_rules=list(nested_rules))
def __init__(self, querystring_name, vfunc, errfunc): getter = lambda req: req.get_param(querystring_name) Rule.__init__(self, vfunc=vfunc, getter=getter, errfunc=errfunc)
# Example: RequestRule(OffsetMarkerRule, LimitRule) Rule.__init__( self, vfunc=is_request(none_ok=True), # pragma: no cover errfunc=lambda: _abort(500), nested_rules=list(nested_rules)) class QueryStringRule(Rule): def __init__(self, querystring_name, vfunc, errfunc): getter = lambda req: req.get_param(querystring_name) Rule.__init__(self, vfunc=vfunc, getter=getter, errfunc=errfunc) # parameter rules VaultGetRule = Rule(val_vault_id(), lambda: _abort(404)) VaultPutRule = Rule(val_vault_id(), lambda: _abort(400)) BlockGetRule = Rule(val_block_id(), lambda: _abort(404)) BlockPutRule = Rule(val_block_id(), lambda: _abort(400)) BlockPostRule = Rule(val_block_id(), lambda: _abort(400)) StorageBlockGetRule = Rule(val_storage_block_id(), lambda: _abort(404)) StorageBlockPutRule = Rule(val_storage_block_id(), lambda: _abort(400)) FileGetRule = Rule(val_file_id(), lambda: _abort(404)) FilePutRule = Rule(val_file_id(), lambda: _abort(400)) FilePostRule = Rule(val_file_id(), lambda: _abort(400)) FileGetRuleNoneOk = Rule(val_file_id(none_ok=True), lambda: _abort(404)) FilePutRuleNoneOk = Rule(val_file_id(none_ok=True), lambda: _abort(400)) FilePostRuleNoneOk = Rule(val_file_id(none_ok=True), lambda: _abort(400)) BlockGetRuleNoneOk = Rule(val_block_id(none_ok=True), lambda: _abort(404)) BlockPutRuleNoneOk = Rule(val_block_id(none_ok=True), lambda: _abort(400)) BlockPostRuleNoneOk = Rule(val_block_id(none_ok=True), lambda: _abort(400))