skip to navigation
skip to content

Not Logged In

dart 1.0

Turn URL variables into models.

Dart turns URL variables into database models with a decorator.

That means you can do something like this:

@app.route('/user/<user_id>/tracks', methods=['GET'])
@dart.inject(User, 'user', from_var='user_id')
def user_tracks(user=None):
    return jsonify(user.tracks)

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:

def login_required(view):
    @dart.inject(User, 'user', from_var='user_id')
    @dart.inject(User, 'current_user', from_val=lambda: session['user_id'])
    def decorated_view(user=None, current_user=None, *args, **kwargs):
        if current_user != user:
            return view(user=user, *args, **kwargs)
    return decorated_view

def view(user=None):
    return '{} did it!'.format(

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.

For more info, check out the source code – it’s 27 lines.

File Type Py Version Uploaded on Size
dart-1.0-py2.py3-none-any.whl (md5) Python Wheel 2.7 2014-04-07 3KB
dart-1.0.tar.gz (md5) Source 2014-04-07 1KB
  • Downloads (All Versions):
  • 2 downloads in the last day
  • 27 downloads in the last week
  • 122 downloads in the last month