Skip to content

Commit

Permalink
- updated imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Jul 18, 2012
1 parent af8c23c commit 301616a
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/OFS/ObjectManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
from webdav.Lockable import ResourceLockedError
from webdav.NullResource import NullResource
from zExceptions import BadRequest
from zope.interface import implements
from zope.component.interfaces import ComponentLookupError
from zope.container.contained import notifyContainerModified
from zope.event import notify
from zope.interface import implements
from zope.interface.interfaces import ComponentLookupError
from zope.lifecycleevent import ObjectAddedEvent
from zope.lifecycleevent import ObjectRemovedEvent
from zope.container.contained import notifyContainerModified

from OFS.CopySupport import CopyContainer
from OFS.interfaces import IObjectManager
Expand Down
9 changes: 8 additions & 1 deletion src/OFS/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"""

from zope.interface import implements
from zope.component.interfaces import ObjectEvent
from zope.interface.interfaces import ObjectEvent
import OFS.interfaces


class ObjectWillBeMovedEvent(ObjectEvent):

"""An object will be moved."""
implements(OFS.interfaces.IObjectWillBeMovedEvent)

Expand All @@ -31,7 +32,9 @@ def __init__(self, object, oldParent, oldName, newParent, newName):
self.newParent = newParent
self.newName = newName


class ObjectWillBeAddedEvent(ObjectWillBeMovedEvent):

"""An object will be added to a container."""
implements(OFS.interfaces.IObjectWillBeAddedEvent)

Expand All @@ -43,7 +46,9 @@ def __init__(self, object, newParent=None, newName=None):
ObjectWillBeMovedEvent.__init__(self, object, None, None,
newParent, newName)


class ObjectWillBeRemovedEvent(ObjectWillBeMovedEvent):

"""An object will be removed from a container."""
implements(OFS.interfaces.IObjectWillBeRemovedEvent)

Expand All @@ -55,6 +60,8 @@ def __init__(self, object, oldParent=None, oldName=None):
ObjectWillBeMovedEvent.__init__(self, object, oldParent, oldName,
None, None)


class ObjectClonedEvent(ObjectEvent):

"""An object has been cloned into a container."""
implements(OFS.interfaces.IObjectClonedEvent)
6 changes: 4 additions & 2 deletions src/OFS/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from zope.container.interfaces import IContainer
from zope.interface import Attribute
from zope.interface import Interface
from zope.interface.interfaces import IObjectEvent
from zope.location.interfaces import IRoot
from zope.schema import Bool, BytesLine, Tuple

Expand Down Expand Up @@ -871,21 +872,22 @@ def getPhysicalRoot():
##################################################
# Event interfaces

from zope.component.interfaces import IObjectEvent

class IObjectWillBeMovedEvent(IObjectEvent):
"""An object will be moved."""
oldParent = Attribute("The old location parent for the object.")
oldName = Attribute("The old location name for the object.")
newParent = Attribute("The new location parent for the object.")
newName = Attribute("The new location name for the object.")


class IObjectWillBeAddedEvent(IObjectWillBeMovedEvent):
"""An object will be added to a container."""


class IObjectWillBeRemovedEvent(IObjectWillBeMovedEvent):
"""An object will be removed from a container"""


class IObjectClonedEvent(IObjectEvent):
"""An object has been cloned (a la Zope 2).
Expand Down
9 changes: 5 additions & 4 deletions src/OFS/tests/event.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ not for (None, IObjectEvent), and register our subscribers before the
framework's ones, so ours will be called first. This has the effect that
printed events will be in their "natural" order::

>>> from zope.component.interfaces import IObjectEvent, IRegistrationEvent
>>> from zope.lifecycleevent.interfaces import IObjectMovedEvent
>>> from zope.interface.interfaces import IObjectEvent
>>> from zope.interface.interfaces import IRegistrationEvent
>>> from zope.lifecycleevent.interfaces import IObjectCopiedEvent
>>> from OFS.interfaces import IObjectWillBeMovedEvent
>>> from OFS.interfaces import IObjectClonedEvent
>>> from zope.lifecycleevent.interfaces import IObjectMovedEvent
>>> from OFS.interfaces import IItem
>>> from OFS.interfaces import IObjectClonedEvent
>>> from OFS.interfaces import IObjectWillBeMovedEvent
>>> def printObjectEvent(object, event):
... print event.__class__.__name__, object.getId()
>>> def printObjectEventExceptSome(object, event):
Expand Down
19 changes: 8 additions & 11 deletions src/OFS/tests/testCopySupportEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@

