|
1 |
| -""" :mod: RequestValidator |
| 1 | +""":mod: RequestValidator |
2 | 2 |
|
3 |
| - ====================== |
| 3 | +====================== |
4 | 4 |
|
5 |
| - .. module: RequestValidator |
| 5 | +.. module: RequestValidator |
6 | 6 |
|
7 |
| - :synopsis: request validator |
| 7 | +:synopsis: request validator |
8 | 8 |
|
9 |
| - .. moduleauthor:: [email protected] |
| 9 | +.. moduleauthor:: [email protected] |
10 | 10 |
|
11 |
| - A general and simple request validator checking for required attributes and logic. |
12 |
| - It checks if required attributes are set/unset but not for their values. |
| 11 | +A general and simple request validator checking for required attributes and logic. |
| 12 | +It checks if required attributes are set/unset but not for their values. |
13 | 13 |
|
14 |
| - RequestValidator class implements the DIRACSingleton pattern, no global object is |
15 |
| - required to keep a single instance. |
| 14 | +RequestValidator class implements the DIRACSingleton pattern, no global object is |
| 15 | +required to keep a single instance. |
16 | 16 |
|
17 |
| - If you need to extend this one with your own specific checks consider: |
| 17 | +If you need to extend this one with your own specific checks consider: |
18 | 18 |
|
19 |
| - * for adding Operation or Files required attributes use :any:`addReqAttrsCheck` function:: |
| 19 | + * for adding Operation or Files required attributes use :any:`addReqAttrsCheck` function:: |
20 | 20 |
|
21 |
| - RequestValidator().addReqAttrsCheck( "FooOperation", operationAttrs = [ "Bar", "Buzz"], filesAttrs = [ "LFN" ] ) |
| 21 | + RequestValidator().addReqAttrsCheck( "FooOperation", operationAttrs = [ "Bar", "Buzz"], filesAttrs = [ "LFN" ] ) |
22 | 22 |
|
23 |
| - * for adding generic check define a new callable object ( function or functor ) which takes only one argument, |
24 |
| - say for functor:: |
| 23 | + * for adding generic check define a new callable object ( function or functor ) which takes only one argument, |
| 24 | + say for functor:: |
25 | 25 |
|
26 |
| - class MyValidator( RequestValidator ): |
| 26 | + class MyValidator( RequestValidator ): |
27 | 27 |
|
28 |
| - @staticmethod |
29 |
| - def hasFoo( request ): |
30 |
| - if not request.Foo: |
31 |
| - return S_ERROR("Foo not set") |
32 |
| - return S_OK() |
| 28 | + @staticmethod |
| 29 | + def hasFoo( request ): |
| 30 | + if not request.Foo: |
| 31 | + return S_ERROR("Foo not set") |
| 32 | + return S_OK() |
33 | 33 |
|
34 |
| - * or function:: |
| 34 | + * or function:: |
35 | 35 |
|
36 |
| - def hasBar( request ): |
37 |
| - if not request.Bar: |
38 |
| - return S_ERROR("Bar not set") |
39 |
| - return S_OK() |
| 36 | + def hasBar( request ): |
| 37 | + if not request.Bar: |
| 38 | + return S_ERROR("Bar not set") |
| 39 | + return S_OK() |
40 | 40 |
|
41 |
| - and add this one to the validators set by calling `RequestValidator().addValidator`, i.e.:: |
| 41 | +and add this one to the validators set by calling `RequestValidator().addValidator`, i.e.:: |
42 | 42 |
|
43 |
| - RequestValidator().addValidator( MyValidator.hasFoo ) |
44 |
| - RequestValidator().addValidator( hasFoo ) |
| 43 | + RequestValidator().addValidator( MyValidator.hasFoo ) |
| 44 | + RequestValidator().addValidator( hasFoo ) |
45 | 45 |
|
46 |
| - Notice that all validators should always return S_ERROR/S_OK, no exceptions from that whatsoever! |
| 46 | +Notice that all validators should always return S_ERROR/S_OK, no exceptions from that whatsoever! |
47 | 47 | """
|
48 | 48 |
|
49 | 49 | import inspect
|
|
0 commit comments