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)
| 4003 | |
| 4004 | |
| 4005 | def load_app(target): |
| 4006 | """ Load a bottle application from a module and make sure that the import |
| 4007 | does not affect the current default application, but returns a separate |
| 4008 | application object. See :func:`load` for the target parameter. """ |
| 4009 | global NORUN |
| 4010 | NORUN, nr_old = True, NORUN |
| 4011 | tmp = default_app.push() # Create a new "default application" |
| 4012 | try: |
| 4013 | rv = load(target) # Import the target module |
| 4014 | return rv if callable(rv) else tmp |
| 4015 | finally: |
| 4016 | default_app.remove(tmp) # Remove the temporary added default application |
| 4017 | NORUN = nr_old |
| 4018 | |
| 4019 | |
| 4020 | _debug = debug |