Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Use @implementer class decorator.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed Sep 13, 2016
1 parent b6dfb51 commit 81fe01b
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
4.0a2 (unreleased)
------------------

- Use `@implementer` class decorator.

4.0a1 (2016-09-09)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/ZServer/Testing/doctest_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
basestring = str


# @zope.interface.implementer(zope.server.interfaces.IHeaderOutput)
class HTTPHeaderOutput:

# zope.interface.implements(zope.server.interfaces.IHeaderOutput)
status = '200'
reason = 'OK'

Expand Down
5 changes: 2 additions & 3 deletions src/ZServer/Testing/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import sys

import transaction
from zope.interface import implements
from zope.interface import implementer

from Testing.ZopeTestCase import sandbox
from Testing.ZopeTestCase import interfaces
Expand All @@ -45,6 +45,7 @@ def wrapped_func(*args, **kw):
return wrapped_func


@implementer(interfaces.IFunctional)
class Functional(sandbox.Sandboxed):
'''Derive from this class and an xTestCase to get functional
testing support::
Expand All @@ -53,8 +54,6 @@ class MyTest(Functional, ZopeTestCase):
...
'''

implements(interfaces.IFunctional)

@savestate
def publish(self, path, basic=None, env=None, extra=None,
request_method='GET', stdin=None, handle_errors=True):
Expand Down
5 changes: 2 additions & 3 deletions src/ZServer/ZPublisher/tests/test_publish.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import doctest

from zope.interface import implements
from zope.interface import implementer
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.publisher.interfaces.browser import IBrowserRequest
from ZPublisher import Retry
Expand Down Expand Up @@ -88,12 +88,11 @@ def setBody(self, a):
pass


@implementer(IBrowserRequest)
class Request:
"""Mock Request to replace ZPublisher.HTTPRequest.HTTPRequest.
"""

implements(IBrowserRequest)

args = ()

def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions src/ZServer/tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ZServer.FCGIServer import FCGIResponse
from ZPublisher.Iterators import IStreamIterator
from ZPublisher.pubevents import PubBeforeStreaming
from zope.interface import implements
from zope.interface import implementer
import unittest
from cStringIO import StringIO

Expand Down Expand Up @@ -86,8 +86,8 @@ def write(self, data, len=None):
break
self.out.write(s)

@implementer(IStreamIterator)
class test_streamiterator:
implements(IStreamIterator)
data = "hello"
done = 0

Expand Down
5 changes: 2 additions & 3 deletions src/webdav/Collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from OFS.Lockable import wl_isLocked
from zExceptions import MethodNotAllowed
from zExceptions import NotFound
from zope.interface import implements
from zope.interface import implementer

from webdav.common import Locked
from webdav.common import PreconditionFailed
Expand All @@ -32,15 +32,14 @@
from webdav.Resource import Resource


@implementer(IDAVCollection)
class Collection(Resource):

"""The Collection class provides basic WebDAV support for
collection objects. It provides default implementations
for all supported WebDAV HTTP methods. The behaviors of some
WebDAV HTTP methods for collections are slightly different
than those for non-collection resources."""

implements(IDAVCollection)
security = ClassSecurityInfo()

__dav_collection__=1
Expand Down
5 changes: 2 additions & 3 deletions src/webdav/Resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import ZServer.Zope2.Startup.config
from ZPublisher.HTTPRangeSupport import HTTPRangeInterface

from zope.interface import implements
from zope.interface import implementer
from zope.event import notify
from zope.lifecycleevent import ObjectCopiedEvent
from zope.lifecycleevent import ObjectMovedEvent
Expand All @@ -67,6 +67,7 @@

ms_dav_agent = re.compile("Microsoft.*Internet Publishing.*")

@implementer(IDAVResource)
class Resource(Base, LockableItem):

"""The Resource mixin class provides basic WebDAV support for
Expand All @@ -75,8 +76,6 @@ class Resource(Base, LockableItem):
such as PUT should be overridden to ensure correct behavior in
the context of the object type."""

implements(IDAVResource)

__dav_resource__=1

__http_methods__=('GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS',
Expand Down
4 changes: 2 additions & 2 deletions src/webdav/tests/testCopySupportEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ITestItem(interface.Interface):
pass


@interface.implementer(ITestItem)
class TestItem(SimpleItem):
interface.implements(ITestItem)

def __init__(self, id):
self.id = id
Expand All @@ -49,8 +49,8 @@ class ITestFolder(interface.Interface):
pass


@interface.implementer(ITestFolder)
class TestFolder(Folder):
interface.implements(ITestFolder)

def __init__(self, id):
self.id = id
Expand Down
13 changes: 6 additions & 7 deletions src/webdav/tests/test_davcmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from OFS.interfaces import IWriteLock
from zExceptions import Forbidden
from zope.interface import implements
from zope.interface import implementer


class _DummySecurityPolicy(object):
Expand All @@ -13,11 +14,9 @@ def checkPermission(self, permission, object, context):
return False


@implementer(IWriteLock)
class _DummyContent(object):

from OFS.interfaces import IWriteLock
implements(IWriteLock)

def __init__(self, token=None):
self.token = token

Expand Down Expand Up @@ -49,7 +48,7 @@ def test_apply_bogus_lock(self):
Prior to Zope 2.11, we returned a 204 under this circumstance.
We choose do what mod_dav does, which is return a '400 Bad
Request' error.
This was caught by litmus locks.notowner_lock test #10.
"""
inst = self._makeOne()
Expand Down Expand Up @@ -91,7 +90,7 @@ def test_parse_xml_property_values_with_namespaces(self):
</set>
</propertyupdate>"""

request = {'BODY':reqbody}
request = {'BODY': reqbody}

inst = self._makeOne(request)
self.assertEqual(len(inst.values), 1)
Expand Down Expand Up @@ -142,4 +141,4 @@ def test_suite():
unittest.makeSuite(TestUnlock),
unittest.makeSuite(TestPropPatch),
unittest.makeSuite(TestDeleteCollection),
))
))

0 comments on commit 81fe01b

Please sign in to comment.