Skip to content

Commit

Permalink
Raise a more meaningful error message when someone tries to subclass …
Browse files Browse the repository at this point in the history
…a custom content type, which isn't supported.
  • Loading branch information
stephenmcd committed Dec 19, 2011
1 parent 802f0ee commit 7b17b08
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mezzanine/pages/templatetags/pages_tags.py
@@ -1,6 +1,7 @@

from collections import defaultdict

from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db.models import get_models
from django.template import TemplateSyntaxError, Variable
Expand Down Expand Up @@ -123,7 +124,14 @@ def set_page_permissions(context, token):
"""
page = context[token.split_contents()[1]]
model = page.get_content_model()
opts = model._meta
try:
opts = model._meta
except AttributeError:
# 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?")
raise ImproperlyConfigured(error + " '%s'" % page.__class__.__name__)
perm_name = opts.app_label + ".%s_" + opts.object_name.lower()
request = context["request"]
setattr(page, "perms", {})
Expand Down

0 comments on commit 7b17b08

Please sign in to comment.