| | 35 | |
| | 36 | def development_mode(default=True): |
| | 37 | """ |
| | 38 | Returns True if the environment var UMIT_DEVELOPMENT is set to true, |
| | 39 | 'true' (case insensitive) or some number different than 0 are considered |
| | 40 | as true, False otherwise. |
| | 41 | |
| | 42 | If the env var is not set, then the default value governs the return |
| | 43 | value. If you want UMIT_DEVELOPMENT to be True by default, call this |
| | 44 | function with default=True (default). |
| | 45 | """ |
| | 46 | val = os.environ.get('UMIT_DEVELOPMENT', default) |
| | 47 | try: |
| | 48 | val = int(val) |
| | 49 | except ValueError: |
| | 50 | if val.lower() == 'true': |
| | 51 | return True |
| | 52 | else: |
| | 53 | if val: |
| | 54 | return True |
| | 55 | |
| | 56 | return False |