Commits

Anonymous committed ca9f005

[soc2009/multidb] Merged up to trunk r11901.

  • Participants
  • Parent commits 4c2c75c
  • Branches soc2009/multidb

Comments (0)

Files changed (24)

django/contrib/admin/widgets.py

 Form Widget classes specific to the Django admin site.
 """
 
-import copy
+import django.utils.copycompat as copy
 
 from django import forms
 from django.forms.widgets import RadioFieldRenderer

django/contrib/gis/geos/tests/test_geos.py

 
     def test22_copy(self):
         "Testing use with the Python `copy` module."
-        import copy
+        import django.utils.copycompat as copy
         poly = GEOSGeometry('POLYGON((0 0, 0 23, 23 23, 23 0, 0 0), (5 5, 5 10, 10 10, 10 5, 5 5))')
         cpy1 = copy.copy(poly)
         cpy2 = copy.deepcopy(poly)

django/contrib/gis/geos/tests/test_geos_mutation.py

 # Modified from original contribution by Aryeh Leib Taurog, which was
 # released under the New BSD license.
 import unittest
+
+import django.utils.copycompat as copy
+
 from django.contrib.gis.geos import *
 from django.contrib.gis.geos.error import GEOSIndexError
-import copy
 
 def getItem(o,i): return o[i]
 def delItem(o,i): del o[i]

django/contrib/gis/tests/layermap/tests.py

-import os, unittest
-from copy import copy
+import os
+import unittest
 from decimal import Decimal
-from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping
-from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
+
+from django.utils.copycompat import copy
+
 from django.contrib.gis.gdal import DataSource
 from django.contrib.gis.tests.utils import mysql
+from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
+
+from models import City, County, CountyFeat, Interstate, ICity1, ICity2, State, city_mapping, co_mapping, cofeat_mapping, inter_mapping
 
 shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
 city_shp = os.path.join(shp_path, 'cities', 'cities.shp')

django/db/models/base.py

-import copy
 import types
 import sys
 import os
 from django.db import connections, transaction, DatabaseError, DEFAULT_DB_ALIAS
 from django.db.models import signals
 from django.db.models.loading import register_models, get_model
+import django.utils.copycompat as copy
 from django.utils.functional import curry
 from django.utils.encoding import smart_str, force_unicode, smart_unicode
 from django.conf import settings

django/db/models/expressions.py

-from copy import deepcopy
 from datetime import datetime
 
 from django.utils import tree
+from django.utils.copycompat import deepcopy
 
 class ExpressionNode(tree.Node):
     """

django/db/models/fields/__init__.py

-import copy
 import datetime
 import decimal
 import os
 import re
 import time
 
+import django.utils.copycompat as copy
+
 from django.db import connection
 from django.db.models import signals
 from django.db.models.fields.subclassing import LegacyConnection

django/db/models/fields/files.py

-import copy
 import datetime
 import os
 
+import django.utils.copycompat as copy
+
 from django.conf import settings
 from django.db.models.fields import Field
 from django.core.files.base import File, ContentFile

django/db/models/manager.py

-import copy
+import django.utils.copycompat as copy
 from django.db.models.query import QuerySet, EmptyQuerySet, insert_query
 from django.db.models import signals
 from django.db.models.fields import FieldDoesNotExist

django/db/models/query.py

 from django.db.models.fields import DateField
 from django.db.models.query_utils import Q, select_related_descend, CollectedObjects, CyclicDependency, deferred_class_factory
 from django.db.models import signals, sql
+from django.utils.copycompat import deepcopy
 
 # Used to control how many objects are worked with at once in some cases (e.g.
 # when deleting objects).

django/db/models/query_utils.py

 """
 
 import weakref
-from copy import deepcopy
+from django.utils.copycompat import deepcopy
 
 from django.utils import tree
 from django.utils.datastructures import SortedDict
 
-try:
-    sorted
-except NameError:
-    from django.utils.itercompat import sorted  # For Python 2.3.
-
 
 class CyclicDependency(Exception):
     """

