Django

Code

Changeset 6276

Show
Ignore:
Timestamp:
09/15/07 05:57:03 (1 year ago)
Author:
mtredinnick
Message:

Fixed #5487 -- Added deepcopying ability to lazy() objects, along with a test to demonstrate why the previous code failed. Debugging and patch from John Buchanan.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/functional.py

    r5632 r6276  
     1import copy 
     2 
    13def curry(_curried_func, *args, **kwargs): 
    24    def _curried(*moreargs, **morekwargs): 
     
    102104                raise AssertionError('__mod__ not supported for non-string types') 
    103105 
     106        def __deepcopy__(self, memo): 
     107            result = copy.copy(self) 
     108            memo[id(self)] = result 
     109            return result 
     110 
    104111    def __wrapper__(*args, **kw): 
    105112        # Creates the proxy object, instead of the actual value. 
  • django/trunk/tests/regressiontests/forms/regressions.py

    r6090 r6276  
    6161>>> deactivate() 
    6262 
     63Deep copying translated text shouldn't raise an error 
     64>>> from django.utils.translation import gettext_lazy 
     65>>> class CopyForm(Form): 
     66...     degree = IntegerField(widget=Select(choices=((1, gettext_lazy('test')),))) 
     67>>> f = CopyForm() 
     68 
    6369####################### 
    6470# Miscellaneous Tests #