Created
January 4, 2010 21:30
-
-
Save fitzgen/268880 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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