1
0
mirror of https://github.com/django/django.git synced 2025-06-13 23:49:13 +00:00

magic-removal: Negligible changes to ManipulatorDescriptor

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2101 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-22 05:53:36 +00:00
parent 107f097a98
commit 6d9b4f443c

View File

@ -17,23 +17,23 @@ dispatcher.connect(add_manipulators, signal=signals.class_prepared)
class ManipulatorDescriptor(object): class ManipulatorDescriptor(object):
def __init__(self, name, base): def __init__(self, name, base):
self.man = None self.man = None # Cache of the manipulator class.
self.name = name self.name = name
self.base = base self.base = base
def __get__(self, instance, type=None): def __get__(self, instance, type_=None):
if instance != None: if instance != None:
raise "Manipulator can not be accessed via instance" raise "Manipulator cannot be accessed via instance"
else: else:
if not self.man: if not self.man:
# Create a class that inherits from the "Manipulator" class # Create a class that inherits from the "Manipulator" class
# given in the model class (if specified) and the automatic # given in the model class (if specified) and the automatic
# manipulator. # manipulator.
bases = [self.base] bases = [self.base]
if hasattr(type, 'Manipulator'): if hasattr(type_, 'Manipulator'):
bases = [type.Manipulator] + bases bases = [type_.Manipulator] + bases
self.man = types.ClassType(self.name, tuple(bases), {}) self.man = types.ClassType(self.name, tuple(bases), {})
self.man._prepare(type) self.man._prepare(type_)
return self.man return self.man
class Naming(object): class Naming(object):