| 1 | """ |
| 2 | Nothing, but in a friendly way. Good for filling in for objects you want to |
| 3 | hide. If $form.f1 is a RecursiveNull object, then |
| 4 | $form.f1.anything["you"].might("use") will resolve to the empty string. |
| 5 | |
| 6 | This module was contributed by Ian Bicking. |
| 7 | """ |
| 8 | import sys |
| 9 | |
| 10 | |
| 11 | class RecursiveNull(object): |
| 12 | def __getattr__(self, attr): |
| 13 | return self |
| 14 | |
| 15 | def __getitem__(self, item): |
| 16 | return self |
| 17 | |
| 18 | def __call__(self, *args, **kwargs): |
| 19 | return self |
| 20 | |
| 21 | def __str__(self): |
| 22 | return '' |
| 23 | |
| 24 | def __repr__(self): |
| 25 | return '' |
| 26 | if sys.version_info[0] >= 3: |
| 27 | def __bool__(self): |
| 28 | return 0 |
| 29 | else: |
| 30 | def __nonzero__(self): |
| 31 | return 0 |
| 32 | |
| 33 | def __eq__(self, x): |
| 34 | if x: |
| 35 | return False |
| 36 | return True |
| 37 | |
| 38 | def __ne__(self, x): |
| 39 | return x and True or False |
| 40 | |
| 41 | |
| 42 | del sys |