Skip to content

Instantly share code, notes, and snippets.

@fitzgen
Created January 4, 2010 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitzgen/268880 to your computer and use it in GitHub Desktop.
Save fitzgen/268880 to your computer and use it in GitHub Desktop.
class GenericViewMeta(type):
def __new__(mcs, name, bases, attrs):
cls = type.__new__(mcs, name, bases, attrs)
if hasattr(cls, "decorators"):
decorators = list(cls.decorators)
# Sort the decorators by order they would be applied if using the @
# syntax.
decorators.reverse()
for d in decorators:
cls.__call__ = d(cls.__call__)
return cls
# Need to add
# ``__metaclass__ = GenericViewMeta``
# to the GenericView class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment