If you’re smart, you might have a decorator that checks user authorization,
something like @login_required. You can compose Dart with other decorators
to simplify logic, while still keeping your code readable and concise:

deflogin_required(view):@functools.wraps(view)@dart.inject(User,'user',from_var='user_id')@dart.inject(User,'current_user',from_val=lambda:session['user_id'])defdecorated_view(user=None,current_user=None,*args,**kwargs):ifcurrent_user!=user:abort(403)else:returnview(user=user,*args,**kwargs)returndecorated_view@login_requireddefview(user=None):return'{} did it!'.format(user.name)

Of course, Dart isn’t just a Flask. It’s literally just a decorator that
takes a keyword arg or lambda expression and queries the model class using it as
the primary key. That means you can use the Dart decorator with any function.