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

magic-removal: Collapsed else statements in SingleRelatedObjectDescriptor and ManyRelatedObjectsDescriptor

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2242 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-02-03 19:11:04 +00:00
parent fe94847e2c
commit ce0c6887d6

View File

@ -74,7 +74,6 @@ class SingleRelatedObjectDescriptor(object):
def __get__(self, instance, instance_type=None): def __get__(self, instance, instance_type=None):
if instance is None: if instance is None:
raise AttributeError, "%s must be accessed via instance" % self._field.name raise AttributeError, "%s must be accessed via instance" % self._field.name
else:
cache_name = self._field.get_cache_name() cache_name = self._field.get_cache_name()
try: try:
return getattr(instance, cache_name) return getattr(instance, cache_name)
@ -94,7 +93,8 @@ class SingleRelatedObjectDescriptor(object):
class ManyRelatedObjectsDescriptor(object): class ManyRelatedObjectsDescriptor(object):
# This class provides the functionality that makes the related-object # This class provides the functionality that makes the related-object
# managers available as attributes on a model class, for fields that have # managers available as attributes on a model class, for fields that have
# multiple "remote" values. # multiple "remote" values and have a ManyToManyField pointed at them by
# some other model (rather than having a ManyToManyField themselves).
# In the example "poll.choice_set", the choice_set attribute is a # In the example "poll.choice_set", the choice_set attribute is a
# ManyRelatedObjectsDescriptor instance. # ManyRelatedObjectsDescriptor instance.
def __init__(self, related, rel_type): def __init__(self, related, rel_type):
@ -104,7 +104,6 @@ class ManyRelatedObjectsDescriptor(object):
def __get__(self, instance, instance_type=None): def __get__(self, instance, instance_type=None):
if instance is None: if instance is None:
raise AttributeError, "Manager must be accessed via instance" raise AttributeError, "Manager must be accessed via instance"
else:
# Dynamically create a class that subclasses the related # Dynamically create a class that subclasses the related
# model's default manager. # model's default manager.
superclass = self.related.model._default_manager.__class__ superclass = self.related.model._default_manager.__class__