bversion/server.py
def commit(request: Request, context: ConnectionContext) -> Responce:
    """ Commit changes and release the write lock """

    session_token = request.headers['session_token'].encode('utf8')
    repository    = request.headers['repository']

    #===
    current_user = have_authenticated_user(request.remote_addr, repository, session_token)
    if current_user is False: return fail(user_auth_fail_msg)

    #===
    repository_path = config['repositories'][repository]['path']

    #===
    if not context.lock:
        return fail(lock_fail_msg)

    #===
    data_store = versioned_storage(repository_path,
                                   path_override = config['repositories'][repository]['transient_db_path_override'])

    if data_store.get_active_commit() is None: return fail(no_active_commit_msg)

    result = {}
    if request.headers['mode'] == 'commit':
        new_head = data_store.commit(request.headers['commit_message'], current_user['username'])
        result = {'head' : new_head}
    else:
        data_store.rollback()

    # --------------------------
    context.shutdown_handler()
    return success(result)
 Commit changes and release the write lock 
Commit changes and release the write lock
Commit changes and release the write lock
def commit(request: Request, context: ConnectionContext) -> Responce:
    session_token = request.headers['session_token'].encode('utf8')
    repository    = request.headers['repository']
    current_user = have_authenticated_user(request.remote_addr, repository, session_token)
    if current_user is False: return fail(user_auth_fail_msg)
    repository_path = config['repositories'][repository]['path']
    if not context.lock:
        return fail(lock_fail_msg)
    data_store = versioned_storage(repository_path,
                                   path_override = config['repositories'][repository]['transient_db_path_override'])
    if data_store.get_active_commit() is None: return fail(no_active_commit_msg)
    result = {}
    if request.headers['mode'] == 'commit':
        new_head = data_store.commit(request.headers['commit_message'], current_user['username'])
        result = {'head' : new_head}
    else:
        data_store.rollback()
    context.shutdown_handler()
    return success(result)
def commit ( request : Request , context : ConnectionContext ) -> Responce : session_token = request . headers [ 'session_token' ] . encode ( 'utf8' ) repository = request . headers [ 'repository' ] current_user = have_authenticated_user ( request . remote_addr , repository , session_token ) if current_user is False : return fail ( user_auth_fail_msg ) repository_path = config [ 'repositories' ] [ repository ] [ 'path' ] if not context . lock : return fail ( lock_fail_msg ) data_store = versioned_storage ( repository_path , path_override = config [ 'repositories' ] [ repository ] [ 'transient_db_path_override' ] ) if data_store . get_active_commit ( ) is None : return fail ( no_active_commit_msg ) result = { } if request . headers [ 'mode' ] == 'commit' : new_head = data_store . commit ( request . headers [ 'commit_message' ] , current_user [ 'username' ] ) result = { 'head' : new_head } else : data_store . rollback ( ) context . shutdown_handler ( ) return success ( result )
Commit changes and release the write lock
Commit changes and release the write lock
""" Commit changes and release the write lock """ #=== #=== #=== #=== # --------------------------
request
Request
context
ConnectionContext