Skip to content

Commit

Permalink
Port to Python 3
Browse files Browse the repository at this point in the history
Add zope.annotation as a test dep to be sure all branches of the configure.zcml are exercised.

We don't actually need ZODB[3], just persistent
  • Loading branch information
jamadden committed Apr 22, 2017
1 parent 3ba4a1c commit e9fa6a4
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
source = src

[report]
exclude_lines =
pragma: no cover
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
language: python
sudo: false
python:
- 2.7
- pypy-5.4.1
- 3.4
- 3.5
- 3.6
install:
- pip install .
- pip install -U pip setuptools
- pip install -U coverage coveralls
- pip install -U -e .[test]
script:
- python setup.py test -q
- coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress
notifications:
email: false
after_success:
- coveralls
cache: pip
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
7 changes: 5 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
CHANGES
=======

3.7.3 (unreleased)
4.0.0 (unreleased)
------------------

- Nothing changed yet.
- Add support for PyPy.
- Add support for Python 3.4, 3.5, and 3.6.
- Remove dependency on ZODB3. Instead, depend on the separate
``persistent`` package.


3.7.2 (2010-03-21)
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include *.py
include *.txt
include buildout.cfg
include tox.ini
include .coveragerc
recursive-include src *.zcml
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
58 changes: 41 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@
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()

version = '4.0.0.dev0'

tests_require = [
'zope.annotation',
'zope.configuration',
'zope.testing',
'zope.testrunner',
]

setup(name='zope.app.localpermission',
version = '3.7.3dev',
version=version,
author='Zope Corporation and Contributors',
author_email='zope-dev@zope.org',
description='Local Persistent Permissions for zope.security',
Expand All @@ -31,30 +41,44 @@ def read(*rnames):
+ '\n\n' +
read('CHANGES.txt')
),
keywords = "zope security persistent local permission",
classifiers = [
keywords="zope security persistent local permission",
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.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://pypi.python.org/pypi/zope.app.localpermission',
'Framework :: Zope3',
],
url='http://github.org/zopefoundation/zope.app.localpermission',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir = {'': 'src'},
package_dir={'': 'src'},
namespace_packages=['zope', 'zope.app'],
install_requires=['setuptools',
'ZODB3',
'zope.component',
'zope.i18nmessageid',
'zope.interface',
'zope.location',
'zope.security',
],
include_package_data = True,
zip_safe = False,
install_requires=[
'setuptools',
'persistent',
'zope.component',
'zope.i18nmessageid',
'zope.interface',
'zope.location',
'zope.security',
],
tests_require=tests_require,
extras_require={
'test': tests_require,
},
include_package_data=True,
zip_safe=False,
)
5 changes: 5 additions & 0 deletions src/zope/app/localpermission/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
i18n_domain="zope"
>

<include package="zope.component" file="meta.zcml" />
<include package="zope.security" file="meta.zcml" />

<include package="zope.security" file="permissions.zcml" />

<class class=".permission.LocalPermission">
<factory
id="zope.app.security.Permission"
Expand Down
15 changes: 6 additions & 9 deletions src/zope/app/localpermission/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,23 @@
#
##############################################################################
"""Persistent Local Permissions
$Id: permission.py 97714 2009-03-09 18:52:31Z nadako $
"""
__docformat__ = 'restructuredtext'

from persistent import Persistent
from zope.component import adapter
from zope.component.interfaces import IRegistered, IUnregistered
from zope.i18nmessageid import MessageFactory
from zope.interface import implements
from zope.interface import implementer
from zope.location import Location
from zope.security.interfaces import IPermission

_ = MessageFactory('zope')

NULL_ID = _(u'<permission not activated>')


@implementer(IPermission)
class LocalPermission(Persistent, Location):
implements(IPermission)

def __init__(self, title=u'', description=u''):
self.id = NULL_ID
Expand All @@ -52,8 +49,8 @@ def setIdOnActivation(permission, event):
... self.name = name
>>> perm1 = LocalPermission('Permission 1', 'A first permission')
>>> perm1.id
u'<permission not activated>'
>>> print(perm1.id)
<permission not activated>
>>> import zope.component.interfaces
>>> event = zope.component.interfaces.Registered(
Expand Down Expand Up @@ -92,7 +89,7 @@ def unsetIdOnDeactivation(permission, event):
should be set to NULL_ID.
>>> unsetIdOnDeactivation(perm1, event)
>>> perm1.id
u'<permission not activated>'
>>> print(perm1.id)
<permission not activated>
"""
permission.id = NULL_ID
13 changes: 11 additions & 2 deletions src/zope/app/localpermission/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@
#
##############################################################################
"""Tests for zope.localpermission.
$Id$
"""
import unittest
import doctest

from zope.testing.cleanup import CleanUp

import zope.app.localpermission

class TestConfiguration(CleanUp, unittest.TestCase):

def test_configuration(self):
from zope.configuration import xmlconfig
xmlconfig.file('configure.zcml', package=zope.app.localpermission)

def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite('zope.app.localpermission.permission'),
unittest.defaultTestLoader.loadTestsFromName(__name__),
))
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tox]
envlist =
py27, pypy, py34, py35, py36

[testenv]
commands =
zope-testrunner --test-path=src
deps =
.[test]

0 comments on commit e9fa6a4

Please sign in to comment.