Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.6, drop Python 3.3 #4

Merged
merged 3 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[run]
source = zope.principalannotation

[report]
precision = 2
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
self.fail
raise AssertionError
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ develop-eggs/
eggs/
docs/
parts/
.coverage
htmlcov/
21 changes: 13 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- pypy
- pypy3
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3.5-5.8.0
install:
- pip install tox-travis
- pip install -U pip setuptools
- pip install -U coverage coveralls
- pip install -U -e .[test]
script:
- tox
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
25 changes: 13 additions & 12 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
Changes
=======
=========
Changes
=========

4.2.0 (unreleased)
------------------
==================

- Add support for Python 3.5.
- Add support for Python 3.5 and 3.6.

- Drop support for Python 2.6.
- Drop support for Python 2.6 and 3.3.


4.1.1 (2015-06-02)
------------------
==================

- Replace use of long-deprecated ``zope.testing.doctest`` with stdlib's
``doctest``.


4.1.0 (2015-01-09)
------------------
==================

- Accomodate new methods added to ``zope.annotation.interfaces.IAnnotations``
in upcoming zope.annotation 4.4.0 release.


4.0.0 (2014-12-24)
------------------
==================

- Add support for PyPy.

Expand All @@ -34,13 +35,13 @@ Changes


4.0.0a2 (2013-02-25)
--------------------
====================

- Correct Trove classifiers.


4.0.0a1 (2013-02-24)
--------------------
====================

- Add support for Python 3.3.

Expand All @@ -50,14 +51,14 @@ Changes
- Drop support for Python 2.4 and 2.5.

3.6.1 (2010-05-05)
------------------
==================

- Fix a test failure in nested local site manager setup.

- Remove dependency on zope.container.

3.6.0 (2009-03-09)
------------------
==================

Initial release. This package was splitted off zope.app.principalannotation
to remove its dependencies on "zope 3 application server" components.
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include *.txt
include *.py
include buildout.cfg
include tox.ini
include .coveragerc
include .travis.yml

recursive-include src *

Expand Down
18 changes: 15 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
``zope.principalannotation``
============================
==============================
``zope.principalannotation``
==============================

.. image:: https://img.shields.io/pypi/v/zope.principalannotation.svg
:target: https://pypi.python.org/pypi/zope.principalannotation/
:alt: Latest release

.. image:: https://img.shields.io/pypi/pyversions/zope.principalannotation.svg
:target: https://pypi.org/project/zope.principalannotation/
:alt: Supported Python versions

.. image:: https://travis-ci.org/zopefoundation/zope.principalannotation.png?branch=master
:target: https://travis-ci.org/zopefoundation/zope.principalannotation

.. image:: https://coveralls.io/repos/github/zopefoundation/zope.principalannotation/badge.svg?branch=master
:target: https://coveralls.io/github/zopefoundation/zope.principalannotation?branch=master

This package implements annotations for zope.security principals. Common
annotation techniques, like AttributeAnnotations cannot be applied to
annotation techniques, like ``AttributeAnnotations`` cannot be applied to
principals, since they are created on the fly for every request.
104 changes: 58 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,58 @@ def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()

