[Django] #12176: curry can't be replaced by functools.partial

View: New views
3 Messages — Rating Filter:   Alert me  

[Django] #12176: curry can't be replaced by functools.partial

by Django-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12176: curry can't be replaced by functools.partial
-----------------------------+----------------------------------------------
 Reporter:  bear330          |       Owner:  nobody    
   Status:  new              |   Milestone:            
Component:  Template system  |     Version:  SVN      
 Keywords:  curry partial    |       Stage:  Unreviewed
Has_patch:  0                |  
-----------------------------+----------------------------------------------
 I think this should not be a bug.

 I do this before:
 {{{
 #!python
 # We make sure we are using Python 2.5, so partial is faster than
 # django's curry function.
 import functools
 from django.utils import functional
 functional.curry = functools.partial
 }}}

 This works fine at 1.0.2 and previous versions.

 After I upgrade to 1.0.4, I got many problems while rendering template. I
 do some investigation, the problem is because
 {{{
 #!python
 def _render_value_in_context(value, context):
     """
     Converts any value to a string to become part of a rendered template.
 This
     means escaping, if required, and conversion to a unicode object. If
 value
     is a string, it is expected to have already been translated.
     """
     value = force_unicode(value)
     if (context.autoescape and not isinstance(value, SafeData)) or
 isinstance(value, EscapeData):
         return escape(value)
     else:
         return value
 }}}

 While rendering node, force_unicode a SafeString will raise error.

 I am just curious, why can't I replace curry with functools.partial?

 Thanks.

--
Ticket URL: <http://code.djangoproject.com/ticket/12176>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12176: curry can't be replaced by functools.partial

by Django-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12176: curry can't be replaced by functools.partial
--------------------------------------+-------------------------------------
          Reporter:  bear330          |         Owner:  nobody      
            Status:  closed           |     Milestone:              
         Component:  Template system  |       Version:  SVN          
        Resolution:  invalid          |      Keywords:  curry partial
             Stage:  Unreviewed       |     Has_patch:  0            
        Needs_docs:  0                |   Needs_tests:  0            
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Changes (by lukeplant):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => invalid
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I don't know, you tell me :-)

 Since you include no information about how you are actually using
 curry/partial, or with what values, it's quite impossible for us to tell
 you.  Also, this isn't a bug, and the bug tracker isn't the place for
 "just curious" questions I'm afraid.

--
Ticket URL: <http://code.djangoproject.com/ticket/12176#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12176: curry can't be replaced by functools.partial

by Django-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12176: curry can't be replaced by functools.partial
--------------------------------------+-------------------------------------
          Reporter:  bear330          |         Owner:  nobody      
            Status:  closed           |     Milestone:              
         Component:  Template system  |       Version:  SVN          
        Resolution:  invalid          |      Keywords:  curry partial
             Stage:  Unreviewed       |     Has_patch:  0            
        Needs_docs:  0                |   Needs_tests:  0            
Needs_better_patch:  0                |  
--------------------------------------+-------------------------------------
Comment (by anonymous):

 Replying to [comment:1 lukeplant]:
 > I don't know, you tell me :-)
 >
 > Since you include no information about how you are actually using
 curry/partial, or with what values, it's quite impossible for us to tell
 you.  Also, this isn't a bug, and the bug tracker isn't the place for
 "just curious" questions I'm afraid.

 Actually, I don't "use" it. I just do functional.curry =
 functools.partial, then django broken.
 While rendering templates, it will raise error because SafeString (which
 uses curry: decode = curry(_proxy_method, method = str.decode)) can't be
 pass to force_unicode function.

 Finally, I am sorry to put a such question here, but I think this "MIGHT"
 be a problem, but I am not sure and curious. :)

--
Ticket URL: <http://code.djangoproject.com/ticket/12176#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---