The get_base_path method is pretty explicit in what you need to do..
Override to customize behavior (per-user directories, etc)
So, that's what you need to do. You need to create a class that inherits from FileAdmin, overrides the get_base_path()
method, and use THAT class rather than the base FileAdmin. If you're not familiar with what "overriding" a method is, you should look for a Python object-oriented tutorial.
This new class you create needs to override the get_base_path()
method to be per-user. So, something like...
class MyFileAdmin(FileAdmin):
def get_base_path(self):
path = FileAdmin.get_base_path(self)
if not current_user.is_anonymous():
return os.path.join(path, current_user.custom_path)
else:
return path
Now use MyFileAdmin
in place of FileAdmin
. I haven't tested this code out, but hopefully this gets you on the right track.
Note that your original plan of changing the path on the actual FileAdmin instance would not work. You create one instance of FileAdmin, and all users will have their requests routed using the same view. You would probably run into multi-threaded problems if you attempted to do this.