defnull/bottle — Issue #269: load and load_app fail if an app already loaded them
Author: polandj
Created: 2011-12-28 02:08:17+00:00
State: open

If I have the following files:

v1.py
'''
import bottle

@bottle.get('/')
def index():
return 'Index V1'

@bottle.put('/')
def modify(data):
return 'Ok'
'''

v2.py
'''
import bottle
import v1

@bottle.get('/')
def index():
return 'Index V2 %s' % v1.index()
'''

main.py
'''
import bottle

v2 = bottle.load_app('v2')
v1 = bottle.load_app('v1')
bottle.mount('/v1', v1)
bottle.mount('/v2', v2)
print 'V1 routes: %s' % len(v1.routes)
print 'V2 routes: %s' % len(v2.routes)

bottle.run(host='localhost', port=8080)
'''
It outputs:
'''
V1 routes: 0
V2 routes: 3
'''
If I swap the ordering of loading v1 and v2, it outputs:
'''
V1 routes: 2
V2 routes: 1
'''