Beispiel #1
0
 def __get__(self, instance, instance_type=None):
     try:
         return SingleRelatedObjectDescriptor.__get__(
             self, instance, instance_type)
     except self.related.model.DoesNotExist:
         setattr(instance, self.cache_name, None)
         return None
Beispiel #2
0
 def __get__(self, instance, instance_type=None):
     """ See if we've stored a DoesNotExist exception from last time,
         if so, just raise that.  Else... do the look up and store
         the DoesNotExist exception if we get one.
     """
     if getattr(instance, self.cache_name, None) is None:
         previous_exc = getattr(instance, self.get_exception_cache_name(), None)
         if previous_exc:
             raise previous_exc
     try:
         #This is effectively super(), but because it's __get__ it's a little bit magical...
         return SingleRelatedObjectDescriptor.__get__(self, instance, instance_type)
     except self.related.model.DoesNotExist, e:
         setattr(instance, self.get_exception_cache_name(), e)
         raise
Beispiel #3
0
 def __get__(self, instance, instance_type=None):
     """ See if we've stored a DoesNotExist exception from last time,
         if so, just raise that.  Else... do the look up and store
         the DoesNotExist exception if we get one.
     """
     if getattr(instance, self.cache_name, None) is None:
         previous_exc = getattr(instance, self.get_exception_cache_name(),
                                None)
         if previous_exc:
             raise previous_exc
     try:
         #This is effectively super(), but because it's __get__ it's a little bit magical...
         return SingleRelatedObjectDescriptor.__get__(
             self, instance, instance_type)
     except self.related.model.DoesNotExist, e:
         setattr(instance, self.get_exception_cache_name(), e)
         raise
Beispiel #4
0
 def __get__(self, instance, instance_type=None):
     try:
         return SingleRelatedObjectDescriptor.__get__(self, instance, instance_type)
     except self.related.model.DoesNotExist:
         setattr(instance, self.cache_name, None)
         return None