Hi Lukasz,
Great stuff! Thanks for taking the effort to implement this and put it
out in the open. It's a fantastic example of the sort of thing that
can be very useful without needing to be part of core, which is the
reason that we put the object-based permissions API into the auth
backends.
Regarding admin app integration -- integration of object-level
permissions with the admin app is one area where I am aware there are
some bugs (or, at least, some areas where the object-based permissions
API isn't being used as it should). This aspect of Django's admin
could do with some attention, so if your experience of implementing an
object-based permissions backend has you contemplating a bigger
project, auditing the admin for adherence to object-based permissions
could be an interesting candidate.
Yours,
Russ Magee %-)
There are two possible readings of the global obj=None case.
a) A user must have the global permission in order to be granted the
permission for individual objects. This means that the global
permission is a 'gatekeeper' of sorts for individual object
permissions.
b) The global permission is the 'fallback' permission if a specific
object permssion doesn't exist. That is the obj=None permission is the
"allow all" permission.
My reading of the code and docs [1] [2] is that (b) is the intended
interpretation. From a practical standpoint, this also makes sense: in
the case of (a), there is no way to grant a wildcard permission.
[1] http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.has_perm
[2] http://code.djangoproject.com/wiki/RowLevelPermissions
So - in terms of the practical situation you describe; this means that
a user can only edit a specific flatpage if they have the change
permission for a specific instance, *or* they have the global obj=None
permission.
The issue that cascades on from this is the UX issue of how to
represent an object that you can't edit. Should it be displayed, but
not presented as a link? Should it be hidden entirely?
Yours,
Russ Magee %-)