def setup_attachments(app): # max upload size patch_request_class(app, 6 * 1024 * 1024) # attachment store global store store = setup_store(app) # set for the current thread, useful for debugging push_store_context(store) # link attachment store implicitly to the request chain @app.before_request def start_implicit_store_context(): global pushed push_store_context(store) pushed = True @app.teardown_request def stop_implicit_store_context(exception=None): global pushed if pushed: pop_store_context() pushed = False push_store_context(store)
def test_push_pop(): store_1 = Store() store_2 = Store() with raises(ContextError): get_current_store() push_store_context(store_1) assert get_current_store() is store_1 push_store_context(store_2) assert get_current_store() is store_2 pop_store_context() assert get_current_store() is store_1 pop_store_context() with raises(ContextError): get_current_store()
def start_implicit_store_context(): push_store_context(fs_store)
def start_implicit_store_context(): global pushed push_store_context(store) pushed = True
def start_implicit_store_context(): push_store_context(store)
def store_before_request(): context.push_store_context(app.store)