Skip to content

Commit

Permalink
Merge pull request #2 from zopefoundation/py3
Browse files Browse the repository at this point in the history
Finalize Python 3 support
  • Loading branch information
sallner committed Aug 8, 2016
2 parents c10fb33 + 80aec28 commit 0ec9fdd
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 124 deletions.
19 changes: 19 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[run]
branch = True
source = zope.app.appsetup

[report]
precision = 2
omit = */interfaces.py
*/interfaces/*
*/tests.py
*/tests/*

[html]
directory = htmlcov

[paths]
source =
src/zope/app/appsetup
.tox/*/lib/python*/site-packages/zope/app/appsetup
.tox/pypy*/site-packages/zope/app/appsetup
25 changes: 14 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
.installed.cfg
.tox
bin
develop-eggs
src/zope.app.appsetup.egg-info/
bin/
eggs/
develop-eggs/
parts/
*.dll
*.eggs
*.egg-info/
*.py[co]
*.so
.coverage
.coverage.*
.installed.cfg
.tox/
__pycache__/
bin/
build/
coverage.xml
develop-eggs/
dist/
*.egg-info/
.tox/
eggs/
htmlcov/
parts/
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: python
python:
- 2.6
- 2.7
- 3.3
- 3.4
- 3.5
- pypy
install:
- pip install .
- pip install tox-travis
script:
- python setup.py test -q
- tox
notifications:
email: false
19 changes: 17 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
Changelog
=========

3.17.0 (unreleased)
-------------------
4.0.0a2 (unreleased)
--------------------

- Add dependency on ``zdaemon`` (split off from ``ZODB``).

- Claim support for Python 3.4, 3.5 and PyPy which requires
``zope.app.publication`` >= 4.0.

- Drop Python 2.6 support.

4.0.0a1 (2013-03-03)
--------------------

- Added support for Python 3.3.

- Replaced deprecated ``zope.interface.implements`` usage with equivalent
``zope.interface.implementer`` decorator.

- Dropped support for Python 2.4 and 2.5.


3.16.0 (2011-01-27)
-------------------
Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[buildout]
develop = .
find-links =
parts = test python

[test]
Expand Down
82 changes: 50 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,81 +17,99 @@
# Zope Toolkit policies as described by this documentation.
##############################################################################
"""Setup for zope.app.appsetup package
$Id$
"""

import os

from setuptools import setup, find_packages


def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()

setup(
name='zope.app.appsetup',
version='3.17.dev0',
version='4.0.0a2.dev0',
author='Zope Corporation and Contributors',
author_email='zope-dev@zope.org',
description="Zope app setup helper",
long_description=(
read('README.txt')
+ '\n\n' +
'.. contents::'
+ '\n\n' +
read('src', 'zope', 'app', 'appsetup', 'bootstrap.txt')
+ '\n\n' +
read('src', 'zope', 'app', 'appsetup', 'debug.txt')
+ '\n\n' +
read('src', 'zope', 'app', 'appsetup', 'product.txt')
+ '\n\n' +
read('README.txt') +
'\n\n' +
'.. contents::' +
'\n\n' +
read('src', 'zope', 'app', 'appsetup', 'bootstrap.txt') +
'\n\n' +
read('src', 'zope', 'app', 'appsetup', 'debug.txt') +
'\n\n' +
read('src', 'zope', 'app', 'appsetup', 'product.txt') +
'\n\n' +
read('CHANGES.txt')
),
),
license='ZPL 2.1',
keywords="zope3 app setup",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
url='http://pypi.python.org/pypi/zope.app.appsetup',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope', 'zope.app'],
extras_require=dict(
test=[
'zope.componentvocabulary',
'zope.principalregistry',
'zope.componentvocabulary >= 2.0.0a1',
'zope.principalregistry >= 4.0.0a1',
'zope.testing >= 3.10',
'zope.testrunner',
]
),
namespace_packages=['zope', 'zope.app'],
]
),
setup_requires=[
'eggtestinfo',
'zope.testrunner',
],
install_requires=[
'ZODB',
'zdaemon',
'setuptools',
'zope.app.publication',
'zope.app.publication >= 4.0',
'zope.component >= 3.8.0',
'zope.configuration',
'zope.container',
'zope.container >= 4.0.0a2',
'zope.error',
'zope.event',
'zope.interface',
'zope.processlifetime',
'zope.security >= 3.6.0',
'zope.session',
'zope.site',
'zope.traversing',
],
'zope.security >= 4.0.0a2',
'zope.session >=4.0.0a1',
'zope.site >= 4.0.0a1',
'zope.traversing >= 4.0.0a2',
],
tests_require=[
'zope.componentvocabulary >= 2.0.0a1',
'zope.principalregistry >= 4.0.0a1',
'zope.testing >= 3.10',
'zope.testrunner',
],
test_suite='zope.app.appsetup.tests.test_suite',
test_loader='zope.testrunner.eggsupport:SkipLayers',
include_package_data=True,
zip_safe=False,
entry_points = """
entry_points="""
[console_scripts]
debug = zope.app.appsetup.debug:main
""",
)
)
9 changes: 4 additions & 5 deletions src/zope/app/appsetup/appsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from zope.security.management import system_user
import zope.processlifetime

@zope.interface.implementer(IParticipation)
class SystemConfigurationParticipation(object):
zope.interface.implements(IParticipation)

principal = system_user
interaction = None
Expand All @@ -46,7 +46,7 @@ def config(file, features=(), execute=True):
>>> import tempfile
>>> fn = tempfile.mktemp('.zcml')
>>> zcml = open(fn, 'w')
>>> zcml.write('''
>>> written = zcml.write('''
... <configure xmlns:meta="http://namespaces.zope.org/meta"
... xmlns:zcml="http://namespaces.zope.org/zcml">
... <meta:provides feature="myFeature" />
Expand Down Expand Up @@ -129,7 +129,7 @@ def database(db):
if db.endswith('.py'):
# Python source, exec it
globals = {}
execfile(db, globals)
exec(compile(open(db).read(), db, 'exec'), globals)
if 'DB' in globals:
db = globals['DB']
else:
Expand Down Expand Up @@ -185,8 +185,7 @@ def multi_database(database_factories):
[True, True, True]
>>> items = m.items()
>>> items.sort()
>>> items
>>> sorted(list(items))
[('', DB(3)), ('x', DB(1)), ('y', DB(2))]
Each of the databases is registered as an IDatabase utility:
Expand Down
7 changes: 1 addition & 6 deletions src/zope/app/appsetup/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
This module contains code to bootstrap a Zope3 instance. For example
it makes sure a root folder exists and creates one if necessary.
$Id$
"""
__docformat__ = 'restructuredtext'


