예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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 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()
예제 #5
0
def start_implicit_store_context():
    push_store_context(fs_store)
예제 #6
0
 def start_implicit_store_context():
     global pushed
     push_store_context(store)
     pushed = True
예제 #7
0
 def start_implicit_store_context():
     global pushed
     push_store_context(store)
     pushed = True
예제 #8
0
def start_implicit_store_context():
    push_store_context(store)
예제 #9
0
 def store_before_request():
     context.push_store_context(app.store)
예제 #10
0
 def store_before_request():
     context.push_store_context(app.store)