<commit_before>import pyramid_jsonapi.jsonapi
import pyramid_jsonapi.workflow as wf

stages = (
    'before_delete',
)

def workflow(view, stages, prev_data):
    item = view.single_item_query(loadonly=[view.key_column.name]).one()
    item = wf.execute_stage(
        view, stages, 'before_delete', item
    )
    try:
        view.dbsession.delete(item)
        view.dbsession.flush()
    except sqlalchemy.exc.IntegrityError as exc:
        raise HTTPFailedDependency(str(exc))
    doc = pyramid_jsonapi.jsonapi.Document()
    doc.update({
        'data': view.serialise_resource_identifier(
            view.obj_id
        )})
    return doc<commit_msg>move to new method of getting one object<commit_after>import pyramid_jsonapi.jsonapi
import pyramid_jsonapi.workflow as wf
import sqlalchemy

stages = (
    'before_delete',
)

def workflow(view, stages, prev_data):
    item = view.get_one(
        view.single_item_query(loadonly=[view.key_column.name]),
        not_found_message='No item {} in collection {}'.format(
            view.obj_id, view.collection_name
        )
    )
    item = wf.execute_stage(
        view, stages, 'before_delete', item
    )
    try:
        view.dbsession.delete(item)
        view.dbsession.flush()
    except sqlalchemy.exc.IntegrityError as exc:
        raise HTTPFailedDependency(str(exc))
    doc = pyramid_jsonapi.jsonapi.Document()
    doc.update({
        'data': view.serialise_resource_identifier(
            view.obj_id
        )})
    return doc
{'fraction_non_alphanumeric': 0.10252996005326231, 'fraction_numerical': 0.0, 'mean_word_length': 2.9140625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2543445', 'n_tokens_mistral': 488, 'n_tokens_neox': 468, 'n_words': 90}