Skip to content

Commit

Permalink
Merge pull request #4 from zopefoundation/py3
Browse files Browse the repository at this point in the history
Python 3 compatibility reached
  • Loading branch information
dataflake committed May 15, 2017
2 parents d8e206a + 90a477e commit afb3d46
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 184 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ sudo: false
dist: trusty
python:
- 2.7
- 3.4
- 3.5
- 3.6
install:
- python bootstrap.py
- bin/buildout
script:
- bin/test -v1
notifications:
email: false
cache:
pip: true
directories:
- eggs/
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
3.0.0 (unreleased)
------------------

- Python 3 compatibility


3.0.0b1 (2017-05-03)
--------------------
Expand Down
12 changes: 12 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
[buildout]
extensions =
mr.developer
extends =
https://raw.githubusercontent.com/zopefoundation/Zope/master/sources.cfg
https://raw.githubusercontent.com/zopefoundation/Zope/master/versions-prod.cfg
develop = .
parts = interpreter test
auto-checkout =
Record
Zope2

[sources]
Zope2 = git ${remotes:github}/Zope pushurl=${remotes:github_push}/Zope
Record = git ${remotes:github}/Record pushurl=${remotes:github_push}/Record branch=add_hash

[interpreter]
recipe = zc.recipe.egg
Expand Down
23 changes: 21 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,28 @@
packages=find_packages('src'),
namespace_packages=['Products', 'Shared', 'Shared.DC'],
package_dir={'': 'src'},
classifiers=[
"Development Status :: 6 - Mature",
"Environment :: Web Environment",
"Framework :: Zope2",
"License :: OSI Approved :: Zope Public License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Database",
"Topic :: Database :: Front-Ends",
],
install_requires=[
'setuptools',
'Zope2 >= 4.0dev',
'six',
'Zope2 > 4.0a4',
'RestrictedPython >= 4.0dev',
'AccessControl >= 4.0dev',
'Persistence >= 3.0dev',
Expand All @@ -45,7 +64,7 @@
'DocumentTemplate',
'ExtensionClass >= 4.1a1',
'Missing',
'Record',
'Record > 3.3',
'transaction',
'zope.interface',
'zExceptions',
Expand Down
36 changes: 17 additions & 19 deletions src/Shared/DC/ZRDB/Aqueduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
##############################################################################

import binascii
from cStringIO import StringIO
import os
import re
from six import StringIO
import string

from Acquisition import Implicit
Expand Down Expand Up @@ -99,9 +99,9 @@ def _argdata(self, REQUEST):
# to work as supposed to work.

# if missing:
# raise self.MissingArgumentError, \
# raise self.MissingArgumentError( \
# "The following arguments were omitted " \
# " from the ZSQL method call: %s" % str(missing)
# " from the ZSQL method call: %s" % str(missing))
#

return r
Expand Down Expand Up @@ -136,7 +136,7 @@ def manage_test(self, REQUEST):

def index_html(self, URL1):
" "
raise Redirect, ("%s/manage_testForm" % URL1)
raise Redirect("%s/manage_testForm" % URL1)

class Composite:

Expand All @@ -153,7 +153,7 @@ def _getquery(self,id):
except: pass
return q
except: pass
if i > 100: raise AttributeError, id
if i > 100: raise AttributeError(id)
i=i+1
o=o.aq_parent

Expand Down Expand Up @@ -252,7 +252,7 @@ def custom_default_report(id, result, action='', no_table=0,
for c in columns:
n=c['name']
if goofy(n) is not None:
n='expr="_[\'%s]"' % (`'"'+n`[2:])
n='expr="_[\'%s]"' % (repr('"'+n)[2:])
row.append(' %s<dtml-var %s%s>%s'
% (td,n,c['type']!='s' and ' null=""' or '',_td))

Expand Down Expand Up @@ -294,7 +294,7 @@ def custom_default_zpt_report(id, result, action='', no_table=0,


def detypify(arg):
l=string.find(arg,':')
l=arg.find(':')
if l > 0: arg=arg[:l]
return arg

Expand Down Expand Up @@ -372,7 +372,7 @@ def parse(text,
l = len(mo.group(1))
else:
if not text or not text.strip(): return Args(result,keys)
raise InvalidParameter, text
raise InvalidParameter(text)

lt=name.find(':')
if lt > 0:
Expand All @@ -399,8 +399,8 @@ def quotedHTML(text,
return text

def nicify(name):
name=string.replace(string.strip(name), '_',' ')
return string.upper(name[:1])+name[1:]
name=string.replace(name.strip(), '_',' ')
return name[:1].upper() + name[1:]

def decapitate(html, RESPONSE=None,
header_re=re.compile(
Expand All @@ -420,7 +420,7 @@ def decapitate(html, RESPONSE=None,

headers, html = mo.group(1,3)

headers=string.split(headers,'\n')
headers=headers.split('\n')

i=1
while i < len(headers):
Expand All @@ -439,9 +439,9 @@ def decapitate(html, RESPONSE=None,
mo = name_re.match(headers[i])
if mo:
k,v = mo.group(1,2)
v=string.strip(v)
v = v.strip()
else:
raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i])
raise ValueError('Invalid Header (%d): %s ' % (i,headers[i]))
RESPONSE.setHeader(k,v)

return html
Expand All @@ -452,11 +452,9 @@ def delimited_output(results,REQUEST,RESPONSE):
try: output_type=REQUEST['output-type']
except: output_type='text/plain'
RESPONSE.setHeader('content-type', output_type)
join=string.join
return "%s\n%s\n" % (
join(results.names(),delim),
join(map(lambda row, delim=delim, join=join:
join(map(str,row),delim),
results),
'\n')
delim.join(results.names()),
'\n'.join(map(lambda row, delim=delim:
delim.join(map(str,row)),
results)),
)
22 changes: 11 additions & 11 deletions src/Shared/DC/ZRDB/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
'''Generic Database Connection Support'''

from cgi import escape
from cStringIO import StringIO
from logging import getLogger
from six import StringIO
import string
import sys

Expand Down Expand Up @@ -45,9 +45,9 @@
from AccessControl.Role import RoleManager


from Aqueduct import custom_default_report
import RDB
from Results import Results
from .Aqueduct import custom_default_report
from . import RDB
from .Results import Results

LOG = getLogger('ZRDB.Connection')

Expand Down Expand Up @@ -193,7 +193,7 @@ def __call__(self, v=None):
if s:
self.connect(s)
return self._v_database_connection
raise BadRequest,(
raise BadRequest(
'''The database connection is not connected''')

def connect(self,s):
Expand All @@ -204,20 +204,20 @@ def connect(self,s):
self._v_database_connection=DB(s)
except:
t, v, tb = sys.exc_info()
raise BadRequest, (
raise BadRequest(
'<strong>Error connecting to DB.</strong><br>\n'
'<!--\n%s\n%s\n-->\n'
% (t,v)), tb
% (t,v)).with_traceback(tb)
finally: tb=None
self._v_connected=DateTime()

return self

def sql_quote__(self, v):
if string.find(v,"\'") >= 0:
v = string.join(string.split(v,"\'"),"''")
if string.find(v,"\x00") >= 0:
v = string.join(string.split(v,"\x00"), "")
if v.find("\'") >= 0:
v = "''".join(v.split("\'"))
if v.find("\x00") >= 0:
v = "".join(v.split("\x00"))
return "'%s'" % v

InitializeClass(Connection)

0 comments on commit afb3d46

Please sign in to comment.