@register.render_tag
def set_page_permissions(context, token):
 page = context[token.split_contents()[1]]
 model = page.get_content_model()
 try:
  opts = model._meta
 except AttributeError:
  if (model is None):
   error = _(u'Could not load the model for the following page, was it removed?')
   obj = page
  else:
   error = _(u'An error occured with the following class. Does it subclass Page directly?')
   obj = model.__class__.__name__
  raise ImproperlyConfigured((error + (u" '%s'" % obj)))
 perm_name = ((opts.app_label + u'.%s_') + opts.object_name.lower())
 request = context[u'request']
 setattr(page, u'perms', {})
 for perm_type in (u'add', u'change', u'delete'):
  perm = request.user.has_perm((perm_name % perm_type))
  perm = (perm and getattr(model, (u'can_%s' % perm_type))(request))
  page.perms[perm_type] = perm
 return u''

@ register . render_tag def set_page_permissions ( context , token ) : page = context [ token . split_contents ( ) [ 1 ] ] model = page . get_content_model ( ) try : opts = model . _meta except AttributeError : if ( model is None ) : error = _ ( u'Could not load the model for the following page, was it removed?' ) obj = page else : error = _ ( u'An error occured with the following class. Does it subclass Page directly?' ) obj = model . __class__ . __name__ raise ImproperlyConfigured ( ( error + ( u" '%s'" % obj ) ) ) perm_name = ( ( opts . app_label + u'.%s_' ) + opts . object_name . lower ( ) ) request = context [ u'request' ] setattr ( page , u'perms' , { } ) for perm_type in ( u'add' , u'change' , u'delete' ) : perm = request . user . has_perm ( ( perm_name % perm_type ) ) perm = ( perm and getattr ( model , ( u'can_%s' % perm_type ) ) ( request ) ) page . perms [ perm_type ] = perm return u''
assigns a permissions dict to the given page instance .