@register.tag
def get_obj_perms(parser, token):
 bits = token.split_contents()
 format = u'{% get_obj_perms user/group for obj as "context_var" %}'
 if ((len(bits) != 6) or (bits[2] != u'for') or (bits[4] != u'as')):
  raise template.TemplateSyntaxError((u'get_obj_perms tag should be in format: %s' % format))
 for_whom = bits[1]
 obj = bits[3]
 context_var = bits[5]
 if ((context_var[0] != context_var[(-1)]) or (context_var[0] not in (u'"', u"'"))):
  raise template.TemplateSyntaxError(u"get_obj_perms tag's context_var argument should be in quotes")
 context_var = context_var[1:(-1)]
 return ObjectPermissionsNode(for_whom, obj, context_var)

@ register . tag def get_obj_perms ( parser , token ) : bits = token . split_contents ( ) format = u'{% get_obj_perms user/group for obj as "context_var" %}' if ( ( len ( bits ) != 6 ) or ( bits [ 2 ] != u'for' ) or ( bits [ 4 ] != u'as' ) ) : raise template . TemplateSyntaxError ( ( u'get_obj_perms tag should be in format: %s' % format ) ) for_whom = bits [ 1 ] obj = bits [ 3 ] context_var = bits [ 5 ] if ( ( context_var [ 0 ] != context_var [ ( - 1 ) ] ) or ( context_var [ 0 ] not in ( u'"' , u"'" ) ) ) : raise template . TemplateSyntaxError ( u"get_obj_perms tag's context_var argument should be in quotes" ) context_var = context_var [ 1 : ( - 1 ) ] return ObjectPermissionsNode ( for_whom , obj , context_var )
returns a list of permissions for a given user/group and obj .