Author: lukeplant
Date: 2008-12-02 16:09:51 -0600 (Tue, 02 Dec 2008)
New Revision: 9550

Modified:
   django/trunk/django/db/models/fields/related.py
Log:
Fixed #8248: made help() work on models and improved introspection support.

Descriptors now return themselves when accessed via the class, as per standard
Python descriptors like property().



Modified: django/trunk/django/db/models/fields/related.py
===================================================================
--- django/trunk/django/db/models/fields/related.py     2008-12-02 18:42:30 UTC 
(rev 9549)
+++ django/trunk/django/db/models/fields/related.py     2008-12-02 22:09:51 UTC 
(rev 9550)
@@ -175,7 +175,7 @@
 
     def __get__(self, instance, instance_type=None):
         if instance is None:
-            raise AttributeError, "%s must be accessed via instance" % 
self.related.opts.object_name
+            return self
 
         try:
             return getattr(instance, self.cache_name)
@@ -223,7 +223,7 @@
 
     def __get__(self, instance, instance_type=None):
         if instance is None:
-            raise AttributeError, "%s must be accessed via instance" % 
self.field.name
+            return self
         cache_name = self.field.get_cache_name()
         try:
             return getattr(instance, cache_name)
@@ -287,7 +287,7 @@
 
     def __get__(self, instance, instance_type=None):
         if instance is None:
-            raise AttributeError, "Manager must be accessed via instance"
+            return self
 
         rel_field = self.related.field
         rel_model = self.related.model
@@ -500,7 +500,7 @@
 
     def __get__(self, instance, instance_type=None):
         if instance is None:
-            raise AttributeError, "Manager must be accessed via instance"
+            return self
 
         # Dynamically create a class that subclasses the related
         # model's default manager.
@@ -545,7 +545,7 @@
 
     def __get__(self, instance, instance_type=None):
         if instance is None:
-            raise AttributeError, "Manager must be accessed via instance"
+            return self
 
         # Dynamically create a class that subclasses the related
         # model's default manager.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to