Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (23 sloc) 0.847 kb
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"
Jump to Line
Something went wrong with that request. Please try again.