import transaction

from Testing.makerequest import makerequest
from zope import component
from zope import interface
from zope.interface.interfaces import IObjectEvent
from zope.testing import cleanup

from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager

from OFS.SimpleItem import SimpleItem
from OFS.Folder import Folder

from OFS.SimpleItem import SimpleItem
from Testing.makerequest import makerequest
from Zope2.App import zcml

from zope import interface
from zope import component
from zope.component.interfaces import IObjectEvent

from zope.testing import cleanup


class EventLogger(object):
def __init__(self):
Expand All @@ -38,6 +34,7 @@ def called(self):
class ITestItem(interface.Interface):
pass


class TestItem(SimpleItem):
interface.implements(ITestItem)
def __init__(self, id):
Expand All @@ -47,6 +44,7 @@ def __init__(self, id):
class ITestFolder(interface.Interface):
pass


class TestFolder(Folder):
interface.implements(ITestFolder)
def __init__(self, id):
Expand Down Expand Up @@ -330,4 +328,3 @@ def test_suite():
suite.addTest(makeSuite(TestCopySupport))
suite.addTest(makeSuite(TestCopySupportSublocation))
return suite

3 changes: 2 additions & 1 deletion src/Products/Five/browser/tests/test_pagetemplatefile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest


class ViewPageTemplateFileTests(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -192,7 +193,7 @@ def _makeOne(self, ob=None, request=None):
return self._getTargetClass()(ob, request)

def test___getitem___miss(self):
from zope.component import ComponentLookupError
from zope.interface.interfaces import ComponentLookupError
mapper = self._makeOne()
self.assertRaises(ComponentLookupError, mapper.__getitem__, 'nonesuch')

Expand Down
4 changes: 2 additions & 2 deletions src/Products/Five/component/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import zope.component
import zope.event
import zope.interface
from zope.component.interfaces import IComponentLookup
from zope.component.interfaces import IPossibleSite
from zope.component.interfaces import ISite
from zope.interface.interfaces import IComponentLookup
from zope.traversing.interfaces import BeforeTraverseEvent

import ExtensionClass
Expand Down Expand Up @@ -64,7 +64,7 @@ def enableSite(obj, iface=ISite):
# We want the original object, not stuff in between, and no acquisition
obj = aq_base(obj)
if not IPossibleSite.providedBy(obj):
raise TypeError, 'Must provide IPossibleSite'
raise TypeError('Must provide IPossibleSite')
hook = NameCaller(HOOK_NAME)
registerBeforeTraverse(obj, hook, HOOK_NAME, 1)

Expand Down
2 changes: 1 addition & 1 deletion src/Products/Five/component/component.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Now we create a site object with a stub component registry:
When we adapt the site itself, we obviously get its component
registry:

>>> from zope.component.interfaces import IComponentLookup
>>> from zope.interface.interfaces import IComponentLookup
>>> IComponentLookup(site) is components
True

Expand Down
2 changes: 1 addition & 1 deletion src/Products/Five/component/makesite.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ We get the site manager for the folder and assert that it is indeed a
component registry:

>>> sm = app.folder.getSiteManager()
>>> from zope.component.interfaces import IComponents
>>> from zope.interface.interfaces import IComponents
>>> IComponents.providedBy(sm)
True

Expand Down
6 changes: 3 additions & 3 deletions src/Products/Five/viewlet/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ViewletManagerBase(origManagerBase):
"""A base class for Viewlet managers to work in Zope2"""

template = None

def __getitem__(self, name):
"""See zope.interface.common.mapping.IReadMapping"""
# Find the viewlet
Expand All @@ -37,7 +37,7 @@ def __getitem__(self, name):

# If the viewlet was not found, then raise a lookup error
if viewlet is None:
raise zope.component.interfaces.ComponentLookupError(
raise zope.interface.interfaces.ComponentLookupError(
'No provider with name `%s` found.' %name)

# If the viewlet cannot be accessed, then raise an
Expand Down Expand Up @@ -77,7 +77,7 @@ def sort(self, viewlets):

def ViewletManager(name, interface, template=None, bases=()):
attrDict = {'__name__': name}

if template is not None:
attrDict['template'] = ZopeTwoPageTemplateFile(template)

Expand Down

0 comments on commit 301616a

Please sign in to comment.