| Conditions | 2 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 55 | 1 | def run_with_context(function): |
|
| 56 | """Context Decorator""" |
||
| 57 | 1 | def wrapper(*args, **kwargs): |
|
| 58 | |||
| 59 | 1 | db_uri = os.environ.get('LOD_DATABASE_URL', None) |
|
| 60 | |||
| 61 | 1 | if not db_uri: |
|
| 62 | 1 | log.error("Please, specify 'LOD_DATABASE_URL' variable.") |
|
| 63 | 1 | return |
|
| 64 | |||
| 65 | 1 | context = app_lod().app_context() |
|
| 66 | 1 | context.push() |
|
| 67 | 1 | function(*args, **kwargs) |
|
| 68 | 1 | context.pop() |
|
| 69 | |||
| 70 | return wrapper |
||
| 71 |