Skip to content

Instantly share code, notes, and snippets.

@jarmoj
jarmoj / AlwaysAuthenticatedHandler.py
Created October 17, 2013 07:13
Using Python metaclass to create a metaclass factory that decorates all tornado handler methods with tornado.web.authenticated when a handler inherits from AuthenticatedHandler.
import tornado.web
class BaseHandler(tornado.web.RequestHandler):
pass
def MetaClassFactory(function):
class MetaClass(type):
def __new__(meta, classname, bases, classDict):
newClassDict = {}