@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 = _("Could not load the model for the following page, "
                      "was it removed?")
            obj = page
        else:
            # A missing inner Meta class usually means the Page model
            # hasn't been directly subclassed.
            error = _("An error occured with the following class. Does "
                      "it subclass Page directly?")
            obj = model.__class__.__name__
        raise ImproperlyConfigured(error + " '%s'" % obj)
    perm_name = opts.app_label + ".%s_" + opts.object_name.lower()
    request = context["request"]
    setattr(page, "perms", {})
    for perm_type in ("add", "change", "delete"):
        perm = request.user.has_perm(perm_name % perm_type)
        perm = perm and getattr(model, "can_%s" % perm_type)(request)
        page.perms[perm_type] = perm
    return ""
Assigns a permissions dict to the given page instance, combining
dataset/ETHPy150Open stephenmcd/mezzanine/mezzanine/pages/templatetags/pages_tags.py/set_page_permissions