import logging
import transaction
import warnings
Expand Down Expand Up @@ -119,7 +114,7 @@ def addUtility(root_folder, utility_type, utility_factory,
utility = package[name]

# Set additional attributes on the utility
for k, v in kw.iteritems():
for k, v in kw.items():
setattr(utility, k, v)
return utility

Expand Down
5 changes: 3 additions & 2 deletions src/zope/app/appsetup/bootstrap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Now the maintainers of existing 3.0 sites need to manually update
their site.zcml to include securitypolicy.zcml while upgrading to 3.1.
See also http://www.zope.org/Collectors/Zope3-dev/381 .

>>> from __future__ import print_function
>>> from zope.testing.loggingsupport import InstalledHandler
>>> handler = InstalledHandler('zope.app.appsetup')

Expand All @@ -63,7 +64,7 @@ ParanoidSecurityPolicy, we get a warning:
>>> from zope.app.appsetup.bootstrap import checkSecurityPolicy
>>> event = object()
>>> checkSecurityPolicy(event)
>>> print handler
>>> print(handler)
zope.app.appsetup WARNING
Security policy is not configured.
Please make sure that securitypolicy.zcml is included in site.zcml immediately
Expand All @@ -76,7 +77,7 @@ is emitted:
>>> defaultPolicy = setSecurityPolicy(object())
>>> handler.clear()
>>> checkSecurityPolicy(event)
>>> print handler
>>> print(handler)
<BLANKLINE>

Clean up:
Expand Down
10 changes: 5 additions & 5 deletions src/zope/app/appsetup/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ def do_debug(self, rest):
os.system(cmdline)

def help_debug(self):
print "debug -- Initialize the Zope application, providing a"
print " debugger object at an interactive Python prompt."
print("debug -- Initialize the Zope application, providing a")
print(" debugger object at an interactive Python prompt.")

def do_run(self, arg):
cmdline = "%s %s" % (
os.path.join(INSTANCE_HOME, 'bin', 'scriptzope'), arg)
os.system(cmdline)

def help_run(self):
print "run <script> [args] -- run a Python script with the Zope "
print " environment set up. The script has "
print " 'root' exposed as the root container."
print("run <script> [args] -- run a Python script with the Zope ")
print(" environment set up. The script has ")
print(" 'root' exposed as the root container.")


def main(args=None, options=None, cmdclass=ZopectlCmd):
Expand Down
6 changes: 4 additions & 2 deletions src/zope/app/appsetup/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$Id$
"""
from __future__ import print_function
__docformat__ = 'restructuredtext'

from zope.app.publication.zopepublication import ZopePublication
Expand Down Expand Up @@ -58,9 +59,10 @@ def loadApplication(args=None):
def main(args=None):
db = loadApplication(args)
if "PYTHONSTARTUP" in os.environ:
execfile(os.environ["PYTHONSTARTUP"])
startup = os.environ["PYTHONSTARTUP"]
exec(compile(open(startup).read(), startup, 'exec'))
sys.modules['__main__'].root = db.open().root()[ZopePublication.root_name]
print 'The application root is known as `root`.'
print('The application root is known as `root`.')
os.environ["PYTHONINSPECT"] = "true"


Expand Down
5 changes: 3 additions & 2 deletions src/zope/app/appsetup/debug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ database connection).
Let's define a helper to run the debug script and trap SystemExit exceptions
that would otherwise hide the output

>>> from __future__ import print_function
>>> import sys
>>> from zope.app.appsetup import debug
>>> def run(*args):
... sys.argv[0] = 'debug'
... sys.stderr = sys.stdout
... try:
... debug.main(args)
... except SystemExit, e:
... print "(exited with status %d)" % e.code
... except SystemExit as e:
... print("(exited with status %d)" % e.code)

If you call the script with no arguments, it displays a brief error message
on stderr
Expand Down

0 comments on commit 0ec9fdd

Please sign in to comment.