Registry / web-framework / dry-rest-permissions

dry-rest-permissions

JSON →
library0.1.10pypypiunverified

Rules-based permissions for Django REST Framework, enabling complex permission logic through a declarative, rule-based approach. Current version 0.1.10, released Jun 15, 2020. Low release cadence, maintained as of latest commit Aug 2022.

pip install dry-rest-permissions
INSTALL
IMPORT
SIG · DRY-REST-PERMISSIO
D
dry-rest-permissions
web-frameworkpythonv0.1.10
Install
1.5s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DRYPermissions
✓ from dry_rest_permissions import DRYPermissions
✗ from dry_rest_permissions.generics import DRYPermissions

Apply DRYPermissions to a viewset. Define permissions via 'read_permissions' and 'write_permissions' on model's DRYMeta class.

from rest_framework import viewsets from myapp.models import MyModel from myapp.serializers import MyModelSerializer from dry_rest_permissions.generics import DRYPermissions class MyModelViewSet(viewsets.ModelViewSet): queryset = MyModel.objects.all() serializer_class = MyModelSerializer permission_classes = (DRYPermissions,)
Debug
Known issues
breakingDRYPermissions requires explicit permissions defined on model class; if no DRYMeta with permissions is defined, all requests are denied.
fix
Define a DRYMeta inner class on your model with read_permissions and write_permissions callable.
affects: all
gotchaThe 'request.user' is not automatically available in permissions callables; you must pass it explicitly via the kwargs.
fix
Use signature: def permission_function(user, obj=None): ... and DRYPermissions will pass request.user.
affects: 0.1.0+
deprecatedThe 'dry_rest_permissions.generics.DRYGlobalPermissions' class behavior may change in future releases; prefer using DRYPermissions with global permission logic.
fix
Use DRYPermissions and implement global check in write_permissions/read_permissions with obj=None.
affects: <=0.1.10
Upgrade
Version history
0.1.10latest on PyPI · released Jan 31, 2018
Audit
Dependencies
djangorequiredFramework dependency
djangorestframeworkrequiredRequired for DRF integration
Agent activity
29 hits · last 30 days
node
28
OpenAI (training)
1
Resources