On Sunday 07 February 2010 10:45:29 Florian Apolloner wrote:
> Hi,
> 
> first of all, I agree with Luke that it's hard to fix this if it's
> possible at all [1]. The only real problem I have with this ticket
> beeing closed is the backwards compatibility issue. Decorating
>  admin views worked just fine in 1.1 and r11660 broke it (At least
>  I hope it worked in 1.1, but as the admin view wasn't decorated at
>  all there, it should have worked). Imho we should at least
>  consider documenting it, and maybe mention it in the release
>  notes, as custom admin code might break by an upgrade from 1.1 to
>  1.2.

I've thought some more about it, and I think you are right.  
Descriptors hurt my head, and descriptors plus decorators and 
decorator decorators (like auto_adapt_to_methods) are particularly 
bad!

Python 3.0 is actually more helpful here, as it does away with unbound 
methods - they are just functions. That helps to clarify that your 
pattern (as on the ticket) is not actually strange, and ought to work 
- SomeClass.method is just a function, and it is the function as 
originally defined, so it ought to work as an assignment in that 
context.

Anyway, could you try the attached patch?  My experiments suggest it 
should fix the issue, but coming up with it hurt my brain too much for 
me to do any more!

Luke

-- 
"Yes, wearily I sit here, pain and misery my only companions. And 
vast intelligence of course. And infinite sorrow. And..." (Marvin 
the paranoid android)

Luke Plant || http://lukeplant.me.uk/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Index: django/utils/decorators.py
===================================================================
--- django/utils/decorators.py	(revision 12380)
+++ django/utils/decorators.py	(working copy)
@@ -35,6 +35,8 @@
     def __call__(self, *args, **kwargs):
         return self.decorator(self.func)(*args, **kwargs)
     def __get__(self, instance, owner):
+        if instance is None:
+            return self
         return self.decorator(self.func.__get__(instance, owner))
 
 def auto_adapt_to_methods(decorator):

Reply via email to