Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7214980c
Commit
7214980c
authored
Sep 13, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `@implementer` and `@adapter` class decorators.
parent
32e810f1
Changes
57
Hide whitespace changes
Inline
Side-by-side
Showing
57 changed files
with
207 additions
and
238 deletions
+207
-238
CHANGES.rst
CHANGES.rst
+1
-0
src/App/Management.py
src/App/Management.py
+2
-3
src/OFS/Application.py
src/OFS/Application.py
+2
-3
src/OFS/CopySupport.py
src/OFS/CopySupport.py
+3
-5
src/OFS/EtagSupport.py
src/OFS/EtagSupport.py
+2
-2
src/OFS/FindSupport.py
src/OFS/FindSupport.py
+2
-3
src/OFS/Folder.py
src/OFS/Folder.py
+2
-3
src/OFS/Image.py
src/OFS/Image.py
+3
-10
src/OFS/LockItem.py
src/OFS/LockItem.py
+2
-3
src/OFS/Lockable.py
src/OFS/Lockable.py
+2
-2
src/OFS/ObjectManager.py
src/OFS/ObjectManager.py
+2
-3
src/OFS/OrderSupport.py
src/OFS/OrderSupport.py
+2
-3
src/OFS/OrderedFolder.py
src/OFS/OrderedFolder.py
+2
-2
src/OFS/PropertyManager.py
src/OFS/PropertyManager.py
+2
-3
src/OFS/SimpleItem.py
src/OFS/SimpleItem.py
+4
-7
src/OFS/Traversable.py
src/OFS/Traversable.py
+2
-2
src/OFS/absoluteurl.py
src/OFS/absoluteurl.py
+3
-3
src/OFS/event.py
src/OFS/event.py
+5
-5
src/OFS/event.txt
src/OFS/event.txt
+2
-2
src/OFS/subscribers.py
src/OFS/subscribers.py
+2
-2
src/OFS/tests/testCopySupportEvents.py
src/OFS/tests/testCopySupportEvents.py
+2
-2
src/OFS/tests/testLockable.py
src/OFS/tests/testLockable.py
+2
-2
src/OFS/tests/testObjectManager.py
src/OFS/tests/testObjectManager.py
+2
-2
src/OFS/tests/test_metaconfigure.py
src/OFS/tests/test_metaconfigure.py
+5
-4
src/OFS/tests/test_registerclass.py
src/OFS/tests/test_registerclass.py
+2
-2
src/Products/Five/browser/adding.py
src/Products/Five/browser/adding.py
+3
-4
src/Products/Five/browser/resource.py
src/Products/Five/browser/resource.py
+2
-2
src/Products/Five/browser/tests/classes.py
src/Products/Five/browser/tests/classes.py
+2
-2
src/Products/Five/browser/tests/provider.txt
src/Products/Five/browser/tests/provider.txt
+17
-13
src/Products/Five/browser/tests/test_pages.py
src/Products/Five/browser/tests/test_pages.py
+4
-3
src/Products/Five/browser/tests/test_recurse.py
src/Products/Five/browser/tests/test_recurse.py
+3
-3
src/Products/Five/doc/manual.txt
src/Products/Five/doc/manual.txt
+13
-13
src/Products/Five/skin/standardmacros.py
src/Products/Five/skin/standardmacros.py
+1
-1
src/Products/Five/tests/adapters.py
src/Products/Five/tests/adapters.py
+9
-8
src/Products/Five/tests/test_size.py
src/Products/Five/tests/test_size.py
+3
-3
src/Products/Five/tests/testing/fancycontent.py
src/Products/Five/tests/testing/fancycontent.py
+3
-4
src/Products/Five/tests/testing/folder.py
src/Products/Five/tests/testing/folder.py
+2
-2
src/Products/Five/tests/testing/simplecontent.py
src/Products/Five/tests/testing/simplecontent.py
+4
-4
src/Products/Five/utilities/marker.py
src/Products/Five/utilities/marker.py
+2
-3
src/Products/Five/viewlet/README.txt
src/Products/Five/viewlet/README.txt
+20
-19
src/Products/Five/viewlet/tests.py
src/Products/Five/viewlet/tests.py
+3
-2
src/Products/PageTemplates/Expressions.py
src/Products/PageTemplates/Expressions.py
+2
-4
src/Products/PageTemplates/engine.py
src/Products/PageTemplates/engine.py
+4
-4
src/Products/PageTemplates/unicodeconflictresolver.py
src/Products/PageTemplates/unicodeconflictresolver.py
+4
-7
src/Testing/ZopeTestCase/PortalTestCase.py
src/Testing/ZopeTestCase/PortalTestCase.py
+3
-4
src/Testing/ZopeTestCase/ZopeTestCase.py
src/Testing/ZopeTestCase/ZopeTestCase.py
+2
-3
src/Testing/ZopeTestCase/base.py
src/Testing/ZopeTestCase/base.py
+2
-3
src/Testing/ZopeTestCase/functional.py
src/Testing/ZopeTestCase/functional.py
+2
-3
src/Testing/ZopeTestCase/testPlaceless.py
src/Testing/ZopeTestCase/testPlaceless.py
+5
-5
src/Testing/ZopeTestCase/zopedoctest/functional.py
src/Testing/ZopeTestCase/zopedoctest/functional.py
+2
-3
src/ZPublisher/BaseRequest.py
src/ZPublisher/BaseRequest.py
+2
-3
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+2
-6
src/ZPublisher/Iterators.py
src/ZPublisher/Iterators.py
+2
-3
src/ZPublisher/pubevents.py
src/ZPublisher/pubevents.py
+8
-8
src/ZPublisher/tests/testBaseRequest.py
src/ZPublisher/tests/testBaseRequest.py
+6
-7
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+8
-8
src/Zope2/App/schema.py
src/Zope2/App/schema.py
+2
-3
No files found.
CHANGES.rst
View file @
7214980c
...
@@ -19,6 +19,7 @@ Features Added
...
@@ -19,6 +19,7 @@ Features Added
Restructuring
Restructuring
+++++++++++++
+++++++++++++
- Use `@implementer` and `@adapter` class decorators.
4.0a2 (2016-09-09)
4.0a2 (2016-09-09)
------------------
------------------
...
...
src/App/Management.py
View file @
7214980c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
from
cgi
import
escape
from
cgi
import
escape
import
urllib
import
urllib
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.class_init
import
InitializeClass
...
@@ -132,11 +132,10 @@ class Tabs(Base):
...
@@ -132,11 +132,10 @@ class Tabs(Base):
InitializeClass
(
Tabs
)
InitializeClass
(
Tabs
)
@
implementer
(
INavigation
)
class
Navigation
(
Base
):
class
Navigation
(
Base
):
"""Basic navigation UI support"""
"""Basic navigation UI support"""
implements
(
INavigation
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareProtected
(
view_management_screens
,
'manage'
)
security
.
declareProtected
(
view_management_screens
,
'manage'
)
...
...
src/OFS/Application.py
View file @
7214980c
...
@@ -35,7 +35,7 @@ from zExceptions import (
...
@@ -35,7 +35,7 @@ from zExceptions import (
Forbidden
,
Forbidden
,
Redirect
as
RedirectException
,
Redirect
as
RedirectException
,
)
)
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
import
Folder
import
Folder
import
misc_
import
misc_
...
@@ -52,11 +52,10 @@ LOG = getLogger('Application')
...
@@ -52,11 +52,10 @@ LOG = getLogger('Application')
APP_MANAGER
=
None
APP_MANAGER
=
None
@
implementer
(
IApplication
)
class
Application
(
ApplicationDefaultPermissions
,
Folder
.
Folder
):
class
Application
(
ApplicationDefaultPermissions
,
Folder
.
Folder
):
"""Top-level system object"""
"""Top-level system object"""
implements
(
IApplication
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
title
=
'Zope'
title
=
'Zope'
...
...
src/OFS/CopySupport.py
View file @
7214980c
...
@@ -36,7 +36,7 @@ from Acquisition import aq_parent
...
@@ -36,7 +36,7 @@ from Acquisition import aq_parent
from
ExtensionClass
import
Base
from
ExtensionClass
import
Base
from
zExceptions
import
Unauthorized
,
BadRequest
,
ResourceLockedError
from
zExceptions
import
Unauthorized
,
BadRequest
,
ResourceLockedError
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.event
import
notify
from
zope.event
import
notify
from
zope.lifecycleevent
import
ObjectCopiedEvent
from
zope.lifecycleevent
import
ObjectCopiedEvent
from
zope.lifecycleevent
import
ObjectMovedEvent
from
zope.lifecycleevent
import
ObjectMovedEvent
...
@@ -59,12 +59,11 @@ copy_re = re.compile('^copy([0-9]*)_of_(.*)')
...
@@ -59,12 +59,11 @@ copy_re = re.compile('^copy([0-9]*)_of_(.*)')
_marker
=
[]
_marker
=
[]
@
implementer
(
ICopyContainer
)
class
CopyContainer
(
Base
):
class
CopyContainer
(
Base
):
"""Interface for containerish objects which allow cut/copy/paste"""
"""Interface for containerish objects which allow cut/copy/paste"""
implements
(
ICopyContainer
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
# The following three methods should be overridden to store sub-objects
# The following three methods should be overridden to store sub-objects
...
@@ -448,12 +447,11 @@ class CopyContainer(Base):
...
@@ -448,12 +447,11 @@ class CopyContainer(Base):
InitializeClass
(
CopyContainer
)
InitializeClass
(
CopyContainer
)
@
implementer
(
ICopySource
)
class
CopySource
(
Base
):
class
CopySource
(
Base
):
"""Interface for objects which allow themselves to be copied."""
"""Interface for objects which allow themselves to be copied."""
implements
(
ICopySource
)
# declare a dummy permission for Copy or Move here that we check
# declare a dummy permission for Copy or Move here that we check
# in cb_isCopyable.
# in cb_isCopyable.
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
...
src/OFS/EtagSupport.py
View file @
7214980c
...
@@ -15,7 +15,7 @@ import time
...
@@ -15,7 +15,7 @@ import time
from
Acquisition
import
aq_acquire
from
Acquisition
import
aq_acquire
from
zExceptions
import
HTTPPreconditionFailed
from
zExceptions
import
HTTPPreconditionFailed
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
Interface
from
zope.interface
import
Interface
...
@@ -56,6 +56,7 @@ class EtagBaseInterface(Interface):
...
@@ -56,6 +56,7 @@ class EtagBaseInterface(Interface):
"""
"""
@
implementer
(
EtagBaseInterface
)
class
EtagSupport
(
object
):
class
EtagSupport
(
object
):
"""
"""
This class is the basis for supporting Etags in Zope. It's main
This class is the basis for supporting Etags in Zope. It's main
...
@@ -68,7 +69,6 @@ class EtagSupport(object):
...
@@ -68,7 +69,6 @@ class EtagSupport(object):
can be rejected according to the type of header (If-Match,
can be rejected according to the type of header (If-Match,
If-None-Match).
If-None-Match).
"""
"""
implements
(
EtagBaseInterface
)
def
http__etag
(
self
,
readonly
=
0
):
def
http__etag
(
self
,
readonly
=
0
):
try
:
try
:
...
...
src/OFS/FindSupport.py
View file @
7214980c
...
@@ -26,16 +26,15 @@ from DocumentTemplate.DT_Util import InstanceDict
...
@@ -26,16 +26,15 @@ from DocumentTemplate.DT_Util import InstanceDict
from
DocumentTemplate.DT_Util
import
TemplateDict
from
DocumentTemplate.DT_Util
import
TemplateDict
from
DocumentTemplate.security
import
RestrictedDTML
from
DocumentTemplate.security
import
RestrictedDTML
from
ExtensionClass
import
Base
from
ExtensionClass
import
Base
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS.interfaces
import
IFindSupport
from
OFS.interfaces
import
IFindSupport
@
implementer
(
IFindSupport
)
class
FindSupport
(
Base
):
class
FindSupport
(
Base
):
"""Find support for Zope Folders"""
"""Find support for Zope Folders"""
implements
(
IFindSupport
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareProtected
(
view_management_screens
,
'ZopeFind'
)
security
.
declareProtected
(
view_management_screens
,
'ZopeFind'
)
...
...
src/OFS/Folder.py
View file @
7214980c
...
@@ -17,7 +17,7 @@ Folders are the basic container objects and are analogous to directories.
...
@@ -17,7 +17,7 @@ Folders are the basic container objects and are analogous to directories.
from
AccessControl.class_init
import
InitializeClass
from
AccessControl.class_init
import
InitializeClass
from
App.special_dtml
import
DTMLFile
from
App.special_dtml
import
DTMLFile
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS
import
bbb
from
OFS
import
bbb
from
OFS.interfaces
import
IFolder
from
OFS.interfaces
import
IFolder
...
@@ -50,6 +50,7 @@ def manage_addFolder(self, id, title='',
...
@@ -50,6 +50,7 @@ def manage_addFolder(self, id, title='',
return
self
.
manage_main
(
self
,
REQUEST
)
return
self
.
manage_main
(
self
,
REQUEST
)
@
implementer
(
IFolder
)
class
Folder
(
class
Folder
(
ObjectManager
,
ObjectManager
,
PropertyManager
,
PropertyManager
,
...
@@ -62,8 +63,6 @@ class Folder(
...
@@ -62,8 +63,6 @@ class Folder(
interface for object management. Folder objects also implement
interface for object management. Folder objects also implement
a management interface and can have arbitrary properties.
a management interface and can have arbitrary properties.
"""
"""
implements
(
IFolder
)
meta_type
=
'Folder'
meta_type
=
'Folder'
_properties
=
(
_properties
=
(
...
...
src/OFS/Image.py
View file @
7214980c
...
@@ -31,8 +31,7 @@ from Persistence import Persistent
...
@@ -31,8 +31,7 @@ from Persistence import Persistent
from
zExceptions
import
Redirect
,
ResourceLockedError
from
zExceptions
import
Redirect
,
ResourceLockedError
from
zope.contenttype
import
guess_content_type
from
zope.contenttype
import
guess_content_type
from
zope.event
import
notify
from
zope.event
import
notify
from
zope.interface
import
implementedBy
from
zope.interface
import
implementer
from
zope.interface
import
implements
from
zope.lifecycleevent
import
ObjectCreatedEvent
from
zope.lifecycleevent
import
ObjectCreatedEvent
from
zope.lifecycleevent
import
ObjectModifiedEvent
from
zope.lifecycleevent
import
ObjectModifiedEvent
...
@@ -87,18 +86,12 @@ def manage_addFile(self, id, file='', title='', precondition='',
...
@@ -87,18 +86,12 @@ def manage_addFile(self, id, file='', title='', precondition='',
raise
Redirect
(
self
.
absolute_url
()
+
'/manage_main'
)
raise
Redirect
(
self
.
absolute_url
()
+
'/manage_main'
)
@
implementer
(
IWriteLock
,
HTTPRangeSupport
.
HTTPRangeInterface
)
class
File
(
Persistent
,
Implicit
,
PropertyManager
,
class
File
(
Persistent
,
Implicit
,
PropertyManager
,
RoleManager
,
Item_w__name__
,
Cacheable
):
RoleManager
,
Item_w__name__
,
Cacheable
):
"""A File object is a content object for arbitrary files."""
"""A File object is a content object for arbitrary files."""
implements
(
implementedBy
(
Persistent
),
implementedBy
(
Implicit
),
implementedBy
(
PropertyManager
),
implementedBy
(
RoleManager
),
implementedBy
(
Item_w__name__
),
IWriteLock
,
HTTPRangeSupport
.
HTTPRangeInterface
)
meta_type
=
'File'
meta_type
=
'File'
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
...
src/OFS/LockItem.py
View file @
7214980c
...
@@ -18,7 +18,7 @@ from AccessControl.class_init import InitializeClass
...
@@ -18,7 +18,7 @@ from AccessControl.class_init import InitializeClass
from
AccessControl.owner
import
ownerInfo
from
AccessControl.owner
import
ownerInfo
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS.interfaces
import
ILockItem
from
OFS.interfaces
import
ILockItem
...
@@ -50,10 +50,9 @@ def validateTimeout(timeout):
...
@@ -50,10 +50,9 @@ def validateTimeout(timeout):
return
timeout
,
errors
return
timeout
,
errors
@
implementer
(
ILockItem
)
class
LockItem
(
Persistent
):
class
LockItem
(
Persistent
):
implements
(
ILockItem
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declarePublic
(
'getOwner'
,
'getLockToken'
,
'getDepth'
,
security
.
declarePublic
(
'getOwner'
,
'getLockToken'
,
'getDepth'
,
'getTimeout'
,
'getTimeoutString'
,
'getTimeout'
,
'getTimeoutString'
,
...
...
src/OFS/Lockable.py
View file @
7214980c
...
@@ -15,16 +15,16 @@ from AccessControl.class_init import InitializeClass
...
@@ -15,16 +15,16 @@ from AccessControl.class_init import InitializeClass
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Persistence
import
PersistentMapping
from
Persistence
import
PersistentMapping
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS.EtagSupport
import
EtagSupport
from
OFS.EtagSupport
import
EtagSupport
from
OFS.interfaces
import
ILockItem
,
IWriteLock
from
OFS.interfaces
import
ILockItem
,
IWriteLock
@
implementer
(
IWriteLock
)
class
LockableItem
(
EtagSupport
):
class
LockableItem
(
EtagSupport
):
"""Implements the WriteLock interface.
"""Implements the WriteLock interface.
"""
"""
implements
(
IWriteLock
)
# Protect methods using declarative security
# Protect methods using declarative security
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
...
src/OFS/ObjectManager.py
View file @
7214980c
...
@@ -46,7 +46,7 @@ from Persistence import Persistent
...
@@ -46,7 +46,7 @@ from Persistence import Persistent
from
zExceptions
import
BadRequest
,
ResourceLockedError
from
zExceptions
import
BadRequest
,
ResourceLockedError
from
zope.container.contained
import
notifyContainerModified
from
zope.container.contained
import
notifyContainerModified
from
zope.event
import
notify
from
zope.event
import
notify
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface.interfaces
import
ComponentLookupError
from
zope.interface.interfaces
import
ComponentLookupError
from
zope.lifecycleevent
import
ObjectAddedEvent
from
zope.lifecycleevent
import
ObjectAddedEvent
from
zope.lifecycleevent
import
ObjectRemovedEvent
from
zope.lifecycleevent
import
ObjectRemovedEvent
...
@@ -142,6 +142,7 @@ class BreakoutException(Exception):
...
@@ -142,6 +142,7 @@ class BreakoutException(Exception):
_marker
=
[]
_marker
=
[]
@
implementer
(
IObjectManager
)
class
ObjectManager
(
CopyContainer
,
class
ObjectManager
(
CopyContainer
,
Navigation
,
Navigation
,
Tabs
,
Tabs
,
...
@@ -156,8 +157,6 @@ class ObjectManager(CopyContainer,
...
@@ -156,8 +157,6 @@ class ObjectManager(CopyContainer,
This class provides core behavior for collections of heterogeneous objects.
This class provides core behavior for collections of heterogeneous objects.
"""
"""
implements
(
IObjectManager
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
access_contents_information
)
security
.
declareObjectProtected
(
access_contents_information
)
security
.
setPermissionDefault
(
access_contents_information
,
security
.
setPermissionDefault
(
access_contents_information
,
...
...
src/OFS/OrderSupport.py
View file @
7214980c
...
@@ -21,7 +21,7 @@ from AccessControl.Permissions import manage_properties
...
@@ -21,7 +21,7 @@ from AccessControl.Permissions import manage_properties
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
DocumentTemplate.sequence
import
sort
from
DocumentTemplate.sequence
import
sort
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.container.contained
import
notifyContainerModified
from
zope.container.contained
import
notifyContainerModified
from
OFS.interfaces
import
IOrderedContainer
as
IOrderedContainer
from
OFS.interfaces
import
IOrderedContainer
as
IOrderedContainer
...
@@ -31,6 +31,7 @@ if sys.version_info >= (3, ):
...
@@ -31,6 +31,7 @@ if sys.version_info >= (3, ):
basestring
=
str
basestring
=
str
@
implementer
(
IOrderedContainer
)
class
OrderSupport
(
object
):
class
OrderSupport
(
object
):
""" Ordered container mixin class.
""" Ordered container mixin class.
...
@@ -40,8 +41,6 @@ class OrderSupport(object):
...
@@ -40,8 +41,6 @@ class OrderSupport(object):
particular helpful, if the order does not depend on object attributes, but
particular helpful, if the order does not depend on object attributes, but
is totally user-specific.
is totally user-specific.
"""
"""
implements
(
IOrderedContainer
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
has_order_support
=
1
has_order_support
=
1
...
...
src/OFS/OrderedFolder.py
View file @
7214980c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
"""
"""
from
App.special_dtml
import
DTMLFile
from
App.special_dtml
import
DTMLFile
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS.Folder
import
Folder
from
OFS.Folder
import
Folder
from
OFS.interfaces
import
IOrderedFolder
from
OFS.interfaces
import
IOrderedFolder
...
@@ -35,11 +35,11 @@ def manage_addOrderedFolder(self, id, title='', createPublic=0, createUserF=0,
...
@@ -35,11 +35,11 @@ def manage_addOrderedFolder(self, id, title='', createPublic=0, createUserF=0,
return
self
.
manage_main
(
self
,
REQUEST
)
return
self
.
manage_main
(
self
,
REQUEST
)
@
implementer
(
IOrderedFolder
)
class
OrderedFolder
(
OrderSupport
,
Folder
):
class
OrderedFolder
(
OrderSupport
,
Folder
):
""" Extends the default Folder by order support.
""" Extends the default Folder by order support.
"""
"""
implements
(
IOrderedFolder
)
meta_type
=
'Folder (Ordered)'
meta_type
=
'Folder (Ordered)'
manage_options
=
(
manage_options
=
(
...
...
src/OFS/PropertyManager.py
View file @
7214980c
...
@@ -22,7 +22,7 @@ from AccessControl.SecurityInfo import ClassSecurityInfo
...
@@ -22,7 +22,7 @@ from AccessControl.SecurityInfo import ClassSecurityInfo
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
ExtensionClass
import
Base
from
ExtensionClass
import
Base
from
zExceptions
import
BadRequest
from
zExceptions
import
BadRequest
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
ZPublisher.Converters
import
type_converters
from
ZPublisher.Converters
import
type_converters
from
OFS.interfaces
import
IPropertyManager
from
OFS.interfaces
import
IPropertyManager
...
@@ -30,6 +30,7 @@ from OFS.PropertySheets import DefaultPropertySheets
...
@@ -30,6 +30,7 @@ from OFS.PropertySheets import DefaultPropertySheets
from
OFS.PropertySheets
import
vps
from
OFS.PropertySheets
import
vps
@
implementer
(
IPropertyManager
)
class
PropertyManager
(
Base
):
class
PropertyManager
(
Base
):
"""
"""
The PropertyManager mixin class provides an object with
The PropertyManager mixin class provides an object with
...
@@ -77,8 +78,6 @@ class PropertyManager(Base):
...
@@ -77,8 +78,6 @@ class PropertyManager(Base):
are assumed to have the mode 'wd' (writeable and deleteable).
are assumed to have the mode 'wd' (writeable and deleteable).
"""
"""
implements
(
IPropertyManager
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
access_contents_information
)
security
.
declareObjectProtected
(
access_contents_information
)
security
.
setPermissionDefault
(
access_contents_information
,
security
.
setPermissionDefault
(
access_contents_information
,
...
...
src/OFS/SimpleItem.py
View file @
7214980c
...
@@ -50,7 +50,7 @@ from ExtensionClass import Base
...
@@ -50,7 +50,7 @@ from ExtensionClass import Base
from
Persistence
import
Persistent
from
Persistence
import
Persistent
from
zExceptions
import
Redirect
from
zExceptions
import
Redirect
from
zExceptions.ExceptionFormatter
import
format_exception
from
zExceptions.ExceptionFormatter
import
format_exception
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS
import
bbb
from
OFS
import
bbb
from
OFS.interfaces
import
IItem
from
OFS.interfaces
import
IItem
...
@@ -70,6 +70,7 @@ else:
...
@@ -70,6 +70,7 @@ else:
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
@
implementer
(
IItem
)
class
Item
(
Base
,
class
Item
(
Base
,
Resource
,
Resource
,
LockableItem
,
LockableItem
,
...
@@ -79,8 +80,6 @@ class Item(Base,
...
@@ -79,8 +80,6 @@ class Item(Base,
Owned
):
Owned
):
"""A common base class for simple, non-container objects."""
"""A common base class for simple, non-container objects."""
implements
(
IItem
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
isPrincipiaFolderish
=
0
isPrincipiaFolderish
=
0
...
@@ -386,11 +385,10 @@ class Item(Base,
...
@@ -386,11 +385,10 @@ class Item(Base,
InitializeClass
(
Item
)
InitializeClass
(
Item
)
@
implementer
(
IItemWithName
)
class
Item_w__name__
(
Item
):
class
Item_w__name__
(
Item
):
"""Mixin class to support common name/id functions"""
"""Mixin class to support common name/id functions"""
implements
(
IItemWithName
)
def
getId
(
self
):
def
getId
(
self
):
"""Return the id of the object as a string.
"""Return the id of the object as a string.
"""
"""
...
@@ -433,6 +431,7 @@ def pretty_tb(t, v, tb, as_html=1):
...
@@ -433,6 +431,7 @@ def pretty_tb(t, v, tb, as_html=1):
return
tb
return
tb
@
implementer
(
ISimpleItem
)
class
SimpleItem
(
Item
,
class
SimpleItem
(
Item
,
Persistent
,
Persistent
,
Implicit
,
Implicit
,
...
@@ -441,8 +440,6 @@ class SimpleItem(Item,
...
@@ -441,8 +440,6 @@ class SimpleItem(Item,
"""Mix-in class combining the most common set of basic mix-ins
"""Mix-in class combining the most common set of basic mix-ins
"""
"""
implements
(
ISimpleItem
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
setPermissionDefault
(
View
,
(
'Manager'
,))
security
.
setPermissionDefault
(
View
,
(
'Manager'
,))
...
...
src/OFS/Traversable.py
View file @
7214980c
...
@@ -32,7 +32,7 @@ from zExceptions import NotFound
...
@@ -32,7 +32,7 @@ from zExceptions import NotFound
from
ZPublisher.interfaces
import
UseTraversalDefault
from
ZPublisher.interfaces
import
UseTraversalDefault
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
Interface
from
zope.interface
import
Interface
from
zope.component
import
queryMultiAdapter
from
zope.component
import
queryMultiAdapter
from
zope.location.interfaces
import
LocationError
from
zope.location.interfaces
import
LocationError
...
@@ -42,8 +42,8 @@ from zope.traversing.namespace import nsParse
...
@@ -42,8 +42,8 @@ from zope.traversing.namespace import nsParse
_marker
=
object
()
_marker
=
object
()
@
implementer
(
ITraversable
)
class
Traversable
:
class
Traversable
:
implements
(
ITraversable
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
...
src/OFS/absoluteurl.py
View file @
7214980c
...
@@ -17,12 +17,13 @@ from Acquisition import aq_parent
...
@@ -17,12 +17,13 @@ from Acquisition import aq_parent
from
OFS.interfaces
import
ITraversable
from
OFS.interfaces
import
ITraversable
from
zope.component
import
getMultiAdapter
from
zope.component
import
getMultiAdapter
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.traversing.browser.interfaces
import
IAbsoluteURL
from
zope.traversing.browser.interfaces
import
IAbsoluteURL
from
zope.traversing.browser.absoluteurl
import
_insufficientContext
,
_safe
from
zope.traversing.browser.absoluteurl
import
_insufficientContext
,
_safe
from
zope.publisher.browser
import
BrowserView
from
zope.publisher.browser
import
BrowserView
@
implementer
(
IAbsoluteURL
)
class
AbsoluteURL
(
BrowserView
):
class
AbsoluteURL
(
BrowserView
):
"""An absolute_url adapter for generic objects in Zope 2 that
"""An absolute_url adapter for generic objects in Zope 2 that
aren't OFS.Traversable (e.g. views, resources, etc.).
aren't OFS.Traversable (e.g. views, resources, etc.).
...
@@ -31,7 +32,6 @@ class AbsoluteURL(BrowserView):
...
@@ -31,7 +32,6 @@ class AbsoluteURL(BrowserView):
zope.traversing.browser, but the Zope 2 request doesn't support
zope.traversing.browser, but the Zope 2 request doesn't support
all the methods that it uses yet.
all the methods that it uses yet.
"""
"""
implements
(
IAbsoluteURL
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
urllib
.
unquote
(
self
.
__str__
()).
decode
(
'utf-8'
)
return
urllib
.
unquote
(
self
.
__str__
()).
decode
(
'utf-8'
)
...
@@ -87,10 +87,10 @@ class AbsoluteURL(BrowserView):
...
@@ -87,10 +87,10 @@ class AbsoluteURL(BrowserView):
return
base
return
base
@
implementer
(
IAbsoluteURL
)
class
OFSTraversableAbsoluteURL
(
BrowserView
):
class
OFSTraversableAbsoluteURL
(
BrowserView
):
"""An absolute_url adapter for OFS.Traversable subclasses
"""An absolute_url adapter for OFS.Traversable subclasses
"""
"""
implements
(
IAbsoluteURL
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
urllib
.
unquote
(
self
.
__str__
()).
decode
(
'utf-8'
)
return
urllib
.
unquote
(
self
.
__str__
()).
decode
(
'utf-8'
)
...
...
src/OFS/event.py
View file @
7214980c
...
@@ -15,15 +15,15 @@
...
@@ -15,15 +15,15 @@
OFS event definitions.
OFS event definitions.
"""
"""
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface.interfaces
import
ObjectEvent
from
zope.interface.interfaces
import
ObjectEvent
import
OFS.interfaces
import
OFS.interfaces
@
implementer
(
OFS
.
interfaces
.
IObjectWillBeMovedEvent
)
class
ObjectWillBeMovedEvent
(
ObjectEvent
):
class
ObjectWillBeMovedEvent
(
ObjectEvent
):
"""An object will be moved."""
"""An object will be moved."""
implements
(
OFS
.
interfaces
.
IObjectWillBeMovedEvent
)
def
__init__
(
self
,
object
,
oldParent
,
oldName
,
newParent
,
newName
):
def
__init__
(
self
,
object
,
oldParent
,
oldName
,
newParent
,
newName
):
ObjectEvent
.
__init__
(
self
,
object
)
ObjectEvent
.
__init__
(
self
,
object
)
...
@@ -33,27 +33,27 @@ class ObjectWillBeMovedEvent(ObjectEvent):
...
@@ -33,27 +33,27 @@ class ObjectWillBeMovedEvent(ObjectEvent):
self
.
newName
=
newName
self
.
newName
=
newName
@
implementer
(
OFS
.
interfaces
.
IObjectWillBeAddedEvent
)
class
ObjectWillBeAddedEvent
(
ObjectWillBeMovedEvent
):
class
ObjectWillBeAddedEvent
(
ObjectWillBeMovedEvent
):
"""An object will be added to a container."""
"""An object will be added to a container."""
implements
(
OFS
.
interfaces
.
IObjectWillBeAddedEvent
)
def
__init__
(
self
,
object
,
newParent
=
None
,
newName
=
None
):
def
__init__
(
self
,
object
,
newParent
=
None
,
newName
=
None
):
ObjectWillBeMovedEvent
.
__init__
(
self
,
object
,
None
,
None
,
ObjectWillBeMovedEvent
.
__init__
(
self
,
object
,
None
,
None
,
newParent
,
newName
)
newParent
,
newName
)
@
implementer
(
OFS
.
interfaces
.
IObjectWillBeRemovedEvent
)
class
ObjectWillBeRemovedEvent
(
ObjectWillBeMovedEvent
):
class
ObjectWillBeRemovedEvent
(
ObjectWillBeMovedEvent
):
"""An object will be removed from a container."""
"""An object will be removed from a container."""
implements
(
OFS
.
interfaces
.
IObjectWillBeRemovedEvent
)
def
__init__
(
self
,
object
,
oldParent
=
None
,
oldName
=
None
):
def
__init__
(
self
,
object
,
oldParent
=
None
,
oldName
=
None
):
ObjectWillBeMovedEvent
.
__init__
(
self
,
object
,
oldParent
,
oldName
,
ObjectWillBeMovedEvent
.
__init__
(
self
,
object
,
oldParent
,
oldName
,
None
,
None
)
None
,
None
)
@
implementer
(
OFS
.
interfaces
.
IObjectClonedEvent
)
class
ObjectClonedEvent
(
ObjectEvent
):
class
ObjectClonedEvent
(
ObjectEvent
):
"""An object has been cloned into a container."""
"""An object has been cloned into a container."""
implements
(
OFS
.
interfaces
.
IObjectClonedEvent
)
src/OFS/event.txt
View file @
7214980c
...
@@ -117,10 +117,10 @@ product's ``interfaces.py``::
...
@@ -117,10 +117,10 @@ product's ``interfaces.py``::
Then the class CoolDocument is marked with this interface::
Then the class CoolDocument is marked with this interface::
from zope.interface import implement
s
from zope.interface import implement
er
from Products.CoolProduct.interfaces import ICoolDocument
from Products.CoolProduct.interfaces import ICoolDocument
@implementer(ICoolDocument)
class CoolDocument(...):
class CoolDocument(...):
implements(ICoolDocument)
...
...
Finally we must link the event and the interface to the subscriber using
Finally we must link the event and the interface to the subscriber using
...
...
src/OFS/subscribers.py
View file @
7214980c
...
@@ -69,11 +69,11 @@ def maybeWarnDeprecated(ob, method_name):
...
@@ -69,11 +69,11 @@ def maybeWarnDeprecated(ob, method_name):
(
class_
.
__module__
,
class_
.
__name__
,
method_name
))
(
class_
.
__module__
,
class_
.
__name__
,
method_name
))
@
zope
.
interface
.
implementer
(
zope
.
location
.
interfaces
.
ISublocations
)
@
zope
.
component
.
adapter
(
OFS
.
interfaces
.
IObjectManager
)
class
ObjectManagerSublocations
(
object
):
class
ObjectManagerSublocations
(
object
):
"""Get the sublocations for an ObjectManager.
"""Get the sublocations for an ObjectManager.
"""
"""
zope
.
component
.
adapts
(
OFS
.
interfaces
.
IObjectManager
)
zope
.
interface
.
implements
(
zope
.
location
.
interfaces
.
ISublocations
)
def
__init__
(
self
,
container
):
def
__init__
(
self
,
container
):
self
.
container
=
container
self
.
container
=
container
...
...
src/OFS/tests/testCopySupportEvents.py
View file @
7214980c
...
@@ -38,8 +38,8 @@ class ITestItem(interface.Interface):
...
@@ -38,8 +38,8 @@ class ITestItem(interface.Interface):
pass
pass
@
interface
.
implementer
(
ITestItem
)
class
TestItem
(
SimpleItem
):
class
TestItem
(
SimpleItem
):
interface
.
implements
(
ITestItem
)
def
__init__
(
self
,
id
):
def
__init__
(
self
,
id
):
self
.
id
=
id
self
.
id
=
id
...
@@ -49,8 +49,8 @@ class ITestFolder(interface.Interface):
...
@@ -49,8 +49,8 @@ class ITestFolder(interface.Interface):
pass
pass
@
interface
.
implementer
(
ITestFolder
)
class
TestFolder
(
Folder
):
class
TestFolder
(
Folder
):
interface
.
implements
(
ITestFolder
)
def
__init__
(
self
,
id
):
def
__init__
(
self
,
id
):
self
.
id
=
id
self
.
id
=
id
...
...
src/OFS/tests/testLockable.py
View file @
7214980c
import
unittest
import
unittest
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
OFS.interfaces
import
IWriteLock
from
OFS.interfaces
import
IWriteLock
@
implementer
(
IWriteLock
)
class
LockableResource
(
object
):
class
LockableResource
(
object
):
implements
(
IWriteLock
)
def
__init__
(
self
,
locked
):
def
__init__
(
self
,
locked
):
self
.
locked
=
locked
self
.
locked
=
locked
...
...
src/OFS/tests/testObjectManager.py
View file @
7214980c
...
@@ -11,7 +11,7 @@ from App.config import getConfiguration
...
@@ -11,7 +11,7 @@ from App.config import getConfiguration
from
logging
import
getLogger
from
logging
import
getLogger
from
zExceptions
import
BadRequest
from
zExceptions
import
BadRequest
from
zope.component.testing
import
PlacelessSetup
from
zope.component.testing
import
PlacelessSetup
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
Zope2.App
import
zcml
from
Zope2.App
import
zcml
from
OFS.interfaces
import
IItem
from
OFS.interfaces
import
IItem
...
@@ -68,9 +68,9 @@ class ItemForDeletion(SimpleItem):
...
@@ -68,9 +68,9 @@ class ItemForDeletion(SimpleItem):
pass
pass
@
implementer
(
IItem
)
class
ObjectManagerWithIItem
(
ObjectManager
):
class
ObjectManagerWithIItem
(
ObjectManager
):
"""The event subscribers work on IItem."""
"""The event subscribers work on IItem."""
implements
(
IItem
)
class
ObjectManagerTests
(
PlacelessSetup
,
unittest
.
TestCase
):
class
ObjectManagerTests
(
PlacelessSetup
,
unittest
.
TestCase
):
...
...
src/OFS/tests/test_metaconfigure.py
View file @
7214980c
...
@@ -45,19 +45,20 @@ class TestRegisterClass(unittest.TestCase):
...
@@ -45,19 +45,20 @@ class TestRegisterClass(unittest.TestCase):
class
Dummy
(
object
):
class
Dummy
(
object
):
pass
pass
else
:
else
:
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
ifaces
)
class
Dummy
(
object
):
class
Dummy
(
object
):
implements
(
ifaces
)
pass
return
Dummy
return
Dummy
def
_registerPermission
(
self
,
name
,
title
=
None
):
def
_registerPermission
(
self
,
name
,
title
=
None
):
from
zope.component
import
provideUtility
from
zope.component
import
provideUtility
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.security.interfaces
import
IPermission
from
zope.security.interfaces
import
IPermission
@
implementer
(
IPermission
)
class
Perm
:
class
Perm
:
implements
(
IPermission
)
def
__init__
(
self
,
title
):
def
__init__
(
self
,
title
):
self
.
title
=
title
self
.
title
=
title
...
...
src/OFS/tests/test_registerclass.py
View file @
7214980c
...
@@ -18,7 +18,7 @@ from AccessControl.class_init import InitializeClass
...
@@ -18,7 +18,7 @@ from AccessControl.class_init import InitializeClass
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
Interface
from
zope.interface
import
Interface
...
@@ -26,8 +26,8 @@ class ISimpleContent(Interface):
...
@@ -26,8 +26,8 @@ class ISimpleContent(Interface):
pass
pass
@
implementer
(
ISimpleContent
)
class
SimpleContent
(
SimpleItem
):
class
SimpleContent
(
SimpleItem
):
implements
(
ISimpleContent
)
meta_type
=
'SimpleContent'
meta_type
=
'SimpleContent'
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
...
src/Products/Five/browser/adding.py
View file @
7214980c
...
@@ -37,7 +37,7 @@ from zope.container.interfaces import IContainerNamesContainer
...
@@ -37,7 +37,7 @@ from zope.container.interfaces import IContainerNamesContainer
from
zope.container.interfaces
import
INameChooser
from
zope.container.interfaces
import
INameChooser
from
zope.event
import
notify
from
zope.event
import
notify
from
zope.exceptions.interfaces
import
UserError
from
zope.exceptions.interfaces
import
UserError
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.lifecycleevent
import
ObjectCreatedEvent
from
zope.lifecycleevent
import
ObjectCreatedEvent
from
zope.publisher.interfaces
import
IPublishTraverse
from
zope.publisher.interfaces
import
IPublishTraverse
from
zope.traversing.browser.absoluteurl
import
absoluteURL
from
zope.traversing.browser.absoluteurl
import
absoluteURL
...
@@ -47,8 +47,8 @@ from Products.Five import BrowserView
...
@@ -47,8 +47,8 @@ from Products.Five import BrowserView
from
Products.Five.browser.pagetemplatefile
import
ViewPageTemplateFile
from
Products.Five.browser.pagetemplatefile
import
ViewPageTemplateFile
@
implementer
(
IAdding
,
IPublishTraverse
)
class
Adding
(
BrowserView
):
class
Adding
(
BrowserView
):
implements
(
IAdding
,
IPublishTraverse
)
def
add
(
self
,
content
):
def
add
(
self
,
content
):
"""See zope.browser.interfaces.IAdding
"""See zope.browser.interfaces.IAdding
...
@@ -199,12 +199,11 @@ class ContentAdding(Adding, SimpleItem):
...
@@ -199,12 +199,11 @@ class ContentAdding(Adding, SimpleItem):
menu_id
=
"add_content"
menu_id
=
"add_content"
@
implementer
(
INameChooser
)
class
ObjectManagerNameChooser
:
class
ObjectManagerNameChooser
:
"""A name chooser for a Zope object manager.
"""A name chooser for a Zope object manager.
"""
"""
implements
(
INameChooser
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
...
src/Products/Five/browser/resource.py
View file @
7214980c
...
@@ -20,7 +20,7 @@ import urllib
...
@@ -20,7 +20,7 @@ import urllib
import
zope.browserresource.directory
import
zope.browserresource.directory
import
zope.browserresource.file
import
zope.browserresource.file
from
zope.browserresource.file
import
File
from
zope.browserresource.file
import
File
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.traversing.browser
import
absoluteURL
from
zope.traversing.browser
import
absoluteURL
from
zope.publisher.interfaces
import
NotFound
from
zope.publisher.interfaces
import
NotFound
from
zope.publisher.interfaces.browser
import
IBrowserPublisher
from
zope.publisher.interfaces.browser
import
IBrowserPublisher
...
@@ -54,8 +54,8 @@ class Resource(object):
...
@@ -54,8 +54,8 @@ class Resource(object):
return
"%s/%s"
%
(
url
,
name
)
return
"%s/%s"
%
(
url
,
name
)
@
implementer
(
IBrowserPublisher
)
class
PageTemplateResource
(
Resource
,
BrowserView
):
class
PageTemplateResource
(
Resource
,
BrowserView
):
implements
(
IBrowserPublisher
)
def
browserDefault
(
self
,
request
):
def
browserDefault
(
self
,
request
):
return
self
.
render
,
()
return
self
.
render
,
()
...
...
src/Products/Five/browser/tests/classes.py
View file @
7214980c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
"""Test fixtures
"""Test fixtures
"""
"""
from
zope.interface
import
Interface
,
implement
s
from
zope.interface
import
Interface
,
implement
er
from
Products.Five
import
BrowserView
from
Products.Five
import
BrowserView
...
@@ -23,9 +23,9 @@ class IOne(Interface):
...
@@ -23,9 +23,9 @@ class IOne(Interface):
"""
"""
@
implementer
(
IOne
)
class
One
(
object
):
class
One
(
object
):
'A class'
'A class'
implements
(
IOne
)
class
ViewOne
(
BrowserView
):
class
ViewOne
(
BrowserView
):
...
...
src/Products/Five/browser/tests/provider.txt
View file @
7214980c
...
@@ -28,11 +28,13 @@ So let's create a simple content provider:
...
@@ -28,11 +28,13 @@ So let's create a simple content provider:
>>> import zope.component
>>> import zope.component
>>> from zope.publisher.interfaces import browser
>>> from zope.publisher.interfaces import browser
>>> class MessageBox(object):
>>> @zope.interface.implementer(interfaces.IContentProvider)
... zope.interface.implements(interfaces.IContentProvider)
... @zope.component.adapter(
... zope.component.adapts(zope.interface.Interface,
... zope.interface.Interface,
... browser.IDefaultBrowserLayer,
... browser.IDefaultBrowserLayer,
... zope.interface.Interface)
... zope.interface.Interface
... )
... class MessageBox(object):
... message = u'My Message'
... message = u'My Message'
...
...
... def __init__(self, context, request, view):
... def __init__(self, context, request, view):
...
@@ -121,8 +123,9 @@ provider implement an interface that specifies the attributes and provides
...
@@ -121,8 +123,9 @@ provider implement an interface that specifies the attributes and provides
Now the message box can receive its text from the TAL environment:
Now the message box can receive its text from the TAL environment:
>>> class DynamicMessageBox(MessageBox):
>>> @zope.interface.implementer(IMessageText)
... zope.interface.implements(IMessageText)
... class DynamicMessageBox(MessageBox):
... pass
>>> zope.component.provideAdapter(
>>> zope.component.provideAdapter(
... DynamicMessageBox, provides=interfaces.IContentProvider,
... DynamicMessageBox, provides=interfaces.IContentProvider,
...
@@ -159,8 +162,8 @@ Finally, a content provider can also implement several ``ITALNamespaceData``:
...
@@ -159,8 +162,8 @@ Finally, a content provider can also implement several ``ITALNamespaceData``:
We'll change our message box content provider implementation a bit, so the new
We'll change our message box content provider implementation a bit, so the new
information is used:
information is used:
>>>
class BetterDynamicMessageBox(DynamicMessageBox):
>>>
@zope.interface.implementer(IMessageType)
...
zope.interface.implements(IMessageType)
...
class BetterDynamicMessageBox(DynamicMessageBox):
... type = None
... type = None
...
...
... def render(self):
... def render(self):
...
@@ -196,10 +199,11 @@ Now we test a provider using a PageTemplateFile to render itself:
...
@@ -196,10 +199,11 @@ Now we test a provider using a PageTemplateFile to render itself:
>>> open(dynTemplate, 'w').write(
>>> open(dynTemplate, 'w').write(
... 'A simple template: <tal:simple replace="python:view.my_property" />')
... 'A simple template: <tal:simple replace="python:view.my_property" />')
>>> from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
>>> from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
>>> class TemplateProvider(object):
>>> @zope.component.adapter(
... zope.component.adapts(zope.interface.Interface,
... zope.interface.Interface,
... browser.IDefaultBrowserLayer,
... browser.IDefaultBrowserLayer,
... zope.interface.Interface)
... zope.interface.Interface)
... class TemplateProvider(object):
...
...
... def __init__(self, context, request, view):
... def __init__(self, context, request, view):
... self.__parent__ = view
... self.__parent__ = view
...
...
src/Products/Five/browser/tests/test_pages.py
View file @
7214980c
...
@@ -27,10 +27,11 @@ def test_view_with_unwrapped_context():
...
@@ -27,10 +27,11 @@ def test_view_with_unwrapped_context():
>>> zcml.load_config('pages.zcml', package=Products.Five.browser.tests)
>>> zcml.load_config('pages.zcml', package=Products.Five.browser.tests)
>>> from Products.Five.tests.testing import simplecontent as sc
>>> from Products.Five.tests.testing import simplecontent as sc
>>> from zope.interface import Interface
>>> from zope.interface import Interface
>>> from zope.interface import implement
s
>>> from zope.interface import implement
er
>>> from zope.component import queryMultiAdapter
>>> from zope.component import queryMultiAdapter
>>> class Unwrapped:
>>> @implementer(sc.ISimpleContent)
... implements(sc.ISimpleContent)
... class Unwrapped:
... pass
>>> unwrapped = Unwrapped()
>>> unwrapped = Unwrapped()
Simple views should work fine without having their contexts wrapped:
Simple views should work fine without having their contexts wrapped:
...
...
src/Products/Five/browser/tests/test_recurse.py
View file @
7214980c
...
@@ -22,7 +22,7 @@ def test_recursion():
...
@@ -22,7 +22,7 @@ def test_recursion():
This test makes sure that recursion is avoided for view lookup.
This test makes sure that recursion is avoided for view lookup.
First, we need to set up a stub interface...
First, we need to set up a stub interface...
>>> from zope.interface import Interface, implement
s
>>> from zope.interface import Interface, implement
er
>>> class IRecurse(Interface):
>>> class IRecurse(Interface):
... pass
... pass
...
...
...
@@ -30,8 +30,8 @@ def test_recursion():
...
@@ -30,8 +30,8 @@ def test_recursion():
and a class that is callable and has a view method:
and a class that is callable and has a view method:
>>> from OFS.Traversable import Traversable
>>> from OFS.Traversable import Traversable
>>>
class Recurse(Traversable):
>>>
@implementer(IRecurse)
...
implements(IRecurse)
...
class Recurse(Traversable):
... def view(self):
... def view(self):
... return self()
... return self()
... def __call__(self):
... def __call__(self):
...
...
src/Products/Five/doc/manual.txt
View file @
7214980c
...
@@ -44,9 +44,8 @@ a class, but contains no implementation::
...
@@ -44,9 +44,8 @@ a class, but contains no implementation::
A concrete class somewhere can now claim that it implements the
A concrete class somewhere can now claim that it implements the
interface (i.e. its instance will provide the interface)::
interface (i.e. its instance will provide the interface)::
@implementer(IElephant)
class PinkElephant:
class PinkElephant:
# this says all instances of this class provide IElephant
implements(IElephant)
def getAngerLevel(self):
def getAngerLevel(self):
return 0 # this elephant is peaceful
return 0 # this elephant is peaceful
...
@@ -100,13 +99,13 @@ to subclass it from ``zope.interface.Interface``. Here is an example::
...
@@ -100,13 +99,13 @@ to subclass it from ``zope.interface.Interface``. Here is an example::
"""
"""
Now to make some class declare that it implements this interface, you
Now to make some class declare that it implements this interface, you
need to use the ``implement
s()`` function i
n the class::
need to use the ``implement
er()`` decorator o
n the class::
from zope.interface import implement
s
from zope.interface import implement
er
from interfaces import IMyInterface
from interfaces import IMyInterface
class MyClass:
@implementer(IMyInterface)
implements(IMyInterface)
class MyClass(object):
def someMethod(self):
def someMethod(self):
return "I am alive! Alive!"
return "I am alive! Alive!"
...
@@ -126,11 +125,11 @@ requirement to make a class that is an adapter is very simple; you
...
@@ -126,11 +125,11 @@ requirement to make a class that is an adapter is very simple; you
only need to take a context object as the constructor. The context
only need to take a context object as the constructor. The context
object is the object being adapted. An example::
object is the object being adapted. An example::
from zope.interface import implement
s
from zope.interface import implement
er
from interfaces import INewInterface
from interfaces import INewInterface
@implementer(INewInterface)
class MyAdapter:
class MyAdapter:
implements(INewInterface)
def __init__(self, context):
def __init__(self, context):
self.context = context
self.context = context
...
@@ -162,7 +161,7 @@ can now be adapted to ``INewInterface``, like this::
...
@@ -162,7 +161,7 @@ can now be adapted to ``INewInterface``, like this::
object = MyClass()
object = MyClass()
adapted = INewInterface(object)
adapted = INewInterface(object)
print
adapted.anotherMethod(
)
print
(adapted.anotherMethod()
)
Views
Views
-----
-----
...
@@ -177,11 +176,12 @@ Zope objects, as long as two things are the case:
...
@@ -177,11 +176,12 @@ Zope objects, as long as two things are the case:
* The object (typically its class) is made traversable. This allows Zope
* The object (typically its class) is made traversable. This allows Zope
views, resources and other things to be attached to a Zope object.
views, resources and other things to be attached to a Zope object.
Typically you give your classes an interface using the ``implement
s
``
Typically you give your classes an interface using the ``implement
er
``
d
irective in the class body
::
d
ecorator on the class
::
class MyClass:
@implementer(ISomeInterface)
implements(ISomeInterface)
class MyClass(object):
pass
For existing objects that you cannot modify this is not
For existing objects that you cannot modify this is not
possible. Instead, we provide a ZCML directive to accomplish this. As
possible. Instead, we provide a ZCML directive to accomplish this. As
...
...
src/Products/Five/skin/standardmacros.py
View file @
7214980c
...
@@ -19,8 +19,8 @@ import zope.component
...
@@ -19,8 +19,8 @@ import zope.component
from
Products.Five.browser
import
BrowserView
from
Products.Five.browser
import
BrowserView
@
zope
.
interface
.
implementer
(
zope
.
interface
.
common
.
mapping
.
IItemMapping
)
class
Macros
(
object
):
class
Macros
(
object
):
zope
.
interface
.
implements
(
zope
.
interface
.
common
.
mapping
.
IItemMapping
)
macro_pages
=
()
macro_pages
=
()
aliases
=
{
aliases
=
{
...
...
src/Products/Five/tests/adapters.py
View file @
7214980c
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
"""Adapter test fixtures
"""Adapter test fixtures
"""
"""
from
zope.
interface
import
implements
,
Interface
from
zope.
component
import
adapter
from
zope.
component
import
adapts
from
zope.
interface
import
implementer
,
Interface
class
IAdaptable
(
Interface
):
class
IAdaptable
(
Interface
):
...
@@ -46,16 +46,16 @@ class IDestination(Interface):
...
@@ -46,16 +46,16 @@ class IDestination(Interface):
"""Do something"""
"""Do something"""
@
implementer
(
IAdaptable
)
class
Adaptable
(
object
):
class
Adaptable
(
object
):
implements
(
IAdaptable
)
def
method
(
self
):
def
method
(
self
):
return
"The method"
return
"The method"
@
implementer
(
IAdapted
)
@
adapter
(
IAdaptable
)
class
Adapter
(
object
):
class
Adapter
(
object
):
implements
(
IAdapted
)
adapts
(
IAdaptable
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
@@ -64,12 +64,13 @@ class Adapter(object):
...
@@ -64,12 +64,13 @@ class Adapter(object):
return
"Adapted: %s"
%
self
.
context
.
method
()
return
"Adapted: %s"
%
self
.
context
.
method
()
@
implementer
(
IOrigin
)
class
Origin
(
object
):
class
Origin
(
object
):
implements
(
IOrigin
)
pass
@
implementer
(
IDestination
)
class
OriginalAdapter
(
object
):
class
OriginalAdapter
(
object
):
implements
(
IDestination
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
@@ -78,8 +79,8 @@ class OriginalAdapter(object):
...
@@ -78,8 +79,8 @@ class OriginalAdapter(object):
return
"Original"
return
"Original"
@
implementer
(
IDestination
)
class
OverrideAdapter
(
object
):
class
OverrideAdapter
(
object
):
implements
(
IDestination
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
...
src/Products/Five/tests/test_size.py
View file @
7214980c
...
@@ -14,13 +14,13 @@
...
@@ -14,13 +14,13 @@
"""Size adapters for testing
"""Size adapters for testing
"""
"""
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.size.interfaces
import
ISized
from
zope.size.interfaces
import
ISized
@
implementer
(
ISized
)
class
SimpleContentSize
(
object
):
class
SimpleContentSize
(
object
):
"""Size for ``SimpleContent`` objects."""
"""Size for ``SimpleContent`` objects."""
implements
(
ISized
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
@@ -32,9 +32,9 @@ class SimpleContentSize(object):
...
@@ -32,9 +32,9 @@ class SimpleContentSize(object):
return
"What is the meaning of life?"
return
"What is the meaning of life?"
@
implementer
(
ISized
)
class
FancyContentSize
(
object
):
class
FancyContentSize
(
object
):
"""Size for ``SimpleContent`` objects."""
"""Size for ``SimpleContent`` objects."""
implements
(
ISized
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
...
src/Products/Five/tests/testing/fancycontent.py
View file @
7214980c
...
@@ -19,7 +19,7 @@ from AccessControl.SecurityInfo import ClassSecurityInfo
...
@@ -19,7 +19,7 @@ from AccessControl.SecurityInfo import ClassSecurityInfo
from
Acquisition
import
Explicit
from
Acquisition
import
Explicit
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
Interface
from
zope.interface
import
Interface
...
@@ -43,13 +43,13 @@ class FancyAttribute(Explicit):
...
@@ -43,13 +43,13 @@ class FancyAttribute(Explicit):
InitializeClass
(
FancyAttribute
)
InitializeClass
(
FancyAttribute
)
@
implementer
(
IFancyContent
)
class
FancyContent
(
SimpleItem
):
class
FancyContent
(
SimpleItem
):
"""A class that already comes with its own __bobo_traverse__ handler.
"""A class that already comes with its own __bobo_traverse__ handler.
Quite fancy indeed.
Quite fancy indeed.
It also comes with its own get_size method.
It also comes with its own get_size method.
"""
"""
implements
(
IFancyContent
)
meta_type
=
"Fancy Content"
meta_type
=
"Fancy Content"
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
@@ -69,14 +69,13 @@ class FancyContent(SimpleItem):
...
@@ -69,14 +69,13 @@ class FancyContent(SimpleItem):
InitializeClass
(
FancyContent
)
InitializeClass
(
FancyContent
)
@
implementer
(
IFancyContent
)
class
NonTraversableFancyContent
(
SimpleItem
):
class
NonTraversableFancyContent
(
SimpleItem
):
"""A class that already comes with its own __bobo_traverse__ handler.
"""A class that already comes with its own __bobo_traverse__ handler.
Quite fancy indeed.
Quite fancy indeed.
It also comes with its own get_size method.
It also comes with its own get_size method.
"""
"""
# A copy of the above class used to demonstrate some baseline behavior.
implements
(
IFancyContent
)
meta_type
=
"Fancy Content"
meta_type
=
"Fancy Content"
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
...
src/Products/Five/tests/testing/folder.py
View file @
7214980c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
from
OFS.Folder
import
Folder
from
OFS.Folder
import
Folder
from
OFS.interfaces
import
IFolder
from
OFS.interfaces
import
IFolder
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
class
NoVerifyPasteFolder
(
Folder
):
class
NoVerifyPasteFolder
(
Folder
):
...
@@ -34,10 +34,10 @@ def manage_addNoVerifyPasteFolder(container, id, title=''):
...
@@ -34,10 +34,10 @@ def manage_addNoVerifyPasteFolder(container, id, title=''):
folder
.
title
=
title
folder
.
title
=
title
@
implementer
(
IFolder
)
class
FiveTraversableFolder
(
Folder
):
class
FiveTraversableFolder
(
Folder
):
"""Folder that is five-traversable
"""Folder that is five-traversable
"""
"""
implements
(
IFolder
)
def
manage_addFiveTraversableFolder
(
container
,
id
,
title
=
''
):
def
manage_addFiveTraversableFolder
(
container
,
id
,
title
=
''
):
...
...
src/Products/Five/tests/testing/simplecontent.py
View file @
7214980c
...
@@ -18,7 +18,7 @@ from AccessControl.class_init import InitializeClass
...
@@ -18,7 +18,7 @@ from AccessControl.class_init import InitializeClass
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
AccessControl.SecurityInfo
import
ClassSecurityInfo
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
Interface
from
zope.interface
import
Interface
...
@@ -34,8 +34,8 @@ class IIndexSimpleContent(ISimpleContent):
...
@@ -34,8 +34,8 @@ class IIndexSimpleContent(ISimpleContent):
pass
pass
@
implementer
(
ISimpleContent
)
class
SimpleContent
(
SimpleItem
):
class
SimpleContent
(
SimpleItem
):
implements
(
ISimpleContent
)
meta_type
=
'Five SimpleContent'
meta_type
=
'Five SimpleContent'
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
@@ -57,9 +57,9 @@ class SimpleContent(SimpleItem):
...
@@ -57,9 +57,9 @@ class SimpleContent(SimpleItem):
InitializeClass
(
SimpleContent
)
InitializeClass
(
SimpleContent
)
@
implementer
(
ICallableSimpleContent
)
class
CallableSimpleContent
(
SimpleItem
):
class
CallableSimpleContent
(
SimpleItem
):
"""A Viewable piece of content"""
"""A Viewable piece of content"""
implements
(
ICallableSimpleContent
)
meta_type
=
"Five CallableSimpleContent"
meta_type
=
"Five CallableSimpleContent"
...
@@ -70,9 +70,9 @@ class CallableSimpleContent(SimpleItem):
...
@@ -70,9 +70,9 @@ class CallableSimpleContent(SimpleItem):
InitializeClass
(
CallableSimpleContent
)
InitializeClass
(
CallableSimpleContent
)
@
implementer
(
IIndexSimpleContent
)
class
IndexSimpleContent
(
SimpleItem
):
class
IndexSimpleContent
(
SimpleItem
):
"""A Viewable piece of content"""
"""A Viewable piece of content"""
implements
(
IIndexSimpleContent
)
meta_type
=
'Five IndexSimpleContent'
meta_type
=
'Five IndexSimpleContent'
...
...
src/Products/Five/utilities/marker.py
View file @
7214980c
...
@@ -18,7 +18,7 @@ Allows for arbitrary application of marker interfaces to objects.
...
@@ -18,7 +18,7 @@ Allows for arbitrary application of marker interfaces to objects.
from
sets
import
Set
from
sets
import
Set
from
zope.interface
import
implement
s
,
implementedBy
,
providedBy
from
zope.interface
import
implement
er
,
implementedBy
,
providedBy
from
zope.interface
import
directlyProvides
,
directlyProvidedBy
from
zope.interface
import
directlyProvides
,
directlyProvidedBy
from
zope.interface.interfaces
import
IInterface
from
zope.interface.interfaces
import
IInterface
from
zope.component.interface
import
getInterface
,
interfaceToName
from
zope.component.interface
import
getInterface
,
interfaceToName
...
@@ -46,10 +46,9 @@ mark = interfaceStringCheck(mark)
...
@@ -46,10 +46,9 @@ mark = interfaceStringCheck(mark)
erase
=
interfaceStringCheck
(
erase
)
erase
=
interfaceStringCheck
(
erase
)
@
implementer
(
IMarkerInterfaces
)
class
MarkerInterfacesAdapter
(
object
):
class
MarkerInterfacesAdapter
(
object
):
implements
(
IMarkerInterfaces
)
mark
=
staticmethod
(
mark
)
mark
=
staticmethod
(
mark
)
erase
=
staticmethod
(
erase
)
erase
=
staticmethod
(
erase
)
...
...
src/Products/Five/viewlet/README.txt
View file @
7214980c
...
@@ -64,8 +64,9 @@ Now we have to instantiate it in the context of an actual zope object:
...
@@ -64,8 +64,9 @@ Now we have to instantiate it in the context of an actual zope object:
>>> import zope.interface
>>> import zope.interface
>>> from OFS import SimpleItem, Folder
>>> from OFS import SimpleItem, Folder
>>> class Content(SimpleItem.SimpleItem):
>>> @zope.interface.implementer(zope.interface.Interface)
... zope.interface.implements(zope.interface.Interface)
... class Content(SimpleItem.SimpleItem):
... pass
>>> obj_id = self.folder._setObject('content1', Content())
>>> obj_id = self.folder._setObject('content1', Content())
>>> content = self.folder[obj_id]
>>> content = self.folder[obj_id]
...
@@ -89,8 +90,8 @@ But now we register some viewlets for the manager
...
@@ -89,8 +90,8 @@ But now we register some viewlets for the manager
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
>>> from zope.browser.interfaces import IBrowserView
>>> from zope.browser.interfaces import IBrowserView
>>>
class WeatherBox(object):
>>>
@zope.interface.implementer(interfaces.IViewlet)
...
zope.interface.implements(interfaces.IViewlet)
...
class WeatherBox(object):
...
...
... def __init__(self, context, request, view, manager):
... def __init__(self, context, request, view, manager):
... self.__parent__ = view
... self.__parent__ = view
...
@@ -108,8 +109,8 @@ But now we register some viewlets for the manager
...
@@ -108,8 +109,8 @@ But now we register some viewlets for the manager
... IBrowserView, ILeftColumn),
... IBrowserView, ILeftColumn),
... interfaces.IViewlet, name='weather')
... interfaces.IViewlet, name='weather')
>>>
class SportBox(object):
>>>
@zope.interface.implementer(interfaces.IViewlet)
...
zope.interface.implements(interfaces.IViewlet)
...
class SportBox(object):
...
...
... def __init__(self, context, request, view, manager):
... def __init__(self, context, request, view, manager):
... self.__parent__ = view
... self.__parent__ = view
...
@@ -426,8 +427,8 @@ generic contents view for files. The step is to create a file component:
...
@@ -426,8 +427,8 @@ generic contents view for files. The step is to create a file component:
>>> class IFile(zope.interface.Interface):
>>> class IFile(zope.interface.Interface):
... data = zope.interface.Attribute('Data of file.')
... data = zope.interface.Attribute('Data of file.')
>>>
class File(SimpleItem.SimpleItem):
>>>
@zope.interface.implementer(IFile)
...
zope.interface.implements(IFile)
...
class File(SimpleItem.SimpleItem):
... def __init__(self, data=''):
... def __init__(self, data=''):
... self.__name__ = ''
... self.__name__ = ''
... self.data = data
... self.data = data
...
@@ -436,9 +437,9 @@ Since we want to also provide the size of a file, here a simple implementation
...
@@ -436,9 +437,9 @@ Since we want to also provide the size of a file, here a simple implementation
of the ``ISized`` interface:
of the ``ISized`` interface:
>>> from zope import size
>>> from zope import size
>>>
class FileSized(object):
>>>
@zope.interface.implementer(size.interfaces.ISized)
...
zope.interface.implements(size.interfaces.ISized
)
...
@zope.component.adapter(IFile
)
...
zope.component.adapts(IFile)
...
class FileSized(object):
...
...
... def __init__(self, file):
... def __init__(self, file):
... self.file = file
... self.file = file
...
@@ -497,8 +498,8 @@ different item:
...
@@ -497,8 +498,8 @@ different item:
>>> shownColumns = []
>>> shownColumns = []
>>>
class ContentsViewletManager(object):
>>>
@zope.interface.implementer(interfaces.IViewletManager)
...
zope.interface.implements(interfaces.IViewletManager)
...
class ContentsViewletManager(object):
... index = None
... index = None
...
...
... def __init__(self, context, request, view):
... def __init__(self, context, request, view):
...
@@ -761,16 +762,16 @@ sorting using a simple utility:
...
@@ -761,16 +762,16 @@ sorting using a simple utility:
... def sort(values):
... def sort(values):
... """Sort the values."""
... """Sort the values."""
>>>
class SortByName(object):
>>>
@zope.interface.implementer(ISorter)
...
zope.interface.implements(ISorter)
...
class SortByName(object):
...
...
... def sort(self, values):
... def sort(self, values):
... return sorted(values, key=attrgetter('__name__'))
... return sorted(values, key=attrgetter('__name__'))
>>> zope.component.provideUtility(SortByName(), name='name')
>>> zope.component.provideUtility(SortByName(), name='name')
>>>
class SortBySize(object):
>>>
@zope.interface.implementer(ISorter)
...
zope.interface.implements(ISorter)
...
class SortBySize(object):
...
...
... def sort(self, values):
... def sort(self, values):
... def _key(value):
... def _key(value):
...
@@ -785,8 +786,8 @@ viewlet manager much simpler:
...
@@ -785,8 +786,8 @@ viewlet manager much simpler:
>>> sortByColumn = ''
>>> sortByColumn = ''
>>>
class SortedContentsViewletManager(manager.ViewletManagerBase):
>>>
@zope.interface.implementer(interfaces.IViewletManager)
...
zope.interface.implements(interfaces.IViewletManager)
...
class SortedContentsViewletManager(manager.ViewletManagerBase):
... index = None
... index = None
...
...
... def __init__(self, context, request, view):
... def __init__(self, context, request, view):
...
...
src/Products/Five/viewlet/tests.py
View file @
7214980c
...
@@ -17,13 +17,14 @@
...
@@ -17,13 +17,14 @@
import
unittest
import
unittest
from
Testing.ZopeTestCase
import
FunctionalDocFileSuite
from
Testing.ZopeTestCase
import
FunctionalDocFileSuite
from
zope.interface
import
Interface
from
zope.interface
import
Interface
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.viewlet
import
interfaces
from
zope.viewlet
import
interfaces
from
OFS.SimpleItem
import
SimpleItem
from
OFS.SimpleItem
import
SimpleItem
@
implementer
(
Interface
)
class
Content
(
SimpleItem
):
class
Content
(
SimpleItem
):
implements
(
Interface
)
pass
class
UnitTestSecurityPolicy
:
class
UnitTestSecurityPolicy
:
...
...
src/Products/PageTemplates/Expressions.py
View file @
7214980c
...
@@ -21,7 +21,7 @@ import sys
...
@@ -21,7 +21,7 @@ import sys
from
zope.component
import
queryUtility
from
zope.component
import
queryUtility
from
zope.i18n
import
translate
from
zope.i18n
import
translate
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.pagetemplate.engine
import
ZopeEngine
as
Z3Engine
from
zope.pagetemplate.engine
import
ZopeEngine
as
Z3Engine
from
zope.proxy
import
removeAllProxies
from
zope.proxy
import
removeAllProxies
from
zope.tales.expressions
import
DeferExpr
from
zope.tales.expressions
import
DeferExpr
...
@@ -353,12 +353,10 @@ class ZopeIterator(Iterator):
...
@@ -353,12 +353,10 @@ class ZopeIterator(Iterator):
return
super
(
ZopeIterator
,
self
).
next
()
return
super
(
ZopeIterator
,
self
).
next
()
@
implementer
(
ITraversable
)
class
PathIterator
(
ZopeIterator
):
class
PathIterator
(
ZopeIterator
):
"""A TALES Iterator with the ability to use first() and last() on
"""A TALES Iterator with the ability to use first() and last() on
subpaths of elements."""
subpaths of elements."""
# we want to control our own traversal so that we can deal with
# 'first' and 'last' when they appear in path expressions
implements
(
ITraversable
)
def
traverse
(
self
,
name
,
furtherPath
):
def
traverse
(
self
,
name
,
furtherPath
):
if
name
in
(
'first'
,
'last'
):
if
name
in
(
'first'
,
'last'
):
...
...
src/Products/PageTemplates/engine.py
View file @
7214980c
import
re
import
re
import
logging
import
logging
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
classProvides
from
zope.interface
import
provider
from
zope.pagetemplate.interfaces
import
IPageTemplateEngine
from
zope.pagetemplate.interfaces
import
IPageTemplateEngine
from
zope.pagetemplate.interfaces
import
IPageTemplateProgram
from
zope.pagetemplate.interfaces
import
IPageTemplateProgram
...
@@ -37,9 +37,9 @@ re_match_pi = re.compile(r'<\?python([^\w].*?)\?>', re.DOTALL)
...
@@ -37,9 +37,9 @@ re_match_pi = re.compile(r'<\?python([^\w].*?)\?>', re.DOTALL)
logger
=
logging
.
getLogger
(
'Products.PageTemplates'
)
logger
=
logging
.
getLogger
(
'Products.PageTemplates'
)
@
implementer
(
IPageTemplateProgram
)
@
provider
(
IPageTemplateEngine
)
class
Program
(
object
):
class
Program
(
object
):
implements
(
IPageTemplateProgram
)
classProvides
(
IPageTemplateEngine
)
# Zope 2 Page Template expressions
# Zope 2 Page Template expressions
secure_expression_types
=
{
secure_expression_types
=
{
...
...
src/Products/PageTemplates/unicodeconflictresolver.py
View file @
7214980c
...
@@ -17,7 +17,7 @@ import sys
...
@@ -17,7 +17,7 @@ import sys
from
Acquisition
import
aq_get
from
Acquisition
import
aq_get
from
Products.PageTemplates.interfaces
import
IUnicodeEncodingConflictResolver
from
Products.PageTemplates.interfaces
import
IUnicodeEncodingConflictResolver
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.i18n.interfaces
import
IUserPreferredCharsets
from
zope.i18n.interfaces
import
IUserPreferredCharsets
if
sys
.
version_info
>=
(
3
,
):
if
sys
.
version_info
>=
(
3
,
):
...
@@ -26,14 +26,13 @@ if sys.version_info >= (3, ):
...
@@ -26,14 +26,13 @@ if sys.version_info >= (3, ):
default_encoding
=
sys
.
getdefaultencoding
()
default_encoding
=
sys
.
getdefaultencoding
()
@
implementer
(
IUnicodeEncodingConflictResolver
)
class
DefaultUnicodeEncodingConflictResolver
(
object
):
class
DefaultUnicodeEncodingConflictResolver
(
object
):
""" This resolver implements the old-style behavior and will
""" This resolver implements the old-style behavior and will
raise an exception in case of the string 'text' can't be converted
raise an exception in case of the string 'text' can't be converted
properly to unicode.
properly to unicode.
"""
"""
implements
(
IUnicodeEncodingConflictResolver
)
def
resolve
(
self
,
context
,
text
,
expression
):
def
resolve
(
self
,
context
,
text
,
expression
):
return
unicode
(
text
)
return
unicode
(
text
)
...
@@ -41,14 +40,13 @@ DefaultUnicodeEncodingConflictResolver = \
...
@@ -41,14 +40,13 @@ DefaultUnicodeEncodingConflictResolver = \
DefaultUnicodeEncodingConflictResolver
()
DefaultUnicodeEncodingConflictResolver
()
@
implementer
(
IUnicodeEncodingConflictResolver
)
class
Z2UnicodeEncodingConflictResolver
(
object
):
class
Z2UnicodeEncodingConflictResolver
(
object
):
""" This resolver tries to lookup the encoding from the
""" This resolver tries to lookup the encoding from the
'management_page_charset' property and defaults to
'management_page_charset' property and defaults to
sys.getdefaultencoding().
sys.getdefaultencoding().
"""
"""
implements
(
IUnicodeEncodingConflictResolver
)
def
__init__
(
self
,
mode
=
'strict'
):
def
__init__
(
self
,
mode
=
'strict'
):
self
.
mode
=
mode
self
.
mode
=
mode
...
@@ -66,13 +64,12 @@ class Z2UnicodeEncodingConflictResolver(object):
...
@@ -66,13 +64,12 @@ class Z2UnicodeEncodingConflictResolver(object):
return
unicode
(
text
,
'iso-8859-15'
,
self
.
mode
)
return
unicode
(
text
,
'iso-8859-15'
,
self
.
mode
)
@
implementer
(
IUnicodeEncodingConflictResolver
)
class
PreferredCharsetResolver
(
object
):
class
PreferredCharsetResolver
(
object
):
""" A resolver that tries use the encoding information
""" A resolver that tries use the encoding information
from the HTTP_ACCEPT_CHARSET header.
from the HTTP_ACCEPT_CHARSET header.
"""
"""
implements
(
IUnicodeEncodingConflictResolver
)
def
resolve
(
self
,
context
,
text
,
expression
):
def
resolve
(
self
,
context
,
text
,
expression
):
request
=
aq_get
(
context
,
'REQUEST'
,
None
)
request
=
aq_get
(
context
,
'REQUEST'
,
None
)
...
...
src/Testing/ZopeTestCase/PortalTestCase.py
View file @
7214980c
...
@@ -29,7 +29,7 @@ import base
...
@@ -29,7 +29,7 @@ import base
import
interfaces
import
interfaces
import
utils
import
utils
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
AccessControl
import
getSecurityManager
from
AccessControl
import
getSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
...
@@ -41,12 +41,11 @@ from ZopeTestCase import user_password
...
@@ -41,12 +41,11 @@ from ZopeTestCase import user_password
portal_name
=
'portal'
portal_name
=
'portal'
@
implementer
(
interfaces
.
IPortalTestCase
,
interfaces
.
IPortalSecurity
)
class
PortalTestCase
(
base
.
TestCase
):
class
PortalTestCase
(
base
.
TestCase
):
'''Base test case for testing CMF-style portals'''
'''Base test case for testing CMF-style portals'''
implements
(
interfaces
.
IPortalTestCase
,
interfaces
.
IPortalSecurity
)
_configure_portal
=
1
_configure_portal
=
1
def
setUp
(
self
):
def
setUp
(
self
):
...
...
src/Testing/ZopeTestCase/ZopeTestCase.py
View file @
7214980c
...
@@ -22,7 +22,7 @@ The default user is logged in and has the 'Access contents information'
...
@@ -22,7 +22,7 @@ The default user is logged in and has the 'Access contents information'
and 'View' permissions given to his role.
and 'View' permissions given to his role.
"""
"""
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
AccessControl
import
getSecurityManager
from
AccessControl
import
getSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
...
@@ -44,11 +44,10 @@ user_role = 'test_role_1_'
...
@@ -44,11 +44,10 @@ user_role = 'test_role_1_'
standard_permissions
=
[
access_contents_information
,
view
]
standard_permissions
=
[
access_contents_information
,
view
]
@
implementer
(
interfaces
.
IZopeSecurity
)
class
ZopeTestCase
(
base
.
TestCase
):
class
ZopeTestCase
(
base
.
TestCase
):
'''Base test case for Zope testing'''
'''Base test case for Zope testing'''
implements
(
interfaces
.
IZopeSecurity
)
_setup_fixture
=
1
_setup_fixture
=
1
def
_setup
(
self
):
def
_setup
(
self
):
...
...
src/Testing/ZopeTestCase/base.py
View file @
7214980c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
import
unittest
import
unittest
import
transaction
import
transaction
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
AccessControl.SecurityManagement
import
noSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
Testing.makerequest
import
makerequest
from
Testing.makerequest
import
makerequest
...
@@ -39,12 +39,11 @@ def close(app):
...
@@ -39,12 +39,11 @@ def close(app):
connections
.
close
(
app
)
connections
.
close
(
app
)
@
implementer
(
interfaces
.
IZopeTestCase
)
class
TestCase
(
unittest
.
TestCase
,
object
):
class
TestCase
(
unittest
.
TestCase
,
object
):
'''Base test case for Zope testing
'''Base test case for Zope testing
'''
'''
implements
(
interfaces
.
IZopeTestCase
)
layer
=
layer
.
ZopeLite
layer
=
layer
.
ZopeLite
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
...
...
src/Testing/ZopeTestCase/functional.py
View file @
7214980c
...
@@ -20,7 +20,7 @@ from functools import partial
...
@@ -20,7 +20,7 @@ from functools import partial
import
sys
import
sys
import
transaction
import
transaction
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
Testing.ZopeTestCase
import
interfaces
from
Testing.ZopeTestCase
import
interfaces
from
Testing.ZopeTestCase
import
sandbox
from
Testing.ZopeTestCase
import
sandbox
...
@@ -46,6 +46,7 @@ def savestate(func):
...
@@ -46,6 +46,7 @@ def savestate(func):
return
wrapped_func
return
wrapped_func
@
implementer
(
interfaces
.
IFunctional
)
class
Functional
(
sandbox
.
Sandboxed
):
class
Functional
(
sandbox
.
Sandboxed
):
'''Derive from this class and an xTestCase to get functional
'''Derive from this class and an xTestCase to get functional
testing support::
testing support::
...
@@ -54,8 +55,6 @@ class Functional(sandbox.Sandboxed):
...
@@ -54,8 +55,6 @@ class Functional(sandbox.Sandboxed):
...
...
'''
'''
implements
(
interfaces
.
IFunctional
)
@
savestate
@
savestate
def
publish
(
self
,
path
,
basic
=
None
,
env
=
None
,
extra
=
None
,
def
publish
(
self
,
path
,
basic
=
None
,
env
=
None
,
extra
=
None
,
request_method
=
'GET'
,
stdin
=
None
,
handle_errors
=
True
):
request_method
=
'GET'
,
stdin
=
None
,
handle_errors
=
True
):
...
...
src/Testing/ZopeTestCase/testPlaceless.py
View file @
7214980c
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
"""Placeless setup tests
"""Placeless setup tests
"""
"""
from
zope.component
import
adapt
s
from
zope.component
import
adapt
er
from
zope.interface
import
implement
s
,
Interface
from
zope.interface
import
implement
er
,
Interface
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
...
@@ -48,16 +48,16 @@ class IAdapted(Interface):
...
@@ -48,16 +48,16 @@ class IAdapted(Interface):
"""
"""
@
implementer
(
IAdaptable
)
class
Adaptable
:
class
Adaptable
:
implements
(
IAdaptable
)
def
method
(
self
):
def
method
(
self
):
return
"The method"
return
"The method"
@
implementer
(
IAdapted
)
@
adapter
(
IAdaptable
)
class
Adapter
:
class
Adapter
:
implements
(
IAdapted
)
adapts
(
IAdaptable
)
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
context
=
context
self
.
context
=
context
...
...
src/Testing/ZopeTestCase/zopedoctest/functional.py
View file @
7214980c
...
@@ -39,9 +39,8 @@ if sys.version_info >= (3, ):
...
@@ -39,9 +39,8 @@ if sys.version_info >= (3, ):
basestring
=
str
basestring
=
str
class
HTTPHeaderOutput
:
class
HTTPHeaderOutput
(
object
)
:
# zope.interface.implements(zope.server.interfaces.IHeaderOutput)
status
=
'200'
status
=
'200'
reason
=
'OK'
reason
=
'OK'
...
@@ -214,7 +213,7 @@ def http(request_string, handle_errors=True):
...
@@ -214,7 +213,7 @@ def http(request_string, handle_errors=True):
response, outstream, path, header_output, wsgi_result, wsgi_headers)
response, outstream, path, header_output, wsgi_result, wsgi_headers)
class ZopeSuiteFactory:
class ZopeSuiteFactory
(object)
:
def __init__(self, *args, **kw):
def __init__(self, *args, **kw):
self._args = args
self._args = args
...
...
src/ZPublisher/BaseRequest.py
View file @
7214980c
...
@@ -25,7 +25,7 @@ from zExceptions import Forbidden
...
@@ -25,7 +25,7 @@ from zExceptions import Forbidden
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
from
zope.component
import
queryMultiAdapter
from
zope.component
import
queryMultiAdapter
from
zope.event
import
notify
from
zope.event
import
notify
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.interface
import
Interface
from
zope.interface
import
Interface
from
zope.location.interfaces
import
LocationError
from
zope.location.interfaces
import
LocationError
from
zope.publisher.defaultview
import
queryDefaultViewName
from
zope.publisher.defaultview
import
queryDefaultViewName
...
@@ -70,10 +70,9 @@ class RequestContainer(Base):
...
@@ -70,10 +70,9 @@ class RequestContainer(Base):
return
type_converters
.
keys
()
return
type_converters
.
keys
()
@
implementer
(
IBrowserPublisher
)
class
DefaultPublishTraverse
(
object
):
class
DefaultPublishTraverse
(
object
):
implements
(
IBrowserPublisher
)
def
__init__
(
self
,
context
,
request
):
def
__init__
(
self
,
context
,
request
):
self
.
context
=
context
self
.
context
=
context
self
.
request
=
request
self
.
request
=
request
...
...
src/ZPublisher/HTTPRequest.py
View file @
7214980c
...
@@ -40,7 +40,7 @@ from zope.i18n.interfaces import IUserPreferredLanguages
...
@@ -40,7 +40,7 @@ from zope.i18n.interfaces import IUserPreferredLanguages
from
zope.i18n.locales
import
locales
,
LoadLocaleError
from
zope.i18n.locales
import
locales
,
LoadLocaleError
from
zope.interface
import
directlyProvidedBy
from
zope.interface
import
directlyProvidedBy
from
zope.interface
import
directlyProvides
from
zope.interface
import
directlyProvides
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.publisher.base
import
DebugFlags
from
zope.publisher.base
import
DebugFlags
from
zope.publisher.interfaces.browser
import
IBrowserRequest
from
zope.publisher.interfaces.browser
import
IBrowserRequest
...
@@ -119,6 +119,7 @@ class NestedLoopExit(Exception):
...
@@ -119,6 +119,7 @@ class NestedLoopExit(Exception):
pass
pass
@
implementer
(
IBrowserRequest
)
class
HTTPRequest
(
BaseRequest
):
class
HTTPRequest
(
BaseRequest
):
""" Model HTTP request data.
""" Model HTTP request data.
...
@@ -171,11 +172,6 @@ class HTTPRequest(BaseRequest):
...
@@ -171,11 +172,6 @@ class HTTPRequest(BaseRequest):
other variables, form data, and then cookies.
other variables, form data, and then cookies.
"""
"""
# The claim to implement IBrowserRequest has been made during the Zope3
# integration project called Five but hasn't been completed in full.
implements
(
IBrowserRequest
)
_hacked_path
=
None
_hacked_path
=
None
args
=
()
args
=
()
_file
=
None
_file
=
None
...
...
src/ZPublisher/Iterators.py
View file @
7214980c
import
io
import
io
from
zope.interface
import
Interface
from
zope.interface
import
Interface
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
class
IUnboundStreamIterator
(
Interface
):
class
IUnboundStreamIterator
(
Interface
):
...
@@ -38,14 +38,13 @@ class IStreamIterator(IUnboundStreamIterator):
...
@@ -38,14 +38,13 @@ class IStreamIterator(IUnboundStreamIterator):
"""
"""
@
implementer
(
IStreamIterator
)
class
filestream_iterator
(
io
.
FileIO
):
class
filestream_iterator
(
io
.
FileIO
):
"""
"""
A FileIO subclass which implements an iterator that returns a
A FileIO subclass which implements an iterator that returns a
fixed-sized sequence of bytes.
fixed-sized sequence of bytes.
"""
"""
implements
(
IStreamIterator
)
def
__init__
(
self
,
name
,
mode
=
'rb'
,
bufsize
=-
1
,
streamsize
=
1
<<
16
):
def
__init__
(
self
,
name
,
mode
=
'rb'
,
bufsize
=-
1
,
streamsize
=
1
<<
16
):
super
(
filestream_iterator
,
self
).
__init__
(
name
,
mode
)
super
(
filestream_iterator
,
self
).
__init__
(
name
,
mode
)
self
.
streamsize
=
streamsize
self
.
streamsize
=
streamsize
...
...
src/ZPublisher/pubevents.py
View file @
7214980c
...
@@ -7,7 +7,7 @@ Subscriptions can be used for all kinds of request supervision,
...
@@ -7,7 +7,7 @@ Subscriptions can be used for all kinds of request supervision,
e.g. request and error rate determination, writing high resolution logfiles
e.g. request and error rate determination, writing high resolution logfiles
for detailed time related analysis, inline request monitoring.
for detailed time related analysis, inline request monitoring.
'''
'''
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
ZPublisher.interfaces
import
(
from
ZPublisher.interfaces
import
(
IPubStart
,
IPubSuccess
,
IPubFailure
,
IPubStart
,
IPubSuccess
,
IPubFailure
,
...
@@ -23,46 +23,46 @@ class _Base(object):
...
@@ -23,46 +23,46 @@ class _Base(object):
self
.
request
=
request
self
.
request
=
request
@
implementer
(
IPubStart
)
class
PubStart
(
_Base
):
class
PubStart
(
_Base
):
'''notified at the beginning of 'ZPublisher.Publish.publish'.'''
'''notified at the beginning of 'ZPublisher.Publish.publish'.'''
implements
(
IPubStart
)
@
implementer
(
IPubSuccess
)
class
PubSuccess
(
_Base
):
class
PubSuccess
(
_Base
):
'''notified at successful request end.'''
'''notified at successful request end.'''
implements
(
IPubSuccess
)
@
implementer
(
IPubFailure
)
class
PubFailure
(
object
):
class
PubFailure
(
object
):
'''notified at failed request end.'''
'''notified at failed request end.'''
implements
(
IPubFailure
)
def
__init__
(
self
,
request
,
exc_info
,
retry
):
def
__init__
(
self
,
request
,
exc_info
,
retry
):
self
.
request
,
self
.
exc_info
,
self
.
retry
=
request
,
exc_info
,
retry
self
.
request
,
self
.
exc_info
,
self
.
retry
=
request
,
exc_info
,
retry
@
implementer
(
IPubAfterTraversal
)
class
PubAfterTraversal
(
_Base
):
class
PubAfterTraversal
(
_Base
):
"""notified after traversal and an (optional) authentication."""
"""notified after traversal and an (optional) authentication."""
implements
(
IPubAfterTraversal
)
@
implementer
(
IPubBeforeCommit
)
class
PubBeforeCommit
(
_Base
):
class
PubBeforeCommit
(
_Base
):
"""notified immediately before the commit."""
"""notified immediately before the commit."""
implements
(
IPubBeforeCommit
)
@
implementer
(
IPubBeforeAbort
)
class
PubBeforeAbort
(
_Base
):
class
PubBeforeAbort
(
_Base
):
"""notified immediately before an abort."""
"""notified immediately before an abort."""
implements
(
IPubBeforeAbort
)
def
__init__
(
self
,
request
,
exc_info
,
retry
):
def
__init__
(
self
,
request
,
exc_info
,
retry
):
self
.
request
,
self
.
exc_info
,
self
.
retry
=
request
,
exc_info
,
retry
self
.
request
,
self
.
exc_info
,
self
.
retry
=
request
,
exc_info
,
retry
@
implementer
(
IPubBeforeStreaming
)
class
PubBeforeStreaming
(
object
):
class
PubBeforeStreaming
(
object
):
"""Notified immediately before streaming via response.write() commences
"""Notified immediately before streaming via response.write() commences
"""
"""
implements
(
IPubBeforeStreaming
)
def
__init__
(
self
,
response
):
def
__init__
(
self
,
response
):
self
.
response
=
response
self
.
response
=
response
src/ZPublisher/tests/testBaseRequest.py
View file @
7214980c
import
unittest
import
unittest
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.publisher.interfaces
import
IPublishTraverse
from
zope.publisher.interfaces
import
IPublishTraverse
from
zope.publisher.interfaces
import
NotFound
as
ztkNotFound
from
zope.publisher.interfaces
import
NotFound
as
ztkNotFound
@
implementer
(
IPublishTraverse
)
class
DummyTraverser
(
object
):
class
DummyTraverser
(
object
):
implements
(
IPublishTraverse
)
def
publishTraverse
(
self
,
request
,
name
):
def
publishTraverse
(
self
,
request
,
name
):
if
name
==
'dummy'
:
if
name
==
'dummy'
:
return
'dummy object'
return
'dummy object'
...
@@ -515,10 +514,10 @@ class TestRequestViewsBase(unittest.TestCase, BaseRequest_factory):
...
@@ -515,10 +514,10 @@ class TestRequestViewsBase(unittest.TestCase, BaseRequest_factory):
return
IDummy
return
IDummy
def
_makeDummyObject
(
self
,
name
=
'dummy'
):
def
_makeDummyObject
(
self
,
name
=
'dummy'
):
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
self
.
_dummyInterface
())
class
DummyObjectZ3
(
self
.
_makeBasicObjectClass
()):
class
DummyObjectZ3
(
self
.
_makeBasicObjectClass
()):
implements
(
self
.
_dummyInterface
())
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
name
=
name
...
@@ -526,10 +525,10 @@ class TestRequestViewsBase(unittest.TestCase, BaseRequest_factory):
...
@@ -526,10 +525,10 @@ class TestRequestViewsBase(unittest.TestCase, BaseRequest_factory):
return
DummyObjectZ3
(
name
)
return
DummyObjectZ3
(
name
)
def
_makeDummyObjectWithAttr
(
self
,
name
):
def
_makeDummyObjectWithAttr
(
self
,
name
):
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
self
.
_dummyInterface
())
class
DummyObjectZ3WithAttr
(
self
.
_makeBasicObjectClass
()):
class
DummyObjectZ3WithAttr
(
self
.
_makeBasicObjectClass
()):
implements
(
self
.
_dummyInterface
())
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
name
=
name
...
...
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
7214980c
...
@@ -92,10 +92,10 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -92,10 +92,10 @@ class WSGIResponseTests(unittest.TestCase):
def
test_setBody_IUnboundStreamIterator
(
self
):
def
test_setBody_IUnboundStreamIterator
(
self
):
from
ZPublisher.Iterators
import
IUnboundStreamIterator
from
ZPublisher.Iterators
import
IUnboundStreamIterator
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
IUnboundStreamIterator
)
class
TestStreamIterator
(
object
):
class
TestStreamIterator
(
object
):
implements
(
IUnboundStreamIterator
)
data
=
"hello"
data
=
"hello"
done
=
0
done
=
0
...
@@ -115,10 +115,10 @@ class WSGIResponseTests(unittest.TestCase):
...
@@ -115,10 +115,10 @@ class WSGIResponseTests(unittest.TestCase):
def
test_setBody_IStreamIterator
(
self
):
def
test_setBody_IStreamIterator
(
self
):
from
ZPublisher.Iterators
import
IStreamIterator
from
ZPublisher.Iterators
import
IStreamIterator
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
IStreamIterator
)
class
TestStreamIterator
(
object
):
class
TestStreamIterator
(
object
):
implements
(
IStreamIterator
)
data
=
"hello"
data
=
"hello"
done
=
0
done
=
0
...
@@ -342,10 +342,10 @@ class TestPublishModule(unittest.TestCase, PlacelessSetup):
...
@@ -342,10 +342,10 @@ class TestPublishModule(unittest.TestCase, PlacelessSetup):
def
test_response_is_stream
(
self
):
def
test_response_is_stream
(
self
):
from
ZPublisher.Iterators
import
IStreamIterator
from
ZPublisher.Iterators
import
IStreamIterator
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
IStreamIterator
)
class
TestStreamIterator
(
object
):
class
TestStreamIterator
(
object
):
implements
(
IStreamIterator
)
data
=
"hello"
data
=
"hello"
done
=
0
done
=
0
...
@@ -368,10 +368,10 @@ class TestPublishModule(unittest.TestCase, PlacelessSetup):
...
@@ -368,10 +368,10 @@ class TestPublishModule(unittest.TestCase, PlacelessSetup):
def
test_response_is_unboundstream
(
self
):
def
test_response_is_unboundstream
(
self
):
from
ZPublisher.Iterators
import
IUnboundStreamIterator
from
ZPublisher.Iterators
import
IUnboundStreamIterator
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
@
implementer
(
IUnboundStreamIterator
)
class
TestUnboundStreamIterator
(
object
):
class
TestUnboundStreamIterator
(
object
):
implements
(
IUnboundStreamIterator
)
data
=
"hello"
data
=
"hello"
done
=
0
done
=
0
...
...
src/Zope2/App/schema.py
View file @
7214980c
...
@@ -13,17 +13,16 @@
...
@@ -13,17 +13,16 @@
##############################################################################
##############################################################################
from
zope.component
import
getUtility
from
zope.component
import
getUtility
from
zope.interface
import
implement
s
from
zope.interface
import
implement
er
from
zope.schema.interfaces
import
IVocabularyFactory
from
zope.schema.interfaces
import
IVocabularyFactory
from
zope.schema.interfaces
import
IVocabularyRegistry
from
zope.schema.interfaces
import
IVocabularyRegistry
from
zope.schema.vocabulary
import
setVocabularyRegistry
from
zope.schema.vocabulary
import
setVocabularyRegistry
@
implementer
(
IVocabularyRegistry
)
class
Zope2VocabularyRegistry
(
object
):
class
Zope2VocabularyRegistry
(
object
):
"""IVocabularyRegistry that supports global and local utilities.
"""IVocabularyRegistry that supports global and local utilities.
"""
"""
implements
(
IVocabularyRegistry
)
__slots__
=
()
__slots__
=
()
def
get
(
self
,
context
,
name
):
def
get
(
self
,
context
,
name
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment