Skip to content

Commit

Permalink
Python 3 and PyPy support.
Browse files Browse the repository at this point in the history
Stop publishing INSTALL.txt on PyPI because it's very misleading at
this point.

Remove zope.app.testing and zope.app.zcmlfiles dependencies.

Test coverage could be better.
  • Loading branch information
jamadden committed May 2, 2017
1 parent 1e8482b commit bf8290b
Show file tree
Hide file tree
Showing 34 changed files with 401 additions and 186 deletions.
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
source = src

[report]
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ build/
dist/
*.egg-info/
.tox/
.coverage
htmlcov/
27 changes: 22 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
language: python
sudo: false
python:
- 2.7
install:
- pip install .
- 2.7
- 3.4
- 3.5
- 3.6
- pypy-5.4.1
script:
- python setup.py test -q
- coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress

after_success:
- coveralls
notifications:
email: false
email: false

install:
- pip install -U pip setuptools
- pip install -U coveralls coverage
- pip install -U -e ".[test]"


cache: pip

before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
7 changes: 5 additions & 2 deletions CHANGES.txt → CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
CHANGES
=======

3.5.11 (unreleased)
4.0.0 (unreleased)
-------------------

- TBD
- Add support for Python 3.42 3.5 and 3.6 and PyPy.

- Remove test dependency on zope.app.testing and zope.app.zcmlfiles,
among others.


3.5.10 (2011-11-02)
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
include *.py
include *.txt
include *.rst
include buildout.cfg
include tox.ini
include .travis.yml
include .coveragerc
recursive-include src *.pt
recursive-include src *.txt
recursive-include src *.rst
recursive-include src *.zcml
File renamed without changes.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
73 changes: 48 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,59 +21,82 @@

from setuptools import setup, find_packages

version = '3.5.11dev'
version = '4.0.0.dev0'

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()

tests_require = [
'webtest',

'zope.app.authentication >= 4.0.0',
'zope.app.basicskin >= 4.0.0',
'zope.app.form >= 5.0.0',
'zope.app.locales >= 4.0.0',
'zope.app.publication',
'zope.app.rotterdam >= 4.0.0',
'zope.app.wsgi',

'zope.browserresource >= 4.1.0',
'zope.login',
'zope.password',
'zope.principalregistry',
'zope.securitypolicy',
'zope.testbrowser >= 5.2',
'zope.testrunner',
]

