diff --git a/CHANGES.rst b/CHANGES.rst
index 3d5de33..2a06f65 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -6,6 +6,8 @@ Changelog
- Add test coverage computation.
+- Various small Python 3 compatibility changes.
+
3.0.1 (2017-10-18)
------------------
diff --git a/src/Shared/DC/ZRDB/Aqueduct.py b/src/Shared/DC/ZRDB/Aqueduct.py
index 1d257a0..efe4815 100644
--- a/src/Shared/DC/ZRDB/Aqueduct.py
+++ b/src/Shared/DC/ZRDB/Aqueduct.py
@@ -15,7 +15,6 @@
import os
import re
from six import StringIO
-import string
from Acquisition import Implicit
from App.Common import package_home
@@ -137,7 +136,7 @@ def manage_test(self, REQUEST):
result = self(REQUEST)
report = HTML(custom_default_report(self.id, result))
- return apply(report, (self, REQUEST), {self.id: result})
+ return report(*(self, REQUEST), **{self.id: result})
def index_html(self, URL1):
" "
@@ -188,7 +187,7 @@ def default_input_form(id, arguments, action='query', tabs=''):
'Enter query parameters:
'
'
%s | \n' @@ -204,8 +203,7 @@ def default_input_form(id, arguments, action='query', tabs=''): 'default' in a[1] and a[1]['default'] or '' )) , items - ), - '\n'), + )), '\n|||
---|---|---|---|
\n'
'\n'
'%s | \n' % nicify(c['name']),
- columns),
- ''
+ columns)
))
if no_table:
@@ -269,7 +266,7 @@ def custom_default_report(id, result, action='', no_table=0,
% (td, n, c['type'] != 's' and ' null=""' or '', _td))
row = (' %s\n%s\n %s' % (
- tr, string.joinfields(row, delim), _tr))
+ tr, delim.join(row), _tr))
return custom_default_report_src(
id=id, heading=heading, row=row, action=action, no_table=no_table)
@@ -281,11 +278,10 @@ def custom_default_zpt_report(id, result, action='', no_table=0,
columns = result._searchable_result_columns()
__traceback_info__ = columns
heading = ('%s | \n' % nicify(c['name']),
- columns),
- ''
+ columns)
))
if no_table:
@@ -300,7 +296,7 @@ def custom_default_zpt_report(id, result, action='', no_table=0,
% (td, n, n, _td))
row = (' %s\n%s\n %s' % (
- tr, string.joinfields(row, delim), _tr))
+ tr, delim.join(row), _tr))
return custom_default_zpt_report_src(
id=id, heading=heading, row=row, action=action, no_table=no_table)
@@ -425,13 +421,13 @@ def quotedHTML(text,
('"', '"'))):
for char, name in character_entities:
- text = string.replace(text, char, name)
+ text = text.replace(char, name)
return text
def nicify(name):
- name = string.replace(name.strip(), '_', ' ')
+ name = name.strip().replace('_', ' ')
return name[:1].upper() + name[1:]
diff --git a/src/Shared/DC/ZRDB/Aqueduct.py.bak b/src/Shared/DC/ZRDB/Aqueduct.py.bak
new file mode 100644
index 0000000..1d257a0
--- /dev/null
+++ b/src/Shared/DC/ZRDB/Aqueduct.py.bak
@@ -0,0 +1,496 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+import binascii
+import os
+import re
+from six import StringIO
+import string
+
+from Acquisition import Implicit
+from App.Common import package_home
+from DateTime.DateTime import DateTime
+from DocumentTemplate import File
+from DocumentTemplate import HTML
+from OFS.SimpleItem import Item
+from Persistence import Persistent
+from zExceptions import Redirect
+
+# BBB Zope 2.12
+try:
+ from OFS.role import RoleManager
+except ImportError:
+ from AccessControl.Role import RoleManager
+
+
+dtml_dir = os.path.join(package_home(globals()), 'dtml')
+
+InvalidParameter = 'Invalid Parameter'
+
+
+class BaseQuery(Persistent, Item, Implicit, RoleManager):
+
+ _col = None
+ _arg = {}
+ query_date = DateTime()
+ manage_options = ()
+ MissingArgumentError = 'Bad Request'
+
+ def query_year(self):
+ return self.query_date.year()
+
+ def query_month(self):
+ return self.query_date.month()
+
+ def query_day(self):
+ return self.query_date.day()
+
+ def quoted_input(self):
+ return quotedHTML(self.input_src)
+
+ def quoted_report(self):
+ return quotedHTML(self.report_src)
+
+ def _convert(self):
+ self._arg = parse(self.arguments_src)
+
+ def _argdata(self, REQUEST):
+ r = {}
+
+ try:
+ args = self._arg
+ except Exception:
+ self._convert()
+ args = self._arg
+
+ id = self.id
+ missing = []
+
+ for name in args.keys():
+ idname = "%s/%s" % (id, name)
+ try:
+ r[name] = REQUEST[idname]
+ except Exception:
+ try:
+ r[name] = REQUEST[name]
+ except Exception:
+ arg = args[name]
+ try:
+ r[name] = arg['default']
+ except Exception:
+ try:
+ if not arg['optional']:
+ missing.append(name)
+ except Exception:
+ missing.append(name)
+
+ # Note: the code above tries to check if an argument of the
+ # ZSQL method above has the "optional" flag set (in case the
+ # argument is omitted from the ZSQL function call). But there
+ # is neither corresponding code inside the parse() function to
+ # check for the "optional" parameter nor any documentation.
+ # So we omit the check for the optional parameter. There will
+ # be probably no code break but there will be hopefully more code
+ # to work as supposed to work.
+
+# if missing:
+# raise self.MissingArgumentError( \
+# "The following arguments were omitted " \
+# " from the ZSQL method call: %s" % str(missing))
+#
+
+ return r
+
+
+class Searchable(BaseQuery):
+
+ def _searchable_arguments(self):
+
+ try:
+ return self._arg
+ except Exception:
+ self._convert()
+ return self._arg
+
+ def _searchable_result_columns(self):
+ return self._col
+
+ def manage_testForm(self, REQUEST):
+ """Provide testing interface"""
+ input_src = default_input_form(self.title_or_id(),
+ self._searchable_arguments(),
+ 'manage_test')
+ return HTML(input_src)(self, REQUEST)
+
+ def manage_test(self, REQUEST):
+ 'Perform an actual query'
+
+ result = self(REQUEST)
+ report = HTML(custom_default_report(self.id, result))
+ return apply(report, (self, REQUEST), {self.id: result})
+
+ def index_html(self, URL1):
+ " "
+ raise Redirect("%s/manage_testForm" % URL1)
+
+
+class Composite(object):
+
+ def _getquery(self, id):
+
+ o = self
+ i = 0
+ while 1:
+ __traceback_info__ = o
+ q = getattr(o, id)
+ try:
+ if hasattr(q, '_searchable_arguments'):
+ try:
+ q = q.__of__(self.aq_parent)
+ except Exception:
+ pass
+ return q
+ except Exception:
+ pass
+ if i > 100:
+ raise AttributeError(id)
+ i = i + 1
+ o = o.aq_parent
+
+ def myQueryIds(self):
+ return map(
+ lambda k, queries=self.queries:
+ {'id': k, 'selected': k in queries},
+ self.ZQueryIds())
+
+
+def default_input_form(id, arguments, action='query', tabs=''):
+ if arguments:
+ items = arguments.items()
+ return (
+ "%s\n%s%s" % (
+ '\n'
+ ' |
', '
', '', '', ',\n' + else: + tr, _tr, td, _td, delim = '', '
', '', '', ',\n' + else: + tr, _tr, td, _td, delim = '