Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See :func:`load` for the target parameter.
(target)
| 3605 | |
| 3606 | |
| 3607 | def load_app(target): |
| 3608 | """ Load a bottle application from a module and make sure that the import |
| 3609 | does not affect the current default application, but returns a separate |
| 3610 | application object. See :func:`load` for the target parameter. """ |
| 3611 | global NORUN |
| 3612 | NORUN, nr_old = True, NORUN |
| 3613 | tmp = default_app.push() # Create a new "default application" |
| 3614 | try: |
| 3615 | rv = load(target) # Import the target module |
| 3616 | return rv if callable(rv) else tmp |
| 3617 | finally: |
| 3618 | default_app.remove(tmp) # Remove the temporary added default application |
| 3619 | NORUN = nr_old |
| 3620 | |
| 3621 | |
| 3622 | _debug = debug |