Wrap methods instead of screwing with the class hierarchy uniphil/Windermere

wrap_file_field is a class decorator for handling file uploads, deletions, etc with a flask-admin sqla.ModelView. It wraps the ModelView methods for creation, updating, and deleting. ModelViews don't (and can't really) know anything about files, so this is a end-user convenience that makes everything work with a few config options passed into the decorator.

It's simple. For a model like this:

class Photo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.Text)
    photo = db.Column(db.String(200))  # this will be a filename

... you might make a Flask-Admin ModelView like this:

@wrap_file_field('photo', 'photos-folder', endpoint='uploaded_file', photo=True)
class PhotoView(sqla.ModelView):
    """Manage your nice photos whose files will be magically taken care of yay"""

And you're done (provided you've set up the right config variables for the uploads directory and stuff). Sweet.

However, the old version's implementation screwed with the class hierarchy a bit, and that caused problems. Particularly, it broke super():

@wrap_file_field('photo', 'photos-folder', endpoint='uploaded_file', photo=True)
class PhotoView(sqla.ModelView):
    """Manage your nice photos whose files will be magically taken care of yay"""
    def get_list(self, *args, **kwargs)
        result = super(PhotoView, self).get_list(*args, **kwargs)  # infinite recursion?!?!
        # screw around with result...
        return result

The new version no longer subclasses the user's class, but instead mutates it. Users can use super as much as and however they like and it's all terrific.