Is it worth asking this question is dev group?

On Dec 31 2008, 1:56 am, Artem Skvira <artem.skv...@gmail.com> wrote:
> Hi all,
>
> I have some issues with djangopermissionsmodel. Please bear in mind
> that I have just started learning django so feel free to correct me if
> I'm wrong :)
>
> First of all it was hard to find how one can add a custom permission
> to list ofpermissionsof a model instance.
> I ended up with a code like this:
>
>         from ... import model
>         ...
>         c_type = ContentType.objects.get_for_model(model)
>         p = Permission.objects.get(codename=name, content_type=c_type)
>         user.user_permissions.add(p)
>
> It does look like rather generic task to me, and If that is the right
> way of doing that, it could be implemented as a helper function in
> django, alongside with has_perm(), get_all_permissions() and others.
> Or is there something like that already?
>
> Second thing which I have problems understanding is a naming
> convention for .has_perm() function parameter. Why for god's sake it
> omits model name, including only package name and permission name?
>
> Here is the quote from documentation:
>
>         has_perm(perm)
>                 Returns True if the user has the specified permission, where 
> perm is
> in the format "package.codename"
>
> It's easy to imagine a situation when one has got several 
> custompermissionswith same name for different models within same package.
> Is this going to cause some sort of conflict or wrong name resolution
> when using has_perm()?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to