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):
@functools.wraps(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:
abort(403)
else:
return view(user=user, *args, **kwargs)
return decorated_view
@login_required
def view(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.
For more info, check out the source code – it’s 27 lines.
Metadata
Release files for dart 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dart-1.0.tar.gz | 2.0 kB | Without provenance | Details for dart-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dart-1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for dart-1.0-py2.py3-none-any.whl |
Total release size: 5.4 kB
Release files / dart-1.0.tar.gz
| Download URL | dart-1.0.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fdceb359ee781e7853186cfc39d061902fb2d2d8573f90430323a9ff784c2c06
|
|
BLAKE2b-256 checksum How to use checksums |
89f763c55a348968a67d8034b12d98c0b9213204722d7cccbfe296b185cd3bb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / dart-1.0-py2.py3-none-any.whl
| Download URL | dart-1.0-py2.py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
967f3d0beb0db32f8c3cb868d701cf7b1e59227b94be305a955d59ac066173ab
|
|
BLAKE2b-256 checksum How to use checksums |
f2c4eb080648ebdee8f9342e5f8af59b9643f645123e4334b37e2c7684fa1435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dart 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.