setup(name='zope.principalannotation',
version='4.2.0.dev0',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
description='Annotations for Zope Principals',
long_description=(
read('README.rst')
+ '\n\n' +
read('src', 'zope', 'principalannotation', 'README.txt')
+ '\n\n' +
read('CHANGES.rst')
),
keywords = "zope security principal annotation",
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 :: 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.principalannotation',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir = {'': 'src'},
namespace_packages=['zope'],
extras_require = dict(
test=['zope.testing', 'zope.site[test]'],
docs=['z3c.recipe.sphinxdoc',]),
install_requires=[
TESTS_REQUIRE = [
'zope.configuration',
'zope.testing',
'zope.site[test]',
'zope.testrunner',
]

setup(
name='zope.principalannotation',
version='4.2.0.dev0',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
description='Annotations for Zope Principals',
long_description=(
read('README.rst')
+ '\n\n' +
read('src', 'zope', 'principalannotation', 'README.rst')
+ '\n\n' +
read('CHANGES.rst')
),
keywords="zope security principal annotation",
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://github.com/zopefoundation/zope.principalannotation',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
extras_require={
'test': TESTS_REQUIRE,
'docs': [
'z3c.recipe.sphinxdoc',
],
},
install_requires=[
'persistent',
'setuptools',
'zope.annotation',
Expand All @@ -68,9 +80,9 @@ def read(*rnames):
'zope.location',
'zope.security',
'zope.site',
],
tests_require=['zope.testing', 'zope.site[test]'],
test_suite='zope.principalannotation.tests.test_suite',
include_package_data = True,
zip_safe = False,
)
],
tests_require=TESTS_REQUIRE,
test_suite='zope.principalannotation.tests.test_suite',
include_package_data=True,
zip_safe=False,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Principal Annotations
=====================
=======================
Principal Annotations
=======================

This package implements annotations for zope.security principals.
To make it clear, the `principal` here is the object that provides
Expand All @@ -17,7 +18,7 @@ to IAnnotations.


PrincipalAnnotationUtility
--------------------------
==========================

The core of this package is the ``PrincipalAnnotationUtility`` class
that stores annotations for principals and allows to get them easily.
Expand Down Expand Up @@ -108,7 +109,7 @@ But we can't delete the key that is (no more) existant::


Multiple annotation utilities
-----------------------------
=============================

Imagine that your application has a root ``site`` object with its
component registry (a.k.a. site manager) and that object has a sub-site
Expand Down Expand Up @@ -142,15 +143,20 @@ Now, let's create a key in the IAnnotations, provided by root utility::

>>> annots = util.getAnnotations(nadako)
>>> annots['root.number'] = 42
>>> sorted(annots.items())
[('root.number', 42)]

The subsite utility should get the annotation successfully::

>>> annots2 = util2.getAnnotations(nadako)
>>> bool(annots2)
True

>>> annots2['root.number']
42
>>> del annots['root.number']
>>> bool(annots2)
False
>>> annots['root.number'] = 42

If we have the key both in higher-level annotations and lower-level ones,
the lower-level will have priority, but higher-level won't be deleted or
Expand All @@ -163,6 +169,10 @@ overriden::
1
>>> annots2['another.number']
42
>>> sorted(iter(annots))
['another.number', 'root.number']
>>> sorted(iter(annots2))
['another.number']

If we'll delete the key from lower-level, it will not be deleted from a
higher level utility::
Expand All @@ -173,10 +183,26 @@ higher level utility::
1
>>> annots2['another.number']
1
>>> sorted(iter(annots))
['another.number', 'root.number']

This is somewhat confusing given the way that ``in`` and boolean tests
work::

>>> 'another.number' in annots
True
>>> 'another.number' in annots2
False
>>> annots2['another.number']
1
>>> list(iter(annots2))
[]
>>> bool(annots2)
True


IPrincipal -> IAnnotations adapter
----------------------------------
==================================

Of course, the most nice feature is that we can simply adapt our
principal object to IAnnotations and get those annotations using
Expand All @@ -195,15 +221,15 @@ By default, the IAnnotation adapter uses the current site's utility::

>>> from zope.site.hooks import setSite
>>> setSite(subsite)

>>> IAnnotations(nadako) is util2.getAnnotations(nadako)
True

Howerver, we can use a binary multi-adapter to IAnnotations to specify
some context object from which to get the annotations utility::

>>> from zope.component import getMultiAdapter

>>> annots = getMultiAdapter((nadako, root), IAnnotations)
>>> annots is util.getAnnotations(nadako)
True
Expand Down
3 changes: 3 additions & 0 deletions src/zope/principalannotation/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<configure xmlns="http://namespaces.zope.org/zope">

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

<class class=".utility.PrincipalAnnotationUtility">
<factory id="zope.app.PrincipalAnnotationUtility" />
<implements
Expand Down
Loading