django/db/models/sql/query.py

 all about the internals of models in order to get the information it needs.
 """
 
-from copy import deepcopy
+from django.utils.copycompat import deepcopy
 from django.utils.tree import Node
 from django.utils.datastructures import SortedDict
 from django.utils.encoding import force_unicode

django/forms/fields.py

 Field classes.
 """
 
-import copy
 import datetime
 import os
 import re
 import time
 import urlparse
+from decimal import Decimal, DecimalException
 try:
     from cStringIO import StringIO
 except ImportError:
     from StringIO import StringIO
 
-# Python 2.3 fallbacks
-try:
-    from decimal import Decimal, DecimalException
-except ImportError:
-    from django.utils._decimal import Decimal, DecimalException
-try:
-    set
-except NameError:
-    from sets import Set as set
-
 import django.core.exceptions
+import django.utils.copycompat as copy
 from django.utils.translation import ugettext_lazy as _
 from django.utils.encoding import smart_unicode, smart_str
 

django/forms/forms.py

 Form classes
 """
 
-from copy import deepcopy
-
+from django.utils.copycompat import deepcopy
 from django.utils.datastructures import SortedDict
 from django.utils.html import conditional_escape
 from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode

django/forms/widgets.py

 HTML Widget classes
 """
 
-try:
-    set
-except NameError:
-    from sets import Set as set   # Python 2.3 fallback
-
-import copy
+import django.utils.copycompat as copy
 from itertools import chain
 from django.conf import settings
 from django.utils.datastructures import MultiValueDict, MergeDict

django/http/__init__.py

         return result
 
     def __deepcopy__(self, memo):
-        import copy
+        import django.utils.copycompat as copy
         result = self.__class__('', mutable=True)
         memo[id(self)] = result
         for key, value in dict.items(self):

django/utils/_decimal.py

     'setcontext', 'getcontext'
 ]
 
-import copy as _copy
+import django.utils.copycompat as _copy
 
 #Rounding
 ROUND_DOWN = 'ROUND_DOWN'

django/utils/copycompat.py

+"""
+Fixes Python 2.4's failure to deepcopy unbound functions.
+"""
+
+import copy
+import types
+
+# Monkeypatch copy's deepcopy registry to handle functions correctly.
+if (hasattr(copy, '_deepcopy_dispatch') and types.FunctionType not in copy._deepcopy_dispatch):
+    copy._deepcopy_dispatch[types.FunctionType] = copy._deepcopy_atomic
+
+# Pose as the copy module now.
+del copy, types
+from copy import *

django/utils/datastructures.py

-from copy import deepcopy
+from django.utils.copycompat import deepcopy
 
 
 class MergeDict(object):
         return self.__class__(super(MultiValueDict, self).items())
 
     def __deepcopy__(self, memo=None):
-        import copy
+        import django.utils.copycompat as copy
         if memo is None:
             memo = {}
         result = self.__class__()

django/utils/functional.py

             memo[id(self)] = result
             return result
         else:
-            import copy
-            return copy.deepcopy(self._wrapped, memo)
+            # Changed to use deepcopy from copycompat, instead of copy
+            # For Python 2.4.
+            from django.utils.copycompat import deepcopy
+            return deepcopy(self._wrapped, memo)
 
     # Need to pretend to be the wrapped class, for the sake of objects that care
     # about this (especially in equality tests)

django/utils/tree.py

 ORM.
 """
 
-from copy import deepcopy
+from django.utils.copycompat import deepcopy
 
 class Node(object):
     """

tests/regressiontests/dispatch/tests/test_dispatcher.py

 from django.dispatch import Signal
 import unittest
-import copy
 import sys
 import gc
+import django.utils.copycompat as copy
 
 if sys.platform.startswith('java'):
     def garbage_collect():

tests/regressiontests/extra_regress/models.py

-import copy
 import datetime
 
+import django.utils.copycompat as copy
+
 from django.contrib.auth.models import User
 from django.db import models
 from django.db.models.query import Q

tests/regressiontests/utils/tests.py

         self.assertEqual(_ComplexObject, SimpleLazyObject(complex_object).__class__)
 
     def test_deepcopy(self):
-        import copy
+        import django.utils.copycompat as copy
         # Check that we *can* do deep copy, and that it returns the right
         # objects.