Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (23 sloc) 847 Bytes
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
import new
import inspect
class MetaClass(type):
def __new__(self, classname, classbases, classdict):
try:
frame = inspect.currentframe()
frame = frame.f_back
if frame.f_locals.has_key(classname):
old_class = frame.f_locals.get(classname)
for name, func in classdict.items():
if inspect.isfunction(func):
setattr(old_class, name, func)
return old_class
return type.__new__(self, classname, classbases, classdict)
finally:
del frame
class MetaObject(object):
__metaclass__ = MetaClass
class User(MetaObject):
def test(self):
print "Injection successful"