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.utils.functional import curry
|
||||
|
||||
import types
|
||||
|
||||
def add_manipulators(sender):
|
||||
cls = sender
|
||||
cls.add_to_class('AddManipulator', ModelAddManipulator)
|
||||
|
@ -33,20 +35,12 @@ class ManipulatorDescriptor(object):
|
|||
if not self.man:
|
||||
# Create a class which inherits from the MANIPULATOR class given in the class,
|
||||
# and the appropriate automatic manipulator,
|
||||
class Man(self.get_base_manipulator(type), self.base):
|
||||
pass
|
||||
|
||||
Man._prepare(type)
|
||||
Man.__name__ = self.name
|
||||
self.man = Man
|
||||
return self.man
|
||||
|
||||
def get_base_manipulator(self, type):
|
||||
bases = [ self.base ]
|
||||
if hasattr(type, 'MANIPULATOR'):
|
||||
man = type.MANIPULATOR
|
||||
else:
|
||||
man = self.empty
|
||||
return man
|
||||
bases = [type.MANIPULATOR] + bases
|
||||
self.man = types.ClassType(self.name, tuple(bases), {})
|
||||
self.man._prepare(type)
|
||||
return self.man
|
||||
|
||||
class AutomaticManipulator(Manipulator):
|
||||
def _prepare(cls, model):
|
||||
|
|
Loading…
Reference in New Issue