Can't you add the constraint in both code and in the DB. On older sites  
the constraint just won't exist in the DB (Could include it in the release
notes so people can add it to existing sites if they wish).


On Wednesday, September 19, 2012 at 6:40 PM, Anssi Kääriäinen wrote:

> We use the style of "app_label.permission_name" in multiple places of
> our code to refer to given auth.models.Permission. However, there is
> no unique key for that combination, the key is content_type,
> permission_name. I verified that it is actually possible to hit this
> problem by using the Meta.permissions.
>  
> I am not sure what we can do about this... Or if we even need to do
> anything about this.
>  
> Without schema changes we can't have a DB constraint for the key. But,
> maybe we could validate (as part of model validation) that there are
> no overlapping permissions? If the user goes and creates overlapping
> permissions despite of this, we can't do anything about that.
>  
> The reason why I am wondering about this is that I'd like to add
> Permissions.objects.get_permission('app_label.permission_name')
> convenience method. And, while investigating that I realized that the
> app_label, permission name isn't a key...
>  
> I am likely going to add the get_permission() anyways, it will just
> throw "returned more than 1" if the above problem is hit.
>  
> Thoughts?
>  
> - Anssi
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "Django developers" group.
> To post to this group, send email to django-developers@googlegroups.com 
> (mailto:django-developers@googlegroups.com).
> To unsubscribe from this group, send email to 
> django-developers+unsubscr...@googlegroups.com 
> (mailto:django-developers+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/django-developers?hl=en.
>  
>  


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to