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 | |
---|
9 | class RecursiveNull(object): |
---|
10 | def __getattr__(self, attr): |
---|
11 | return self |
---|
12 | def __getitem__(self, item): |
---|
13 | return self |
---|
14 | def __call__(self, *args, **kwargs): |
---|
15 | return self |
---|
16 | def __str__(self): |
---|
17 | return '' |
---|
18 | def __repr__(self): |
---|
19 | return '' |
---|
20 | def __nonzero__(self): |
---|
21 | return 0 |
---|
22 | def __eq__(self, x): |
---|
23 | if x: |
---|
24 | return False |
---|
25 | return True |
---|
26 | def __ne__(self, x): |
---|
27 | return x and True or False |
---|
28 | |
---|