Copy deepcopy fix to src/web (thanks P. Franklin); removed workaround

svn: r18314
This commit is contained in:
Doug Blank 2011-10-13 10:32:27 +00:00
parent 9b90430c29
commit b07514e0d1
3 changed files with 12 additions and 12 deletions

View File

@ -31,7 +31,6 @@
#------------------------------------------------------------------------
import math
import copy
import sys
from gen.ggettext import gettext as _
#------------------------------------------------------------------------
@ -109,11 +108,7 @@ class AncestorReport(Report):
# Copy the global NameDisplay so that we don't change application
# defaults.
try:
self._name_display = copy.deepcopy(global_name_display)
except:
print >> sys.stderr, "WARNING: unable to deepcopy name_display; continuing..."
self._name_display = global_name_display
self._name_display = copy.deepcopy(global_name_display)
name_format = menu.get_option_by_name("name_format").get_value()
if name_format != 0:
self._name_display.set_default_format(name_format)

View File

@ -34,7 +34,6 @@
#
#------------------------------------------------------------------------
import copy
import sys
from gen.ggettext import gettext as _
#------------------------------------------------------------------------
@ -141,11 +140,7 @@ class DetAncestorReport(Report):
# Copy the global NameDisplay so that we don't change application
# defaults.
try:
self._name_display = copy.deepcopy(global_name_display)
except:
print >> sys.stderr, "WARNING: unable to deepcopy name_display; continuing..."
self._name_display = global_name_display
self._name_display = copy.deepcopy(global_name_display)
name_format = menu.get_option_by_name("name_format").get_value()
if name_format != 0:

View File

@ -130,3 +130,13 @@ CACHE_BACKEND = 'locmem://'
TRANSACTIONS_MANAGED = False
LOCALE_PATHS = tuple()
# In versions < 2.7 python does not properly copy methods when doing a
# deepcopy. This workaround makes the copy work properly. When Gramps no longer
# supports python 2.6, this workaround can be removed.
import sys
if sys.version_info < (2, 7) :
import copy
import types
def _deepcopy_method(x, memo):
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class)
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method