setup(name='zope.app.applicationcontrol',
version = version,
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
description='Zope application control',
long_description=(
read('README.txt')
+ '\n\n' +
read('INSTALL.txt')
read('README.rst')
+ '\n\n' +
read('CHANGES.txt')
read('CHANGES.rst')
),
license='ZPL 2.1',
keywords = "zope3 application control",
classifiers = [
keywords="zope3 application control",
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 :: 3.6',
'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://cheeseshop.python.org/pypi/zope.app.applicationcontrol',
extras_require=dict(
test=['zope.app.component',
'zope.app.testing',
'zope.app.zcmlfiles',
'zope.login',
'zope.password',
'zope.securitypolicy',
'zope.testbrowser',
]),
package_dir = {'': 'src'},
'Framework :: Zope3',
],
url='http://github.com/zopefoundation/zope.app.applicationcontrol',
extras_require={
'test': tests_require,
},
package_dir={'': 'src'},
packages=find_packages('src'),
namespace_packages=['zope', 'zope.app'],
install_requires=[
'setuptools',
'ZODB3',
'zope.applicationcontrol',
'ZODB',
'zope.applicationcontrol >= 4.0.1',
'zope.component',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
'zope.size',
'zope.traversing>=3.7.0',
],
include_package_data = True,
zip_safe = False,
)
include_package_data=True,
zip_safe=False,
)
8 changes: 1 addition & 7 deletions src/zope/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
8 changes: 1 addition & 7 deletions src/zope/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
2 changes: 1 addition & 1 deletion src/zope/app/applicationcontrol/applicationcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
##############################################################################
"""Application Control
$Id$"""
"""
__docformat__ = 'restructuredtext'

# BBB
Expand Down
12 changes: 6 additions & 6 deletions src/zope/app/applicationcontrol/browser/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<zope:configure
<zope:configure
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser"
zcml:condition="installed zope.browserpage">

<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
for="zope.applicationcontrol.interfaces.IApplicationControl"
name="servercontrol.html"
template="servercontrol.pt"
class=".servercontrol.ServerControlView"
permission="zope.ManageApplication"/>

<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
for="zope.applicationcontrol.interfaces.IApplicationControl"
name="index.html"
template="runtimeinfo.pt"
class=".runtimeinfo.RuntimeInfoView"
permission="zope.ManageApplication"/>

<menuItems
menu="zmi_views"
for="zope.app.applicationcontrol.interfaces.IApplicationControl">
for="zope.applicationcontrol.interfaces.IApplicationControl">

<menuItem
order="-2"
Expand All @@ -33,15 +33,15 @@
</menuItems>

<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
for="zope.applicationcontrol.interfaces.IApplicationControl"
name="ZODBControl.html"
template="zodbcontrol.pt"
class=".zodbcontrol.ZODBControlView"
permission="zope.ManageApplication"
menu="zmi_views" title="ZODB Control"/>

<page
for="zope.app.applicationcontrol.interfaces.IApplicationControl"
for="zope.applicationcontrol.interfaces.IApplicationControl"
name="TranslationDomain.html"
template="translationdomaincontrol.pt"
class=".translationdomaincontrol.TranslationDomainControlView"
Expand Down
11 changes: 7 additions & 4 deletions src/zope/app/applicationcontrol/browser/runtimeinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
#
##############################################################################
"""Define runtime information view component for Application Control
$Id$
"""
__docformat__ = 'restructuredtext'

from zope.app.applicationcontrol.interfaces import IRuntimeInfo

from zope.app.applicationcontrol.i18n import ZopeMessageFactory as _

try:
long
except NameError:
long = int

class RuntimeInfoView(object):

Expand Down Expand Up @@ -50,10 +52,11 @@ def runtimeInfo(self):
def _getInfo(self, ri):
formatted = {}
for name in self._fields:
value = self._unavailable
try:
value = getattr(ri, "get" + name)()
except ValueError:
value = self._unavailable
except ValueError: # pragma: no cover
pass
formatted[name] = value
formatted["Uptime"] = self._getUptime(ri)
return formatted
Expand Down
8 changes: 4 additions & 4 deletions src/zope/app/applicationcontrol/browser/servercontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
##############################################################################
"""Server Control View
$Id$
"""
__docformat__ = 'restructuredtext'

Expand All @@ -36,8 +35,9 @@ def action(self):
if 'restart' in self.request:
control.restart(time)
return _("The server will be restarted in ${number} seconds.",
mapping={"number": time})
elif 'shutdown' in self.request:
mapping={"number": time})

if 'shutdown' in self.request:
control.shutdown(time)
return _("The server will be shutdown in ${number} seconds.",
mapping={"number": time})
mapping={"number": time})
53 changes: 51 additions & 2 deletions src/zope/app/applicationcontrol/browser/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
#
# This file is necessary to make this directory a package.
import unittest
from webtest import TestApp

from zope.component import getUtility
from zope.publisher.browser import BrowserView
from zope.traversing.browser.absoluteurl import absoluteURL

from zope.error.interfaces import IErrorReportingUtility


from zope.app.applicationcontrol.testing import ApplicationControlLayer


class BrowserTestCase(unittest.TestCase):

layer = ApplicationControlLayer

def setUp(self):
super(BrowserTestCase, self).setUp()
self._testapp = TestApp(self.layer.make_wsgi_app())

def publish(self, path, basic=None, form=None, headers=None):
assert basic
self._testapp.authorization = ('Basic', tuple(basic.split(':')))

env = {'wsgi.handleErrors': False}
if form:
response = self._testapp.post(path, params=form,
extra_environ=env, headers=headers)
else:
response = self._testapp.get(path, extra_environ=env, headers=headers)
return response

class ErrorRedirect(BrowserView):
# copied from zope.app.error
def action(self):
# Some locations (eg ++etc++process) throw a TypeError exception when
# finding their absoluteurl, if this happens catch the error and
# redirect the browser to the site root "/@@errorRedirect.html"
# to handle redirection to the site error logger instead
try:
err = getUtility(IErrorReportingUtility)
url = absoluteURL(err, self.request)
except TypeError:
url = self.request.getApplicationURL() + "/@@errorRedirect.html"
else:
# The real zope.app.error would redirect to
# url + @@SelectedManagementView.html
raise NotImplementedError()

self.request.response.redirect(url)

0 comments on commit bf8290b

Please sign in to comment.