Django

Code

Changeset 4688

Show
Ignore:
Timestamp:
03/08/07 23:34:42 (2 years ago)
Author:
mtredinnick
Message:

Fixed #3678 -- Implemented SortedDict.copy().

Files:

Legend:

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

    r4640 r4688  
    9292        "Returns the value of the item at the given zero-based index." 
    9393        return self[self.keyOrder[index]] 
     94 
     95    def copy(self): 
     96        "Returns a copy of this object." 
     97        # This way of initialising the copy means it works for subclasses, too. 
     98        obj = self.__class__(self) 
     99        obj.keyOrder = self.keyOrder 
     100        return obj 
    94101 
    95102class MultiValueDictKeyError(KeyError): 
  • django/trunk/tests/regressiontests/datastructures/tests.py

    r4684 r4688  
    5151>>> d['one'] 
    5252'not one' 
     53>>> d.keys() == d.copy().keys() 
     54True 
    5355 
    5456### DotExpandedDict ############################################################