view detectors/immutable_file_contents.py @ 8562:9c3ec0a5c7fc

chore: remove __future print_funcion from code. Not needed as of Python 3.
author John Rouillard <rouilj@ieee.org>
date Wed, 08 Apr 2026 21:39:40 -0400
parents e738377b4ffe
children
line wrap: on
line source

# HTML pages don't provide a way to change the contents of a file.
# However REST does allow setting content and the HTML interface can
# be directed to update the content as well. This detector
# prevents changes to file content.

from roundup.exceptions import UsageError

def immutable_file_contents(db, cl, nodeid, newvalues):
    ''' Prevent content changes to a file
    '''
    if 'content' in newvalues:
        raise UsageError("File contents are immutable. "
                         "Rejecting change to contents.")


def init(db):
    """If you have other FileClass based classes add them here."""

    # fire before changes are made
    db.file.audit('set', immutable_file_contents)
    db.msg.audit('set', immutable_file_contents)


Roundup Issue Tracker: http://roundup-tracker.org/