Skip to content

Commit

Permalink
Python 3 port.
Browse files Browse the repository at this point in the history
Breaks dependency on zope.app.testing and zope.app.zcmlfiles and
zope.app.component.

- Replace all uses of assert_ with more specific method.
- Append :list to appropriate parameter names to account for
  differences in zope.app.testing and zope.app.wsgi.
- Use zope.testing.cleanup to tear down things like interactions, if
  needed.
  • Loading branch information
jamadden committed Apr 22, 2017
1 parent e96edbd commit d1259f4
Show file tree
Hide file tree
Showing 19 changed files with 615 additions and 274 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
17 changes: 15 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
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 -e git+https://github.com/zopefoundation/zope.proxy.git@issue15#egg=zope.proxy
- 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
5 changes: 5 additions & 0 deletions CHANGES.txt → CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
CHANGES
=======

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

- Added support for PyPy and Python 3.4, 3.5 and 3.6.

3.9.2 (2012-01-23)
------------------

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include *.py
include *.txt
include *.rst
include buildout.cfg
recursive-include src *.pt
recursive-include src *.txt
Expand Down
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
109 changes: 69 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,99 @@
##############################################################################
"""Setup for zope.app.container 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()

version = '4.0.0.dev0'

setup(name='zope.app.container',
version='3.9.2',
version=version,
author='Zope Corporation and Contributors',
author_email='zope-dev@zope.org',
description='Zope Container',
long_description=(
read('README.txt')
read('README.rst')
+ '\n\n' +
read('CHANGES.txt')
read('CHANGES.rst')
),
keywords = "zope3 container",
classifiers = [
keywords="zope3 container",
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.7',
'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.container',
'Framework :: Zope3',
],
url='http://github.com/zopefoundation/zope.app.container',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir = {'': 'src'},
namespace_packages=['zope', 'zope.app'],
extras_require={
'test': [
'zope.app.appsetup',
'zope.app.basicskin >= 4.0',
'zope.app.content',
'zope.app.dependable >= 4.0',
'zope.app.http',
'zope.app.pagetemplate >= 4.0',
'zope.app.principalannotation',
'zope.app.publication',
'zope.app.publisher',
'zope.app.security',
'zope.app.testing',
'zope.app.wsgi',

extras_require=dict(test=['zope.app.testing',
'zope.app.zcmlfiles',
'zope.login',
'zope.password',
'zope.securitypolicy',
'zope.schema',
'zope.site',
]),
install_requires=['setuptools',
'zope.browser',
'zope.browsermenu',
'zope.browserpage',
'zope.component',
'zope.container',
'zope.copypastemove',
'zope.dublincore >= 3.7',
'zope.event',
'zope.exceptions',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
'zope.lifecycleevent',
'zope.location',
'zope.publisher >= 3.12',
'zope.security',
'zope.size',
'zope.traversing',
],
include_package_data = True,
zip_safe = False,
'zope.applicationcontrol',
'zope.browser',
'zope.browserresource',
'zope.copypastemove',
'zope.login',
'zope.password',
'zope.principalannotation',
'zope.principalregistry',
'zope.securitypolicy',
'zope.site',
'zope.testbrowser>5',
'zope.testing',
'zope.testrunner',
]},
install_requires=[
'setuptools',
'zope.browser',
'zope.browsermenu',
'zope.browserpage',
'zope.component',
'zope.container',
'zope.copypastemove',
'zope.dublincore >= 3.7',
'zope.event',
'zope.exceptions',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
'zope.lifecycleevent',
'zope.location',
'zope.publisher >= 3.12',
'zope.security',
'zope.size',
'zope.traversing',
],
include_package_data=True,
zip_safe=False,
)

5 changes: 3 additions & 2 deletions src/zope/app/container/browser/adding.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from zope.exceptions.interfaces import UserError
from zope.i18n.interfaces.locales import ICollator
from zope.i18n.locales.fallbackcollator import FallbackCollator
from zope.interface import implements
from zope.interface import implementer
from zope.lifecycleevent import ObjectCreatedEvent
from zope.location import LocationProxy
from zope.publisher.browser import BrowserView
Expand All @@ -47,8 +47,9 @@
from zope.traversing.browser.absoluteurl import absoluteURL
import zope.security.checker

@implementer(IAdding, IPublishTraverse)
class Adding(BrowserView):
implements(IAdding, IPublishTraverse)


def add(self, content):
"""See zope.app.container.interfaces.IAdding
Expand Down
9 changes: 6 additions & 3 deletions src/zope/app/container/browser/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"""
__docformat__ = 'restructuredtext'

import urllib
import six
from six.moves import urllib_parse as urllib

from zope.component import queryMultiAdapter
from zope.event import notify
Expand Down Expand Up @@ -117,7 +118,7 @@ def _normalListContentsInfo(self):
)
self.normalButtons = not self.specialButtons

info = map(self._extractContentInfo, self.context.items())
info = [self._extractContentInfo(x) for x in self.context.items()]

self.supportsCut = info
self.supportsCopy = info
Expand Down Expand Up @@ -261,6 +262,7 @@ def copyObjects(self):
"""Copy objects specified in a list of object ids"""
request = self.request
ids = request.get('ids')

if not ids:
self.error = _("You didn't specify any ids to copy.")
return
Expand Down Expand Up @@ -301,7 +303,8 @@ def cutObjects(self):
if not ids:
self.error = _("You didn't specify any ids to cut.")
return

if isinstance(ids, six.string_types):
ids = [ids]
container_path = getPath(self.context)

# For each item, check that it can be moved; if so, save the
Expand Down
39 changes: 38 additions & 1 deletion src/zope/app/container/browser/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
#
# This file is necessary to make this directory a package.

import unittest

from webtest import TestApp

from zope import component

def provideAdapter(required, provided, factory):
gsm = component.getGlobalSiteManager()
gsm.registerAdapter(factory, [required], provided, event=False)


class BrowserTestCase(unittest.TestCase):

def getRootFolder(self):
return self.layer.getRootFolder()

def setUp(self):
super(BrowserTestCase, self).setUp()
self._testapp = TestApp(self.layer.make_wsgi_app())
# Typically this would be done by zope.app.principalannotation's
# bootstrap.zcml but we don't have a dep on that.
from zope.principalannotation.utility import PrincipalAnnotationUtility
from zope.principalannotation.interfaces import IPrincipalAnnotationUtility
component.getGlobalSiteManager().registerUtility(PrincipalAnnotationUtility(),
IPrincipalAnnotationUtility)

def publish(self, path, basic=None, form=None):
if basic:
self._testapp.authorization = ('Basic', tuple(basic.split(':')))
else:
self._testapp.authorization = None
env = {'wsgi.handleErrors': False}
if form:
response = self._testapp.post(path, params=form, extra_environ=env)
else:
response = self._testapp.get(path, extra_environ=env)
return response
4 changes: 2 additions & 2 deletions src/zope/app/container/browser/tests/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ links).

We can get this view from the root folder easily::

>>> response = http(r"""
>>> response = http(br"""
... GET / HTTP/1.1
... """)

And we can check that there isn't a form (where the management
operations would have buttons)::

>>> body = response.getBody().lower()
>>> "<form" in body
>>> b"<form" in body
False
Loading

0 comments on commit d1259f4

Please sign in to comment.