You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In dev version, bottle doesn't call the before_request hook in subapp.
In version 0.12, bottle calls the hook.
Here is the code for testing.
'''rootapp.py'''frombottleimportBottle, hook, run, requestfromsubappimportsubappapp=Bottle()
app.mount('/subapp/', subapp)
# add hook in rootapp, works in 0.12 and 0.13# @app.hook('before_request')# def downcase():# path_info = request.environ['PATH_INFO']# request.environ['PATH_INFO'] = path_info.lower()run(
app=app,
port='9999',
reloader=True)
'''subapp.py'''importbottlesubapp=bottle.Bottle()
# add hook in subapp, works only in 0.12, not in 0.13@subapp.hook('before_request')defdowncase():
path_info=bottle.request.environ['PATH_INFO']
bottle.request.environ['PATH_INFO'] =path_info.lower()
@subapp.get('/a')defa():
return'a'@subapp.get('/bac')defa():
returnf'{bottle.request.path}'
But a class based decorator works both in 0.12 and 0.13 for subapp
In dev version, bottle doesn't call the before_request hook in subapp.
In version 0.12, bottle calls the hook.
Here is the code for testing.
But a class based decorator works both in 0.12 and 0.13 for subapp
I prefer the hook way, though.
The text was updated successfully, but these errors were encountered: