Skip to content

Commit

Permalink
Merge pull request #2 from zopefoundation/resurrection-python3
Browse files Browse the repository at this point in the history
Resurrection python3.
  • Loading branch information
janwijbrand committed Jan 5, 2018
2 parents 01c9816 + f197226 commit 76ea8b0
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 53 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
syntax:glob

.coverage
.installed.cfg
.mr.developer.cfg
.tox
*.bak
*.pyc
*.pyo
*.swp
bin
develop/*
develop-eggs
develop/*
eggs
.installed.cfg
.mr.developer.cfg
parts
src/*.egg-info
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
language: python
python:
- 2.6
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
install:
- python bootstrap.py
- bin/buildout
- pip install -U pip setuptools
- pip install -U zope.testrunner coverage coveralls
- pip install -U -e .[test]
script:
- bin/test -v1
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
notifications:
email: false
cache: pip
6 changes: 1 addition & 5 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ Changes
1.9 (unreleased)
----------------

- Nothing changed yet.

- Python 3 compatibility.

1.8 (2016-09-21)
----------------

- When removing a site make sure reference are removed from the parent
site.


1.7.1 (2016-01-29)
------------------

- Update tests.


1.7 (2015-06-11)
----------------

Expand All @@ -33,7 +30,6 @@ Changes
will be current Zope local site. The site is restored after the
event.


1.6.1 (2012-05-02)
------------------

Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
global-include *.mo
include *.txt
include *.rst
include bootstrap.py
Expand Down
9 changes: 7 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[buildout]
extends =
https://raw.githubusercontent.com/zopefoundation/groktoolkit/resurrection-python3/grok.cfg
develop = .
parts = interpreter test
extends = https://raw.github.com/zopefoundation/groktoolkit/master/grok.cfg
parts =
interpreter
test
versions = versions
extensions =
mr.developer

[versions]
grokcore.site =
Expand Down
6 changes: 3 additions & 3 deletions src/grokcore/site/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from grokcore.site.interfaces import IApplication
from zope.annotation.interfaces import IAttributeAnnotatable
from zope.container.contained import Contained
from zope.interface import implements
from zope.interface import implementer
from zope.site.site import SiteManagerContainer


Expand All @@ -41,6 +41,7 @@ class Site(BaseSite, SiteManagerContainer):
"""


@implementer(IApplication)
class Application(Site):
"""Mixin for creating Grok application objects.
Expand All @@ -53,9 +54,9 @@ class Application(Site):
that the admin can install directly at the root of their Zope
database.
"""
implements(IApplication)


@implementer(IContext, IAttributeAnnotatable)
class LocalUtility(Contained, Persistent):
"""The base class for local utilities in Grok applications.
Expand All @@ -76,4 +77,3 @@ class LocalUtility(Contained, Persistent):
case Grok cannot tell them apart, and `grok.provides()` must be
used explicitly anyway).
"""
implements(IContext, IAttributeAnnotatable)
4 changes: 2 additions & 2 deletions src/grokcore/site/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __init__(self, factory, provides, name=u'',
self.order = LocalUtilityInfo._order
LocalUtilityInfo._order += 1

def __cmp__(self, other):
def __lt__(self, other):
# LocalUtilityInfos have an inherit sort order by which the
# registrations take place.
return cmp(self.order, other.order)
return self.order < other.order
3 changes: 1 addition & 2 deletions src/grokcore/site/ftests/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
>>> grokcore.site.util.create_application(object(), root, 'myobject')
Traceback (most recent call last):
...
WrongType: ...
zope.schema._bootstrapinterfaces.WrongType: ...
"""
import grokcore.content
Expand Down
15 changes: 11 additions & 4 deletions src/grokcore/site/ftests/test_grok_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
from pkg_resources import resource_listdir

from zope.app.appsetup.testlayer import ZODBLayer
from zope.testing import renormalizing

import grokcore.site

FunctionalLayer = ZODBLayer(grokcore.site)


checker = renormalizing.RENormalizing([])


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
suite = unittest.TestSuite()
Expand All @@ -20,11 +25,13 @@ def suiteFromPackage(name):
dottedname = 'grokcore.site.ftests.%s.%s' % (name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
checker=checker,
extraglobs=dict(getRootFolder=FunctionalLayer.getRootFolder),
optionflags=(doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF)
)
optionflags=(
doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF +
renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2))
test.layer = FunctionalLayer

suite.addTest(test)
Expand Down
8 changes: 5 additions & 3 deletions src/grokcore/site/ftests/utility/install_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@
True
"""
import grokcore.site
from zope.interface import Interface, implements
from zope.interface import Interface, implementer
from zope.component.interfaces import ObjectEvent, IObjectEvent


class IPartyEvent(IObjectEvent):
pass


@implementer(IPartyEvent)
class PartyEvent(ObjectEvent):
implements(IPartyEvent)
pass


class IClub(Interface):
pass


@implementer(IClub)
class Club(grokcore.site.LocalUtility):
implements(IClub)
pass


class Cave(grokcore.site.Site):
Expand Down
33 changes: 19 additions & 14 deletions src/grokcore/site/ftests/utility/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,37 @@
>>> component.getUtility(IFireplace)
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IFireplace>, '')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IFireplace>, '')
>>> component.getUtility(IClub)
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IClub>, '')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IClub>, '')
>>> component.getUtility(IClub, name='spiky')
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IClub>, 'spiky')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IClub>, 'spiky')
>>> component.getUtility(IMammoth)
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IMammoth>, '')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IMammoth>, '')
>>> component.getUtility(IMammoth, name='tiger')
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IMammoth>, 'tiger')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IMammoth>, 'tiger')
>>> component.getUtility(IPainting, name='blackandwhite')
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IPainting>, 'blackandwhite')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IPainting>, 'blackandwhite')
>>> component.getUtility(IPainting, name='color')
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IPainting>, 'color')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.local.IPainting>, 'color')
"""
import grokcore.site
from zope import interface
Expand All @@ -110,37 +110,42 @@ class IMammoth(interface.Interface):
pass


@interface.implementer(IFireplace)
class Fireplace(grokcore.site.LocalUtility):
interface.implements(IFireplace)
pass


@interface.implementer(IClub)
class Club(object):
interface.implements(IClub)
pass


@interface.implementer(IClub, ISpiky)
class SpikyClub(object):
interface.implements(IClub, ISpiky)
pass


@interface.implementer(IMammoth, IClub)
class Mammoth(grokcore.site.LocalUtility):
interface.implements(IMammoth, IClub)
pass


@interface.implementer(IMammoth, IClub)
class SabretoothTiger(grokcore.site.LocalUtility):
interface.implements(IMammoth, IClub)
grokcore.site.provides(IMammoth)


class IPainting(persistent.interfaces.IPersistent):
pass


@interface.implementer(IPainting)
class CavePainting(grokcore.site.LocalUtility):
interface.implements(IPainting)
pass


@interface.implementer(IPainting)
class ColoredCavePainting(grokcore.site.LocalUtility):
interface.implements(IPainting)
grokcore.site.provides(IPainting)


Expand Down
15 changes: 11 additions & 4 deletions src/grokcore/site/ftests/utility/local_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
>>> isinstance(club, SpikyClub)
True
>>> list(cave.getSiteManager().keys())
[u'SpikyClub']
>>> names = list(cave.getSiteManager().keys())
>>> len(names)
1
>>> print(names[0])
SpikyClub
"""
import grokcore.site
from zope import interface
Expand All @@ -26,12 +31,14 @@ class IClub(interface.Interface):
pass


@interface.implementer(IClub)
class Club(grokcore.site.LocalUtility):
interface.implements(IClub)
pass


@interface.implementer(IClub)
class SpikyClub(grokcore.site.LocalUtility):
interface.implements(IClub)
pass


class Cave(grokcore.site.Site):
Expand Down
3 changes: 2 additions & 1 deletion src/grokcore/site/ftests/utility/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class IFireplace(interface.Interface):
pass


@interface.implementer(IFireplace)
class Fireplace(grokcore.site.LocalUtility):
interface.implements(IFireplace)
pass


class Cave(BTreeContainer, grokcore.site.Site):
Expand Down
8 changes: 5 additions & 3 deletions src/grokcore/site/ftests/utility/subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
>>> painting = component.getUtility(IPainting)
Traceback (most recent call last):
...
ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.subclass.IPainting>, '')
zope.interface.interfaces.ComponentLookupError: (<InterfaceClass grokcore.site.ftests.utility.subclass.IPainting>, '')
This works various levels of inheritance deep:
Expand Down Expand Up @@ -76,12 +76,14 @@ class IPainting(interface.Interface):
pass


@interface.implementer(IFireplace)
class Fireplace(grokcore.site.LocalUtility):
interface.implements(IFireplace)
pass


@interface.implementer(IPainting)
class Painting(grokcore.site.LocalUtility):
interface.implements(IPainting)
pass


class Cave(grokcore.site.Site):
Expand Down
Loading

0 comments on commit 76ea8b0

Please sign in to comment.