magic-removal: ManipulatorDescriptor simplification.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1753 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d316f6a8cd
commit
fe524625ed
|
@ -7,6 +7,8 @@ from django.dispatch import dispatcher
|
||||||
from django.db.models import signals
|
from django.db.models import signals
|
||||||
from django.utils.functional import curry
|
from django.utils.functional import curry
|
||||||
|
|
||||||
|
import types
|
||||||
|
|
||||||
def add_manipulators(sender):
|
def add_manipulators(sender):
|
||||||
cls = sender
|
cls = sender
|
||||||
cls.add_to_class('AddManipulator', ModelAddManipulator)
|
cls.add_to_class('AddManipulator', ModelAddManipulator)
|
||||||
|
@ -33,20 +35,12 @@ class ManipulatorDescriptor(object):
|
||||||
if not self.man:
|
if not self.man:
|
||||||
# Create a class which inherits from the MANIPULATOR class given in the class,
|
# Create a class which inherits from the MANIPULATOR class given in the class,
|
||||||
# and the appropriate automatic manipulator,
|
# and the appropriate automatic manipulator,
|
||||||
class Man(self.get_base_manipulator(type), self.base):
|
bases = [ self.base ]
|
||||||
pass
|
|
||||||
|
|
||||||
Man._prepare(type)
|
|
||||||
Man.__name__ = self.name
|
|
||||||
self.man = Man
|
|
||||||
return self.man
|
|
||||||
|
|
||||||
def get_base_manipulator(self, type):
|
|
||||||
if hasattr(type, 'MANIPULATOR'):
|
if hasattr(type, 'MANIPULATOR'):
|
||||||
man = type.MANIPULATOR
|
bases = [type.MANIPULATOR] + bases
|
||||||
else:
|
self.man = types.ClassType(self.name, tuple(bases), {})
|
||||||
man = self.empty
|
self.man._prepare(type)
|
||||||
return man
|
return self.man
|
||||||
|
|
||||||
class AutomaticManipulator(Manipulator):
|
class AutomaticManipulator(Manipulator):
|
||||||
def _prepare(cls, model):
|
def _prepare(cls, model):
|
||||||
|
|
Loading…
Reference in New Issue