On 15/02/11 17:31, hank23 wrote:
> So my question is what type of object is returned by user.user_permissions?

First, N.B. you probably want to look at user.get_all_permissions().
user_permissions in particular doesn't represent all permissions a user
"has" in the django.contrib.auth system, only ones granted directly to
the user, not ones they have e.g. by way of group membership.

Anyway, to answer your question: User to Permission is a ManyToManyField

http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L218

There's involved stuff going on underneath for all such fields, but you
don't usually have to think about it - user.user_permissions winds up
being a specialized sort of Manager, with the usual manager methods -
user.user_permissions.all() etc. So the django docs for managers and
related fields apply:

http://docs.djangoproject.com/en/1.2/topics/db/managers/
http://docs.djangoproject.com/en/1.2/ref/models/relations/


> Or alternatively how can I code type check logic to figure out
> what type it is?

Python has various builtins, type(some.thing) among them.(and
dir(some.thing) will list an object's attrs). Refer to python docs, there.

But you might also want to install ipython if you haven't already.  It
provides a more full-featured interactive repl for python, that django
`./manage.py shell` will pick up and use automatically if present. Then
you can just type `some.thing?` at the shell find out all sorts of stuff
about some.thing, and have get tab completion of obj attrs and such.

http://ipython.github.com/ipython-doc/stable/html/interactive/reference.html#dynamic-object-information

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

Reply via email to