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
a5ccd7a2
Commit
a5ccd7a2
authored
Jul 13, 2005
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- migrated some z2 interfaces to z3 interfaces, using Interface.bridge for backwards compatibility
- added some implements() declarations
parent
b04834a6
Changes
36
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
449 additions
and
672 deletions
+449
-672
doc/CHANGES.txt
doc/CHANGES.txt
+4
-0
lib/python/OFS/Application.py
lib/python/OFS/Application.py
+10
-4
lib/python/OFS/CopySupport.py
lib/python/OFS/CopySupport.py
+11
-6
lib/python/OFS/FTPInterface.py
lib/python/OFS/FTPInterface.py
+10
-2
lib/python/OFS/FindSupport.py
lib/python/OFS/FindSupport.py
+18
-11
lib/python/OFS/Folder.py
lib/python/OFS/Folder.py
+14
-6
lib/python/OFS/IOrderSupport.py
lib/python/OFS/IOrderSupport.py
+9
-95
lib/python/OFS/ObjectManager.py
lib/python/OFS/ObjectManager.py
+18
-13
lib/python/OFS/OrderSupport.py
lib/python/OFS/OrderSupport.py
+7
-3
lib/python/OFS/OrderedFolder.py
lib/python/OFS/OrderedFolder.py
+6
-1
lib/python/OFS/PropertyManager.py
lib/python/OFS/PropertyManager.py
+7
-3
lib/python/OFS/SimpleItem.py
lib/python/OFS/SimpleItem.py
+20
-8
lib/python/OFS/Traversable.py
lib/python/OFS/Traversable.py
+12
-7
lib/python/OFS/interfaces.py
lib/python/OFS/interfaces.py
+95
-9
lib/python/OFS/tests/testApplication.py
lib/python/OFS/tests/testApplication.py
+1
-1
lib/python/OFS/tests/testCopySupport.py
lib/python/OFS/tests/testCopySupport.py
+10
-13
lib/python/OFS/tests/testFTPInterface.py
lib/python/OFS/tests/testFTPInterface.py
+1
-1
lib/python/OFS/tests/testFindSupport.py
lib/python/OFS/tests/testFindSupport.py
+1
-1
lib/python/OFS/tests/testFolder.py
lib/python/OFS/tests/testFolder.py
+2
-2
lib/python/OFS/tests/testObjectManager.py
lib/python/OFS/tests/testObjectManager.py
+7
-5
lib/python/OFS/tests/testOrderSupport.py
lib/python/OFS/tests/testOrderSupport.py
+1
-4
lib/python/OFS/tests/testOrderedFolder.py
lib/python/OFS/tests/testOrderedFolder.py
+3
-3
lib/python/OFS/tests/testProperties.py
lib/python/OFS/tests/testProperties.py
+6
-3
lib/python/OFS/tests/testSimpleItem.py
lib/python/OFS/tests/testSimpleItem.py
+4
-4
lib/python/OFS/tests/testTraverse.py
lib/python/OFS/tests/testTraverse.py
+26
-25
lib/python/Products/PluginIndexes/common/PluggableIndex.py
lib/python/Products/PluginIndexes/common/PluggableIndex.py
+18
-84
lib/python/Products/PluginIndexes/interfaces.py
lib/python/Products/PluginIndexes/interfaces.py
+10
-17
lib/python/Products/ZCatalog/IZCatalog.py
lib/python/Products/ZCatalog/IZCatalog.py
+8
-234
lib/python/Products/ZCatalog/interfaces.py
lib/python/Products/ZCatalog/interfaces.py
+0
-5
lib/python/webdav/Collection.py
lib/python/webdav/Collection.py
+15
-6
lib/python/webdav/Resource.py
lib/python/webdav/Resource.py
+14
-9
lib/python/webdav/WriteLockInterface.py
lib/python/webdav/WriteLockInterface.py
+8
-66
lib/python/webdav/interfaces.py
lib/python/webdav/interfaces.py
+67
-8
lib/python/webdav/tests/testCollection.py
lib/python/webdav/tests/testCollection.py
+1
-4
lib/python/webdav/tests/testNullResource.py
lib/python/webdav/tests/testNullResource.py
+2
-5
lib/python/webdav/tests/testResource.py
lib/python/webdav/tests/testResource.py
+3
-4
No files found.
doc/CHANGES.txt
View file @
a5ccd7a2
...
...
@@ -26,6 +26,10 @@ Zope Changes
Features added
- AccessControl, Acquisition, App, OFS, webdav, PluginIndexes, ZCatalog
and ZCTextIndex: Added some Zope 3 style interfaces.
This makes the bridged interfaces shipped with Five obsolete.
- Interface: Added Z3 -> Z2 bridge utilities.
This allows to migrate interfaces to Zope 3 style interfaces and
bridge them back to oldstyle interfaces for backwards compatibility.
...
...
lib/python/OFS/Application.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Application support
...
...
@@ -19,7 +19,7 @@ import os, sys, traceback
from
cgi
import
escape
from
StringIO
import
StringIO
import
Globals
,
Products
,
App
.
Product
,
App
.
ProductRegistry
,
misc_
import
Globals
,
Products
,
App
.
Product
,
App
.
ProductRegistry
import
transaction
from
AccessControl.User
import
UserFolder
from
Acquisition
import
aq_base
...
...
@@ -29,14 +29,18 @@ from App.Product import doInstall
from
App.ProductContext
import
ProductContext
from
DateTime
import
DateTime
from
HelpSys.HelpSys
import
HelpSys
from
misc_
import
Misc_
from
webdav.NullResource
import
NullResource
from
zExceptions
import
Redirect
as
RedirectException
,
Forbidden
from
zLOG
import
LOG
,
ERROR
,
WARNING
,
INFO
from
zope.interface
import
implements
import
Folder
import
misc_
import
ZDOM
from
FindSupport
import
FindSupport
from
interfaces
import
IApplication
from
misc_
import
Misc_
class
Application
(
Globals
.
ApplicationDefaultPermissions
,
ZDOM
.
Root
,
Folder
.
Folder
,
...
...
@@ -44,6 +48,8 @@ class Application(Globals.ApplicationDefaultPermissions,
"""Top-level system object"""
implements
(
IApplication
)
title
=
'Zope'
#__roles__=['Manager', 'Anonymous']
__defined_roles__
=
(
'Manager'
,
'Anonymous'
,
'Owner'
)
...
...
lib/python/OFS/CopySupport.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Copy interface
...
...
@@ -23,12 +23,16 @@ from zlib import compress, decompress
import
Globals
,
Moniker
,
ExtensionClass
import
transaction
from
App.Dialogs
import
MessageDialog
from
AccessControl
import
getSecurityManager
from
AccessControl.Permissions
import
delete_objects
as
DeleteObjects
from
Acquisition
import
aq_base
,
aq_inner
,
aq_parent
from
zExceptions
import
Unauthorized
,
BadRequest
from
App.Dialogs
import
MessageDialog
from
webdav.Lockable
import
ResourceLockedError
from
zExceptions
import
Unauthorized
,
BadRequest
from
zope.interface
import
implements
from
OFS.interfaces
import
ICopyContainer
from
OFS.interfaces
import
ICopySource
CopyError
=
'Copy Error'
...
...
@@ -42,6 +46,8 @@ class CopyContainer(ExtensionClass.Base):
"""Interface for containerish objects which allow cut/copy/paste"""
implements
(
ICopyContainer
)
__ac_permissions__
=
(
(
'View management screens'
,
(
'manage_copyObjects'
,
'manage_pasteObjects'
,
...
...
@@ -50,7 +56,6 @@ class CopyContainer(ExtensionClass.Base):
(
'manage_cutObjects'
,)),
)
# The following three methods should be overridden to store sub-objects
# as non-attributes.
def
_setOb
(
self
,
id
,
object
):
...
...
@@ -240,7 +245,6 @@ class CopyContainer(ExtensionClass.Base):
cb_dataValid
=
0
)
return
result
manage_renameForm
=
Globals
.
DTMLFile
(
'dtml/renameForm'
,
globals
())
def
manage_renameObjects
(
self
,
ids
=
[],
new_ids
=
[],
REQUEST
=
None
):
...
...
@@ -430,11 +434,12 @@ class CopyContainer(ExtensionClass.Base):
Globals
.
default__class_init__
(
CopyContainer
)
class
CopySource
(
ExtensionClass
.
Base
):
"""Interface for objects which allow themselves to be copied."""
implements
(
ICopySource
)
# declare a dummy permission for Copy or Move here that we check
# in cb_isCopyable.
__ac_permissions__
=
(
...
...
lib/python/OFS/FTPInterface.py
View file @
a5ccd7a2
...
...
@@ -7,10 +7,9 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""FTP Support for Zope classes.
Preliminary FTP support interface. Note, most FTP functions are
...
...
@@ -19,11 +18,20 @@ provided by existing methods such as PUT and manage_delObjects.
All FTP methods should be governed by a single permission:
'FTP access'.
$Id$
"""
from
zope.interface
import
implements
from
interfaces
import
IFTPAccess
class
FTPInterface
:
"Interface for FTP objects"
implements
(
IFTPAccess
)
# XXX The stat and list marshal format should probably
# be XML, not marshal, maybe Andrew K's xml-marshal.
# This will probably be changed later.
...
...
lib/python/OFS/FindSupport.py
View file @
a5ccd7a2
...
...
@@ -7,26 +7,35 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Find support
$Id$
"""
import
sys
,
os
,
time
,
Globals
,
ExtensionClass
from
DocumentTemplate.DT_Util
import
Eval
from
AccessControl.Permission
import
name_trans
from
Globals
import
DTMLFile
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DateTime
import
DateTime
from
string
import
translate
from
AccessControl.DTML
import
RestrictedDTML
import
Globals
,
ExtensionClass
from
AccessControl
import
ClassSecurityInfo
from
AccessControl.DTML
import
RestrictedDTML
from
AccessControl.Permission
import
name_trans
from
DateTime
import
DateTime
from
DocumentTemplate.DT_Util
import
Eval
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
Globals
import
DTMLFile
from
zope.interface
import
implements
from
interfaces
import
IFindSupport
class
FindSupport
(
ExtensionClass
.
Base
):
"""Find support for Zope Folders"""
implements
(
IFindSupport
)
#findframe is deprecated
manage_findFrame
=
DTMLFile
(
'dtml/findFrame'
,
globals
())
manage_findForm
=
DTMLFile
(
'dtml/findForm'
,
globals
(),
...
...
@@ -250,7 +259,7 @@ class FindSupport(ExtensionClass.Base):
return
result
Globals
.
InitializeClass
(
FindSupport
)
class
td
(
RestrictedDTML
,
TemplateDict
):
...
...
@@ -304,8 +313,6 @@ def role_match(ob, permission, roles, lt=type([]), tt=type(())):
return
1
Globals
.
InitializeClass
(
FindSupport
)
# Helper functions
def
absattr
(
attr
):
...
...
lib/python/OFS/Folder.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Folder object
...
...
@@ -16,14 +16,20 @@ Folders are the basic container objects and are analogous to directories.
$Id$
"""
import
Globals
,
SimpleItem
,
ObjectManager
,
PropertyManager
import
AccessControl.Role
,
webdav
.
Collection
,
FindSupport
from
webdav.WriteLockInterface
import
WriteLockInterface
import
AccessControl.Role
,
webdav
.
Collection
import
Globals
from
AccessControl
import
getSecurityManager
from
AccessControl
import
Unauthorized
from
AccessControl.Permissions
import
add_page_templates
from
AccessControl.Permissions
import
add_user_folders
from
Globals
import
DTMLFile
from
webdav.WriteLockInterface
import
WriteLockInterface
from
zope.interface
import
implements
import
FindSupport
import
SimpleItem
,
ObjectManager
,
PropertyManager
from
interfaces
import
IFolder
manage_addFolderForm
=
DTMLFile
(
'dtml/folderAdd'
,
globals
())
...
...
@@ -72,12 +78,14 @@ class Folder(
SimpleItem
.
Item
,
FindSupport
.
FindSupport
,
):
"""
Folders are basic container objects that provide a standard
"""
Folders are basic container objects that provide a standard
interface for object management. Folder objects also implement
a management interface and can have arbitrary properties.
"""
__implements__
=
(
WriteLockInterface
,)
implements
(
IFolder
)
meta_type
=
'Folder'
_properties
=
({
'id'
:
'title'
,
'type'
:
'string'
,
'mode'
:
'wd'
},)
...
...
lib/python/OFS/IOrderSupport.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
""" Order support interfaces.
...
...
@@ -15,100 +15,14 @@
$Id$
"""
from
Interface
import
Interface
# create IOrderedContainer
from
Interface.bridge
import
createZope3Bridge
from
OFS.interfaces
import
IOrderedContainer
as
z3IOrderedContainer
import
IOrderSupport
class
IOrderedContainer
(
Interface
):
""" Ordered Container interface.
createZope3Bridge
(
z3IOrderedContainer
,
IOrderSupport
,
'IOrderedContainer'
)
This interface provides a common mechanism for maintaining ordered
collections.
"""
def
moveObjectsByDelta
(
ids
,
delta
,
subset_ids
=
None
):
""" Move specified sub-objects by delta.
If delta is higher than the possible maximum, objects will be moved to
the bottom. If delta is lower than the possible minimum, objects will
be moved to the top.
If subset_ids is not None, delta will be interpreted relative to the
subset specified by a sequence of ids. The position of objects that
are not part of this subset will not be changed.
The order of the objects specified by ids will always be preserved. So
if you don't want to change their original order, make sure the order
of ids corresponds to their original order.
If an object with id doesn't exist an error will be raised.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsUp
(
ids
,
delta
=
1
,
subset_ids
=
None
):
""" Move specified sub-objects up by delta in container.
If no delta is specified, delta is 1. See moveObjectsByDelta for more
details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsDown
(
ids
,
delta
=
1
,
subset_ids
=
None
):
""" Move specified sub-objects down by delta in container.
If no delta is specified, delta is 1. See moveObjectsByDelta for more
details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsToTop
(
ids
,
subset_ids
=
None
):
""" Move specified sub-objects to top of container.
See moveObjectsByDelta for more details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsToBottom
(
ids
,
subset_ids
=
None
):
""" Move specified sub-objects to bottom of container.
See moveObjectsByDelta for more details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
orderObjects
(
key
,
reverse
=
None
):
""" Order sub-objects by key and direction.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
getObjectPosition
(
id
):
""" Get the position of an object by its id.
Permission -- Access contents information
Returns -- Position
"""
def
moveObjectToPosition
(
id
,
position
):
""" Move specified object to absolute position.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
del
createZope3Bridge
del
z3IOrderedContainer
del
IOrderSupport
lib/python/OFS/ObjectManager.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Object Manager
...
...
@@ -15,31 +15,34 @@
$Id$
"""
import
sys
,
fnmatch
,
copy
,
os
,
re
import
marshal
import
sys
,
fnmatch
,
copy
,
os
,
re
from
cgi
import
escape
from
cStringIO
import
StringIO
from
types
import
StringType
,
UnicodeType
import
App.
Management
,
Acquisition
,
Globals
,
Products
import
App.
Common
import
App.FactoryDispatcher
,
Products
import
App.Management
,
Acquisition
,
Globals
,
Products
from
AccessControl
import
getSecurityManager
from
AccessControl.ZopeSecurityPolicy
import
getRoles
from
Acquisition
import
aq_base
from
App.config
import
getConfiguration
from
Globals
import
DTMLFile
,
Persistent
from
Globals
import
MessageDialog
,
default__class_init__
from
Globals
import
REPLACEABLE
,
NOT_REPLACEABLE
,
UNIQUE
from
webdav.NullResource
import
NullResource
from
webdav.Collection
import
Collection
from
Acquisition
import
aq_base
from
webdav.Lockable
import
ResourceLockedError
from
ZODB.POSException
import
ConflictError
import
App.Common
from
App.config
import
getConfiguration
from
AccessControl
import
getSecurityManager
from
AccessControl.ZopeSecurityPolicy
import
getRoles
from
zLOG
import
LOG
,
ERROR
from
webdav.NullResource
import
NullResource
from
zExceptions
import
BadRequest
from
zLOG
import
LOG
,
ERROR
from
ZODB.POSException
import
ConflictError
from
zope.interface
import
implements
from
OFS.Traversable
import
Traversable
import
CopySupport
from
interfaces
import
IObjectManager
from
Traversable
import
Traversable
# the name BadRequestException is relied upon by 3rd-party code
BadRequestException
=
BadRequest
...
...
@@ -122,6 +125,8 @@ class ObjectManager(
This class provides core behavior for collections of heterogeneous objects.
"""
implements
(
IObjectManager
)
__ac_permissions__
=
(
(
'View management screens'
,
(
'manage_main'
,)),
(
'Access contents information'
,
...
...
lib/python/OFS/OrderSupport.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
""" Order support for 'Object Manager'.
...
...
@@ -23,12 +23,15 @@ from AccessControl.Permissions import manage_properties
from
Acquisition
import
aq_base
from
DocumentTemplate.sequence
import
sort
from
Globals
import
InitializeClass
from
zope.interface
import
implements
from
IOrderSupport
import
IOrderedContainer
from
interfaces
import
IOrderedContainer
as
z3IOrderedContainer
from
IOrderSupport
import
IOrderedContainer
as
z2IOrderedContainer
from
ObjectManager
import
ObjectManager
class
OrderSupport
:
""" Ordered container mixin class.
This is an extension to the regular ObjectManager. It saves the objects in
...
...
@@ -37,7 +40,8 @@ class OrderSupport:
is totally user-specific.
"""
__implements__
=
IOrderedContainer
__implements__
=
z2IOrderedContainer
implements
(
z3IOrderedContainer
)
security
=
ClassSecurityInfo
()
has_order_support
=
1
...
...
lib/python/OFS/OrderedFolder.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
""" 'Folder' with order support.
...
...
@@ -20,8 +20,10 @@ from AccessControl import Unauthorized
from
AccessControl.Permissions
import
add_page_templates
from
AccessControl.Permissions
import
add_user_folders
from
Globals
import
DTMLFile
from
zope.interface
import
implements
from
Folder
import
Folder
from
interfaces
import
IOrderedFolder
from
OrderSupport
import
OrderSupport
manage_addOrderedFolderForm
=
DTMLFile
(
'dtml/addOrderedFolder'
,
globals
())
...
...
@@ -61,10 +63,13 @@ def manage_addOrderedFolder(self, id, title='', createPublic=0, createUserF=0,
class
OrderedFolder
(
OrderSupport
,
Folder
):
""" Extends the default Folder by order support.
"""
__implements__
=
(
OrderSupport
.
__implements__
,
Folder
.
__implements__
)
implements
(
IOrderedFolder
)
meta_type
=
'Folder (Ordered)'
manage_options
=
(
OrderSupport
.
manage_options
+
...
...
lib/python/OFS/PropertyManager.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Property management
...
...
@@ -19,13 +19,15 @@ from cgi import escape
from
types
import
ListType
import
ExtensionClass
,
Globals
from
ZPublisher.Converters
import
type_converters
from
Globals
import
DTMLFile
,
MessageDialog
from
Acquisition
import
aq_base
from
Globals
import
DTMLFile
,
MessageDialog
from
Globals
import
Persistent
from
zExceptions
import
BadRequest
from
zope.interface
import
implements
from
ZPublisher.Converters
import
type_converters
import
ZDOM
from
interfaces
import
IPropertyManager
from
PropertySheets
import
DefaultPropertySheets
,
vps
...
...
@@ -93,6 +95,8 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
'manage_changeProperties',)),
"""
implements
(
IPropertyManager
)
manage_options
=
(
{
'label'
:
'Properties'
,
'action'
:
'manage_propertiesForm'
,
'help'
:(
'OFSP'
,
'Properties.stx'
)},
...
...
lib/python/OFS/SimpleItem.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""This module implements a simple item mix-in for objects that have a
...
...
@@ -22,22 +22,27 @@ $Id$
import
marshal
,
re
,
sys
,
time
import
Globals
,
App
.
Management
,
Acquisition
,
App
.
Undo
import
AccessControl.Role
,
AccessControl
.
Owned
,
App
.
Common
from
webdav.Resource
import
Resource
from
ExtensionClass
import
Base
from
ComputedAttribute
import
ComputedAttribute
import
Globals
,
App
.
Management
,
Acquisition
,
App
.
Undo
from
AccessControl
import
getSecurityManager
,
Unauthorized
from
AccessControl.ZopeSecurityPolicy
import
getRoles
from
Acquisition
import
aq_base
,
aq_parent
,
aq_inner
,
aq_acquire
from
ComputedAttribute
import
ComputedAttribute
from
DocumentTemplate.ustr
import
ustr
from
zExceptions.ExceptionFormatter
import
format_exception
from
ExtensionClass
import
Base
from
webdav.Resource
import
Resource
from
zExceptions
import
Redirect
from
zExceptions.ExceptionFormatter
import
format_exception
from
zLOG
import
LOG
,
BLATHER
from
zope.interface
import
implements
import
ZDOM
from
CopySupport
import
CopySource
from
interfaces
import
IItem
from
interfaces
import
IItemWithName
from
interfaces
import
IManageable
from
interfaces
import
ISimpleItem
from
Traversable
import
Traversable
import
ZDOM
HTML
=
Globals
.
HTML
...
...
@@ -50,6 +55,8 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
"""A common base class for simple, non-container objects."""
implements
(
IItem
,
IManageable
)
isPrincipiaFolderish
=
0
isTopLevelPrincipiaApplicationObject
=
0
...
...
@@ -342,8 +349,11 @@ Globals.default__class_init__(Item)
class
Item_w__name__
(
Item
):
"""Mixin class to support common name/id functions"""
implements
(
IItemWithName
)
def
getId
(
self
):
"""Return the id of the object as a string.
"""
...
...
@@ -397,6 +407,8 @@ class SimpleItem(Item, Globals.Persistent,
"""Mix-in class combining the most common set of basic mix-ins
"""
implements
(
ISimpleItem
)
manage_options
=
Item
.
manage_options
+
(
{
'label'
:
'Security'
,
'action'
:
'manage_access'
,
...
...
lib/python/OFS/Traversable.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""This module implements a mix-in for traversable objects.
...
...
@@ -17,18 +17,23 @@ $Id$
from
urllib
import
quote
from
Acquisition
import
Acquired
,
aq_inner
,
aq_parent
,
aq_base
from
AccessControl
import
getSecurityManager
from
AccessControl
import
Unauthorized
from
AccessControl.ZopeGuards
import
guarded_getattr
from
ZODB.POSException
import
ConflictError
from
Acquisition
import
Acquired
,
aq_inner
,
aq_parent
,
aq_base
from
zExceptions
import
NotFound
from
ZODB.POSException
import
ConflictError
from
zope.interface
import
implements
from
interfaces
import
ITraversable
_marker
=
object
()
class
Traversable
:
implements
(
ITraversable
)
absolute_url__roles__
=
None
# Public
def
absolute_url
(
self
,
relative
=
0
):
"""Return the absolute URL of the object.
...
...
lib/python/OFS/interfaces.py
View file @
a5ccd7a2
...
...
@@ -29,16 +29,101 @@ from webdav.interfaces import IDAVCollection
from
webdav.interfaces
import
IDAVResource
# create IOrderedContainer
from
Products.Five.fiveconfigure
import
createZope2Bridge
from
OFS.IOrderSupport
import
IOrderedContainer
as
z2IOrderedContainer
import
interfaces
class
IOrderedContainer
(
Interface
):
createZope2Bridge
(
z2IOrderedContainer
,
interfaces
,
'IOrderedContainer'
)
""" Ordered Container interface.
del
createZope2Bridge
del
z2IOrderedContainer
del
interfaces
This interface provides a common mechanism for maintaining ordered
collections.
"""
def
moveObjectsByDelta
(
ids
,
delta
,
subset_ids
=
None
):
""" Move specified sub-objects by delta.
If delta is higher than the possible maximum, objects will be moved to
the bottom. If delta is lower than the possible minimum, objects will
be moved to the top.
If subset_ids is not None, delta will be interpreted relative to the
subset specified by a sequence of ids. The position of objects that
are not part of this subset will not be changed.
The order of the objects specified by ids will always be preserved. So
if you don't want to change their original order, make sure the order
of ids corresponds to their original order.
If an object with id doesn't exist an error will be raised.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsUp
(
ids
,
delta
=
1
,
subset_ids
=
None
):
""" Move specified sub-objects up by delta in container.
If no delta is specified, delta is 1. See moveObjectsByDelta for more
details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsDown
(
ids
,
delta
=
1
,
subset_ids
=
None
):
""" Move specified sub-objects down by delta in container.
If no delta is specified, delta is 1. See moveObjectsByDelta for more
details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsToTop
(
ids
,
subset_ids
=
None
):
""" Move specified sub-objects to top of container.
See moveObjectsByDelta for more details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
moveObjectsToBottom
(
ids
,
subset_ids
=
None
):
""" Move specified sub-objects to bottom of container.
See moveObjectsByDelta for more details.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
orderObjects
(
key
,
reverse
=
None
):
""" Order sub-objects by key and direction.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
def
getObjectPosition
(
id
):
""" Get the position of an object by its id.
Permission -- Access contents information
Returns -- Position
"""
def
moveObjectToPosition
(
id
,
position
):
""" Move specified object to absolute position.
Permission -- Manage properties
Returns -- Number of moved sub-objects
"""
# XXX: might contain non-API methods and outdated comments;
...
...
@@ -738,7 +823,8 @@ class IFolder(IObjectManager, IPropertyManager, IRoleManager,
"""Folders are basic container objects that provide a standard
interface for object management. Folder objects also implement a
management interface and can have arbitrary properties."""
management interface and can have arbitrary properties.
"""
# XXX: based on OFS.OrderedFolder.OrderedFolder
...
...
lib/python/OFS/tests/testApplication.py
View file @
a5ccd7a2
...
...
@@ -8,7 +8,7 @@ class TestApplication(unittest.TestCase):
from
OFS.Application
import
Application
from
zope.interface.verify
import
verifyClass
verifyClass
(
IApplication
,
Application
,
1
)
verifyClass
(
IApplication
,
Application
)
def
test_suite
():
...
...
lib/python/OFS/tests/testCopySupport.py
View file @
a5ccd7a2
...
...
@@ -4,20 +4,17 @@ import Zope2
Zope2
.
startup
()
import
cStringIO
from
mimetools
import
Message
from
multifile
import
MultiFile
import
transaction
from
AccessControl
import
SecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
Acquisition
import
Implicit
from
Acquisition
import
aq_base
from
Acquisition
import
Implicit
from
OFS.Application
import
Application
from
OFS.Folder
import
manage_addFolder
from
OFS.Image
import
manage_addFile
from
Testing.makerequest
import
makerequest
from
webdav.common
import
rfc1123_date
ADD_IMAGES_AND_FILES
=
'Add images and files'
...
...
@@ -142,8 +139,8 @@ class TestCopySupport( CopySupportTestBase ):
from
OFS.interfaces
import
ICopySource
from
zope.interface.verify
import
verifyClass
verifyClass
(
ICopyContainer
,
CopyContainer
,
1
)
verifyClass
(
ICopySource
,
CopySource
,
1
)
verifyClass
(
ICopyContainer
,
CopyContainer
)
verifyClass
(
ICopySource
,
CopySource
)
def
testRename
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
...
...
lib/python/OFS/tests/testFTPInterface.py
View file @
a5ccd7a2
...
...
@@ -8,7 +8,7 @@ class TestFTPInterface(unittest.TestCase):
from
OFS.FTPInterface
import
FTPInterface
from
zope.interface.verify
import
verifyClass
verifyClass
(
IFTPAccess
,
FTPInterface
,
1
)
verifyClass
(
IFTPAccess
,
FTPInterface
)
def
test_suite
():
...
...
lib/python/OFS/tests/testFindSupport.py
View file @
a5ccd7a2
...
...
@@ -8,7 +8,7 @@ class TestFindSupport(unittest.TestCase):
from
OFS.FindSupport
import
FindSupport
from
zope.interface.verify
import
verifyClass
verifyClass
(
IFindSupport
,
FindSupport
,
1
)
verifyClass
(
IFindSupport
,
FindSupport
)
def
test_suite
():
...
...
lib/python/OFS/tests/testFolder.py
View file @
a5ccd7a2
...
...
@@ -16,8 +16,8 @@ class TestFolder(unittest.TestCase):
from
webdav.interfaces
import
IWriteLock
from
zope.interface.verify
import
verifyClass
verifyClass
(
IFolder
,
Folder
,
1
)
verifyClass
(
IWriteLock
,
Folder
,
1
)
verifyClass
(
IFolder
,
Folder
)
verifyClass
(
IWriteLock
,
Folder
)
def
test_suite
():
...
...
lib/python/OFS/tests/testObjectManager.py
View file @
a5ccd7a2
import
unittest
from
App.config
import
getConfiguration
from
Acquisition
import
Implicit
,
aq_base
,
aq_parent
from
AccessControl.Owned
import
EmergencyUserCannotOwn
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
AccessControl.User
import
User
from
AccessControl.SpecialUsers
import
emergency_user
,
nobody
,
system
from
AccessControl.Owned
import
EmergencyUserCannotOwn
,
Owned
from
AccessControl.User
import
User
from
Acquisition
import
Implicit
from
App.config
import
getConfiguration
from
OFS.ObjectManager
import
ObjectManager
from
OFS.SimpleItem
import
SimpleItem
class
FauxRoot
(
Implicit
):
id
=
'/'
...
...
@@ -75,7 +76,7 @@ class ObjectManagerTests( unittest.TestCase ):
from
OFS.ObjectManager
import
ObjectManager
from
zope.interface.verify
import
verifyClass
verifyClass
(
IObjectManager
,
ObjectManager
,
1
)
verifyClass
(
IObjectManager
,
ObjectManager
)
def
test_setObject_set_owner_with_no_user
(
self
):
...
...
@@ -310,6 +311,7 @@ class ObjectManagerTests( unittest.TestCase ):
om2
.
_setObject
(
ob
.
getId
(),
ob
)
self
.
assertRaises
(
DeleteFailed
,
om1
.
_delObject
,
'om2'
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
ObjectManagerTests
)
)
...
...
lib/python/OFS/tests/testOrderSupport.py
View file @
a5ccd7a2
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
from
OFS.CopySupport
import
CopySource
from
OFS.ObjectManager
import
ObjectManager
...
...
@@ -55,7 +52,7 @@ class TestOrderSupport(unittest.TestCase):
from
OFS.OrderSupport
import
OrderSupport
from
zope.interface.verify
import
verifyClass
verifyClass
(
IOrderedContainer
,
OrderSupport
,
1
)
verifyClass
(
IOrderedContainer
,
OrderSupport
)
def
_doCanonTest
(
self
,
methodname
,
table
):
for
args
,
order
,
rval
in
table
:
...
...
lib/python/OFS/tests/testOrderedFolder.py
View file @
a5ccd7a2
...
...
@@ -19,9 +19,9 @@ class TestOrderedFolder(unittest.TestCase):
from
webdav.interfaces
import
IWriteLock
from
zope.interface.verify
import
verifyClass
verifyClass
(
IOrderedContainer
,
OrderedFolder
,
1
)
verifyClass
(
IOrderedFolder
,
OrderedFolder
,
1
)
verifyClass
(
IWriteLock
,
OrderedFolder
,
1
)
verifyClass
(
IOrderedContainer
,
OrderedFolder
)
verifyClass
(
IOrderedFolder
,
OrderedFolder
)
verifyClass
(
IWriteLock
,
OrderedFolder
)
def
test_suite
():
...
...
lib/python/OFS/tests/testProperties.py
View file @
a5ccd7a2
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -11,6 +10,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Properties unit tests.
$Id$
"""
import
unittest
...
...
@@ -28,7 +31,7 @@ class TestPropertyManager(unittest.TestCase):
from
OFS.PropertyManager
import
PropertyManager
from
zope.interface.verify
import
verifyClass
verifyClass
(
IPropertyManager
,
PropertyManager
,
1
)
verifyClass
(
IPropertyManager
,
PropertyManager
)
def
testLinesPropertyIsTuple
(
self
):
inst
=
self
.
_makeOne
()
...
...
lib/python/OFS/tests/testSimpleItem.py
View file @
a5ccd7a2
...
...
@@ -9,8 +9,8 @@ class TestItem(unittest.TestCase):
from
OFS.SimpleItem
import
Item
from
zope.interface.verify
import
verifyClass
verifyClass
(
IItem
,
Item
,
1
)
verifyClass
(
IManageable
,
Item
,
1
)
verifyClass
(
IItem
,
Item
)
verifyClass
(
IManageable
,
Item
)
class
TestItem_w__name__
(
unittest
.
TestCase
):
...
...
@@ -20,7 +20,7 @@ class TestItem_w__name__(unittest.TestCase):
from
OFS.SimpleItem
import
Item_w__name__
from
zope.interface.verify
import
verifyClass
verifyClass
(
IItemWithName
,
Item_w__name__
,
1
)
verifyClass
(
IItemWithName
,
Item_w__name__
)
class
TestSimpleItem
(
unittest
.
TestCase
):
...
...
@@ -30,7 +30,7 @@ class TestSimpleItem(unittest.TestCase):
from
OFS.SimpleItem
import
SimpleItem
from
zope.interface.verify
import
verifyClass
verifyClass
(
ISimpleItem
,
SimpleItem
,
1
)
verifyClass
(
ISimpleItem
,
SimpleItem
)
def
test_suite
():
...
...
lib/python/OFS/tests/testTraverse.py
View file @
a5ccd7a2
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -11,24 +10,26 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Traverse unit tests.
import
os
,
sys
,
unittest
import
string
,
cStringIO
,
re
$Id$
"""
import
unittest
import
cStringIO
import
ZODB
,
Acquisition
,
transaction
import
transaction
import
ZODB
,
Acquisition
,
transaction
from
AccessControl
import
SecurityManager
,
Unauthorized
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
Acquisition
import
aq_base
from
OFS.Application
import
Application
from
OFS.Folder
import
manage_addFolder
from
OFS.Image
import
manage_addFile
from
OFS.SimpleItem
import
SimpleItem
from
Testing.makerequest
import
makerequest
from
AccessControl
import
SecurityManager
,
Unauthorized
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
noSecurityManager
from
mimetools
import
Message
from
multifile
import
MultiFile
class
UnitTestSecurityPolicy
:
...
...
@@ -168,7 +169,7 @@ class TestTraverse( unittest.TestCase ):
from
OFS.Traversable
import
Traversable
from
zope.interface.verify
import
verifyClass
verifyClass
(
ITraversable
,
Traversable
,
1
)
verifyClass
(
ITraversable
,
Traversable
)
def
testTraversePath
(
self
):
self
.
failUnless
(
'file'
in
self
.
folder1
.
objectIds
()
)
...
...
lib/python/Products/PluginIndexes/common/PluggableIndex.py
View file @
a5ccd7a2
...
...
@@ -7,94 +7,28 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""Pluggable Index interfaces.
"""Pluggable Index Interface"""
__version__
=
'$Revision: 1.9 $'
[
11
:
-
2
]
$Id$
"""
import
Interface
class
PluggableIndexInterface
(
Interface
.
Base
):
# create PluggableIndexInterface, UniqueValueIndex, SortIndex
from
Interface.bridge
import
createZope3Bridge
from
Products.PluginIndexes.interfaces
import
IPluggableIndex
from
Products.PluginIndexes.interfaces
import
ISortIndex
from
Products.PluginIndexes.interfaces
import
IUniqueValueIndex
import
PluggableIndex
def
getId
():
"""Return Id of index."""
createZope3Bridge
(
IPluggableIndex
,
PluggableIndex
,
'PluggableIndexInterface'
)
createZope3Bridge
(
ISortIndex
,
PluggableIndex
,
'SortIndex'
)
createZope3Bridge
(
IUniqueValueIndex
,
PluggableIndex
,
'UniqueValueIndex'
)
def
getEntryForObject
(
documentId
,
default
=
None
):
"""Get all information contained for 'documentId'."""
def
getIndexSourceNames
():
""" return a sequence of attribute names that are indexed
by the index.
"""
def
index_object
(
documentId
,
obj
,
threshold
=
None
):
"""Index an object.
'documentId' is the integer ID of the document.
'obj' is the object to be indexed.
'threshold' is the number of words to process between committing
subtransactions. If None, subtransactions are disabled.
"""
def
unindex_object
(
documentId
):
"""Remove the documentId from the index."""
def
_apply_index
(
request
,
cid
=
''
):
"""Apply the index to query parameters given in 'request'.
The argument should be a mapping object.
If the request does not contain the needed parametrs, then
None is returned.
If the request contains a parameter with the name of the column
+ "_usage", it is sniffed for information on how to handle applying
the index. (Note: this style or parameters is deprecated)
If the request contains a parameter with the name of the
column and this parameter is either a Record or a class
instance then it is assumed that the parameters of this index
are passed as attribute (Note: this is the recommended way to
pass parameters since Zope 2.4)
Otherwise two objects are returned. The first object is a
ResultSet containing the record numbers of the matching
records. The second object is a tuple containing the names of
all data fields used.
"""
def
numObjects
():
"""Return the number of indexed objects"""
def
indexSize
():
"""Return the size of the index in terms of distinct values"""
def
clear
():
"""Empty the index"""
class
UniqueValueIndex
(
PluggableIndexInterface
):
"""An index which can return lists of unique values contained in it"""
def
hasUniqueValuesFor
(
name
):
"""Return true if the index can return the unique values for name"""
def
uniqueValues
(
name
=
None
,
withLengths
=
0
):
"""Return the unique values for name.
If 'withLengths' is true, returns a sequence of tuples of
(value, length)."""
class
SortIndex
(
PluggableIndexInterface
):
"""An index which may be used to sort a set of document ids"""
def
keyForDocument
(
documentId
):
"""Return the sort key that cooresponds to the specified document id
This method is no longer used by ZCatalog, but is left for backwards
compatibility."""
def
documentToKeyMap
():
"""Return an object that supports __getitem__ and may be used to quickly
lookup the sort key given a document id"""
del
createZope3Bridge
del
IPluggableIndex
del
ISortIndex
del
IUniqueValueIndex
del
PluggableIndex
lib/python/Products/PluginIndexes/interfaces.py
View file @
a5ccd7a2
...
...
@@ -19,8 +19,6 @@ from zope.interface import Interface
from
zope.schema
import
Bool
# XXX: copied from common.PluggableIndex.PluggableIndexInterface;
# should be bridged
class
IPluggableIndex
(
Interface
):
def
getId
():
...
...
@@ -30,8 +28,7 @@ class IPluggableIndex(Interface):
"""Get all information contained for 'documentId'."""
def
getIndexSourceNames
():
""" return a sequence of attribute names that are indexed
by the index.
"""Get a sequence of attribute names that are indexed by the index.
"""
def
index_object
(
documentId
,
obj
,
threshold
=
None
):
...
...
@@ -73,7 +70,7 @@ class IPluggableIndex(Interface):
def
numObjects
():
"""Return the number of indexed objects"""
# XXX:
this is currently broken
# XXX:
not implemented by TextIndex and TopicIndex
# def indexSize():
# """Return the size of the index in terms of distinct values"""
...
...
@@ -81,8 +78,6 @@ class IPluggableIndex(Interface):
"""Empty the index"""
# XXX: copied from from common.PluggableIndex.UniqueValueIndex;
# should be bridged
class
IUniqueValueIndex
(
IPluggableIndex
):
"""An index which can return lists of unique values contained in it"""
...
...
@@ -96,8 +91,6 @@ class IUniqueValueIndex(IPluggableIndex):
(value, length)."""
# XXX: copied from from common.PluggableIndex.SortIndex;
# should be bridged
class
ISortIndex
(
IPluggableIndex
):
"""An index which may be used to sort a set of document ids"""
...
...
lib/python/Products/ZCatalog/IZCatalog.py
View file @
a5ccd7a2
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -15,238 +14,13 @@
$Id$
"""
from
Interface
import
Interface
class
IZCatalog
(
Interface
):
"""ZCatalog object
# create IZCatalog
from
Interface.bridge
import
createZope3Bridge
from
interfaces
import
IZCatalog
as
z3IZCatalog
import
IZCatalog
A ZCatalog contains arbitrary index like references to Zope
objects. ZCatalog's can index object attribute using a variety
of "plug-in" index types.
createZope3Bridge
(
z3IZCatalog
,
IZCatalog
,
'IZCatalog'
)
Several index types are included, and others may be added.
Text -- Text indexes index textual content. The index can be
used to search for objects containing certain words.
Field -- Field indexes index atomic values. The index can be
used to search for objects that have certain properties.
Keyword -- Keyword indexes index sequences of values. The index
can be used to search for objects that match one or more of the
search terms.
Path -- Path indexes index URI paths. They allow you to find objects
based on their placement in a hierarchy.
Date -- Date indexes index date and type data. They are a type of field
index specifically optimized for indexing dates.
Date Range -- Date range indexes index time intervals. They are designed
for efficient searching of dates falling between two boundaries
(such as effective / expiration dates).
Topic -- Topic indexes store prefiltered sets of documents. They are used
to optimize complex queries into a single fast query by prefiltering
documents by an expression
The ZCatalog can maintain a table of extra data about cataloged
objects. This information can be used on search result pages to
show information about a search result.
The meta-data table schema is used to build the schema for
ZCatalog Result objects. The objects have the same attributes
as the column of the meta-data table.
ZCatalog does not store references to the objects themselves, but
rather to a unique identifier that defines how to get to the
object. In Zope, this unique identifier is the object's relative
path to the ZCatalog (since two Zope objects cannot have the same
URL, this is an excellent unique qualifier in Zope).
"""
def
catalog_object
(
obj
,
uid
,
idxs
=
None
,
update_metadata
=
1
):
"""Catalogs the object 'obj' with the unique identifier 'uid'.
The uid must be a physical path, either absolute or relative to
the catalog.
If provided, idxs specifies the names of indexes to update.
If update_metadata is specified (the default), the object's metadata
is updated. If it is not, the metadata is left untouched. This
flag has no effect if the object is not yet cataloged (metadata
is always added for new objects).
"""
def
uncatalog_object
(
uid
):
"""Uncatalogs the object with the unique identifier 'uid'.
The uid must be a physical path, either absolute or relative to
the catalog.
"""
def
uniqueValuesFor
(
name
):
"""returns the unique values for a given FieldIndex named 'name'.
"""
def
getpath
(
rid
):
"""Return the path to a cataloged object given a 'data_record_id_'
"""
def
getrid
(
rid
):
"""Return the 'data_record_id_' to a cataloged object given a path
"""
def
getobject
(
rid
,
REQUEST
=
None
):
"""Return a cataloged object given a 'data_record_id_'
"""
def
schema
():
"""Get the meta-data schema
Returns a sequence of names that correspond to columns in the
meta-data table.
"""
def
indexes
():
"""Returns a sequence of names that correspond to indexes.
"""
def
index_objects
():
"""Returns a sequence of actual index objects.
NOTE: This returns unwrapped indexes! You should probably use
getIndexObjects instead. Some indexes expect to be wrapped.
"""
def
getIndexObjects
():
"""Returns a list of acquisition wrapped index objects
"""
def
searchResults
(
REQUEST
=
None
,
**
kw
):
"""Search the catalog.
Search terms can be passed in the REQUEST or as keyword
arguments.
Search queries consist of a mapping of index names to search
parameters. You can either pass a mapping to searchResults as
the variable 'REQUEST' or you can use index names and search
parameters as keyword arguments to the method, in other words::
searchResults(title='Elvis Exposed',
author='The Great Elvonso')
is the same as::
searchResults({'title' : 'Elvis Exposed',
'author : 'The Great Elvonso'})
In these examples, 'title' and 'author' are indexes. This
query will return any objects that have the title *Elvis
Exposed* AND also are authored by *The Great Elvonso*. Terms
that are passed as keys and values in a searchResults() call
are implicitly ANDed together. To OR two search results, call
searchResults() twice and add concatenate the results like this::
results = ( searchResults(title='Elvis Exposed') +
searchResults(author='The Great Elvonso') )
This will return all objects that have the specified title OR
the specified author.
There are some special index names you can pass to change the
behavior of the search query:
sort_on -- This parameters specifies which index to sort the
results on.
sort_order -- You can specify 'reverse' or 'descending'.
Default behavior is to sort ascending.
sort_limit -- An optimization hint to tell the catalog how many
results you are really interested in. See the limit argument
to the search method for more details.
There are some rules to consider when querying this method:
- an empty query mapping (or a bogus REQUEST) returns all
items in the catalog.
- results from a query involving only field/keyword
indexes, e.g. {'id':'foo'} and no 'sort_on' will be
returned unsorted.
- results from a complex query involving a field/keyword
index *and* a text index,
e.g. {'id':'foo','PrincipiaSearchSource':'bar'} and no
'sort_on' will be returned unsorted.
- results from a simple text index query
e.g.{'PrincipiaSearchSource':'foo'} will be returned
sorted in descending order by 'score'. A text index
cannot beused as a 'sort_on' parameter, and attempting
to do so will raise an error.
Depending on the type of index you are querying, you may be
able to provide more advanced search parameters that can
specify range searches or wildcards. These features are
documented in The Zope Book.
"""
def
__call__
(
REQUEST
=
None
,
**
kw
):
"""Search the catalog, the same way as 'searchResults'.
"""
def
search
(
query_request
,
sort_index
=
None
,
reverse
=
0
,
limit
=
None
,
merge
=
1
):
"""Programmatic search interface, use for searching the catalog from
scripts.
query_request -- Dictionary containing catalog query. This uses the
same format as searchResults.
sort_index -- Name of sort index
reverse -- Boolean, reverse sort order (defaults to false)
limit -- Limit sorted result count to the n best records. This is an
optimization hint used in conjunction with a sort_index. If possible
ZCatalog will use a different sort algorithm that uses much less memory
and scales better then a full sort. The actual number of records
returned is not guaranteed to be <= limit. You still need to apply the
same batching to the results. Since the len() of the results will no
longer be the actual result count, you can use the
"actual_result_count" attribute of the lazy result object instead to
determine the size of the full result set.
merge -- Return merged, lazy results (like searchResults) or raw
results for later merging. This can be used to perform multiple
queries (even across catalogs) and merge and sort the combined results.
"""
def
refreshCatalog
(
clear
=
0
,
pghandler
=
None
):
"""Reindex every object we can find, removing the unreachable
ones from the index.
clear -- values: 1|0 clear the catalog before reindexing
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
def
reindexIndex
(
name
,
REQUEST
,
pghandler
=
None
):
"""Reindex a single index.
name -- id of index
REQUEST -- REQUEST object
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
__doc__
=
IZCatalog
.
__doc__
+
__doc__
del
createZope3Bridge
del
z3IZCatalog
lib/python/Products/ZCatalog/interfaces.py
View file @
a5ccd7a2
...
...
@@ -18,8 +18,6 @@ $Id$
from
zope.interface
import
Interface
# XXX: copied from IZCatalog.IZCatalog;
# should be bridged
class
IZCatalog
(
Interface
):
"""ZCatalog object
...
...
@@ -66,7 +64,6 @@ class IZCatalog(Interface):
object. In Zope, this unique identifier is the object's relative
path to the ZCatalog (since two Zope objects cannot have the same
URL, this is an excellent unique qualifier in Zope).
"""
def
catalog_object
(
obj
,
uid
,
idxs
=
None
,
update_metadata
=
1
):
...
...
@@ -111,7 +108,6 @@ class IZCatalog(Interface):
Returns a sequence of names that correspond to columns in the
meta-data table.
"""
def
indexes
():
...
...
@@ -198,7 +194,6 @@ class IZCatalog(Interface):
able to provide more advanced search parameters that can
specify range searches or wildcards. These features are
documented in The Zope Book.
"""
def
__call__
(
REQUEST
=
None
,
**
kw
):
...
...
lib/python/webdav/Collection.py
View file @
a5ccd7a2
...
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""WebDAV support - collection objects.
...
...
@@ -15,22 +15,31 @@
$Id$
"""
import
Globals
,
davcmds
,
Lockable
from
common
import
urlfix
,
rfc1123_date
from
Resource
import
Resource
from
AccessControl
import
getSecurityManager
from
urllib
import
unquote
import
Globals
from
AccessControl
import
getSecurityManager
from
zExceptions
import
MethodNotAllowed
,
NotFound
from
webdav.common
import
Locked
,
PreconditionFailed
from
zope.interface
import
implements
import
davcmds
import
Lockable
from
common
import
Locked
,
PreconditionFailed
from
common
import
urlfix
,
rfc1123_date
from
interfaces
import
IDAVCollection
from
Resource
import
Resource
class
Collection
(
Resource
):
"""The Collection class provides basic WebDAV support for
collection objects. It provides default implementations
for all supported WebDAV HTTP methods. The behaviors of some
WebDAV HTTP methods for collections are slightly different
than those for non-collection resources."""
implements
(
IDAVCollection
)
__dav_collection__
=
1
def
dav__init
(
self
,
request
,
response
):
...
...
lib/python/webdav/Resource.py
View file @
a5ccd7a2
...
...
@@ -7,10 +7,9 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
"""WebDAV support - resource objects.
$Id$
...
...
@@ -20,29 +19,36 @@ import sys
import
mimetypes
from
urllib
import
unquote
import
Globals
import
ExtensionClass
from
Acquisition
import
aq_base
import
Globals
from
AccessControl
import
getSecurityManager
from
ZPublisher.HTTPRangeSupport
import
HTTPRangeInterface
from
zExceptions
import
Unauthorized
,
Forbidden
from
Acquisition
import
aq_base
from
zExceptions
import
BadRequest
,
MethodNotAllowed
from
zExceptions
import
Unauthorized
,
Forbidden
from
zope.interface
import
implements
from
ZPublisher.HTTPRangeSupport
import
HTTPRangeInterface
from
WriteLockInterface
import
WriteLockInterface
import
davcmds
import
Lockable
from
common
import
absattr
,
urlfix
,
rfc1123_date
,
tokenFinder
,
urlbase
from
common
import
IfParser
from
common
import
isDavCollection
from
common
import
Locked
,
Conflict
,
PreconditionFailed
import
davcmds
from
interfaces
import
IDAVResource
from
interfaces
import
IWriteLock
from
WriteLockInterface
import
WriteLockInterface
class
Resource
(
ExtensionClass
.
Base
,
Lockable
.
LockableItem
):
"""The Resource mixin class provides basic WebDAV support for
non-collection objects. It provides default implementations
for most supported WebDAV HTTP methods, however certain methods
such as PUT should be overridden to ensure correct behavior in
the context of the object type."""
implements
(
IDAVResource
,
IWriteLock
)
__dav_resource__
=
1
__http_methods__
=
(
'GET'
,
'HEAD'
,
'POST'
,
'PUT'
,
'DELETE'
,
'OPTIONS'
,
...
...
@@ -598,5 +604,4 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem):
def
listDAVObjects
(
self
):
return
[]
Globals
.
default__class_init__
(
Resource
)
lib/python/webdav/WriteLockInterface.py
View file @
a5ccd7a2
...
...
@@ -19,6 +19,7 @@ from Interface import Interface
class
LockItemInterface
(
Interface
):
"""A LockItem contains information about a lock.
This includes:
...
...
@@ -144,71 +145,12 @@ class LockItemInterface(Interface):
used when returning the value of a newly created lock. """
class
WriteLockInterface
(
Interface
):
"""Basic protocol needed to support the write lock machinery.
It must be able to answer the questions:
o Is the object locked?
o Is the lock owned by the current user?
o What lock tokens are associated with the current object?
o What is their state (how long until they're supposed to time out?,
what is their depth? what type are they?
And it must be able to do the following:
o Grant a write lock on the object to a specified user.
- *If lock depth is infinite, this must also grant locks on **all**
subobjects, or fail altogether*
o Revoke a lock on the object.
- *If lock depth is infinite, this must also revoke locks on all
subobjects*
**All methods in the WriteLock interface that deal with checking valid
locks MUST check the timeout values on the lockitem (ie, by calling
'lockitem.isValid()'), and DELETE the lock if it is no longer valid**
"""
def
wl_lockItems
(
killinvalids
=
0
):
""" Returns (key, value) pairs of locktoken, lock.
if 'killinvalids' is true, invalid locks (locks whose timeout
has been exceeded) will be deleted"""
def
wl_lockValues
(
killinvalids
=
0
):
""" Returns a sequence of locks. if 'killinvalids' is true,
invalid locks will be deleted"""
def
wl_lockTokens
(
killinvalids
=
0
):
""" Returns a sequence of lock tokens. if 'killinvalids' is true,
invalid locks will be deleted"""
def
wl_hasLock
(
token
,
killinvalids
=
0
):
""" Returns true if the lock identified by the token is attached
to the object. """
def
wl_isLocked
():
""" Returns true if 'self' is locked at all. If invalid locks
still exist, they should be deleted."""
def
wl_setLock
(
locktoken
,
lock
):
""" Store the LockItem, 'lock'. The locktoken will be used to fetch
and delete the lock. If the lock exists, this MUST
overwrite it if all of the values except for the 'timeout' on the
old and new lock are the same. """
def
wl_getLock
(
locktoken
):
""" Returns the locktoken identified by the locktokenuri """
# create WriteLockInterface
from
Interface.bridge
import
createZope3Bridge
from
interfaces
import
IWriteLock
import
WriteLockInterface
def
wl_delLock
(
locktoken
):
""" Deletes the locktoken identified by the locktokenuri """
createZope3Bridge
(
IWriteLock
,
WriteLockInterface
,
'WriteLockInterface'
)
def
wl_clearLocks
():
""" Deletes ALL DAV locks on the object - should only be called
by lock management machinery. """
del
createZope3Bridge
del
IWriteLock
lib/python/webdav/interfaces.py
View file @
a5ccd7a2
...
...
@@ -19,16 +19,75 @@ from zope.interface import Interface
from
zope.schema
import
Bool
,
Tuple
# create IWriteLock
from
Products.Five.fiveconfigure
import
createZope2Bridge
from
webdav.WriteLockInterface
import
WriteLockInterface
import
interfaces
class
IWriteLock
(
Interface
):
createZope2Bridge
(
WriteLockInterface
,
interfaces
,
'IWriteLock'
)
"""Basic protocol needed to support the write lock machinery.
del
createZope2Bridge
del
WriteLockInterface
del
interfaces
It must be able to answer the questions:
o Is the object locked?
o Is the lock owned by the current user?
o What lock tokens are associated with the current object?
o What is their state (how long until they're supposed to time out?,
what is their depth? what type are they?
And it must be able to do the following:
o Grant a write lock on the object to a specified user.
- *If lock depth is infinite, this must also grant locks on **all**
subobjects, or fail altogether*
o Revoke a lock on the object.
- *If lock depth is infinite, this must also revoke locks on all
subobjects*
**All methods in the WriteLock interface that deal with checking valid
locks MUST check the timeout values on the lockitem (ie, by calling
'lockitem.isValid()'), and DELETE the lock if it is no longer valid**
"""
def
wl_lockItems
(
killinvalids
=
0
):
""" Returns (key, value) pairs of locktoken, lock.
if 'killinvalids' is true, invalid locks (locks whose timeout
has been exceeded) will be deleted"""
def
wl_lockValues
(
killinvalids
=
0
):
""" Returns a sequence of locks. if 'killinvalids' is true,
invalid locks will be deleted"""
def
wl_lockTokens
(
killinvalids
=
0
):
""" Returns a sequence of lock tokens. if 'killinvalids' is true,
invalid locks will be deleted"""
def
wl_hasLock
(
token
,
killinvalids
=
0
):
""" Returns true if the lock identified by the token is attached
to the object. """
def
wl_isLocked
():
""" Returns true if 'self' is locked at all. If invalid locks
still exist, they should be deleted."""
def
wl_setLock
(
locktoken
,
lock
):
""" Store the LockItem, 'lock'. The locktoken will be used to fetch
and delete the lock. If the lock exists, this MUST
overwrite it if all of the values except for the 'timeout' on the
old and new lock are the same. """
def
wl_getLock
(
locktoken
):
""" Returns the locktoken identified by the locktokenuri """
def
wl_delLock
(
locktoken
):
""" Deletes the locktoken identified by the locktokenuri """
def
wl_clearLocks
():
""" Deletes ALL DAV locks on the object - should only be called
by lock management machinery. """
# XXX: might contain non-API methods and outdated comments;
...
...
lib/python/webdav/tests/testCollection.py
View file @
a5ccd7a2
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
class
TestCollection
(
unittest
.
TestCase
):
...
...
@@ -11,7 +8,7 @@ class TestCollection(unittest.TestCase):
from
webdav.interfaces
import
IDAVCollection
from
zope.interface.verify
import
verifyClass
verifyClass
(
IDAVCollection
,
Collection
,
1
)
verifyClass
(
IDAVCollection
,
Collection
)
def
test_suite
():
...
...
lib/python/webdav/tests/testNullResource.py
View file @
a5ccd7a2
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
class
TestLockNullResource
(
unittest
.
TestCase
):
...
...
@@ -18,7 +15,7 @@ class TestLockNullResource(unittest.TestCase):
from
webdav.NullResource
import
LockNullResource
from
zope.interface.verify
import
verifyClass
verifyClass
(
IWriteLock
,
LockNullResource
,
1
)
verifyClass
(
IWriteLock
,
LockNullResource
)
class
TestNullResource
(
unittest
.
TestCase
):
...
...
@@ -35,7 +32,7 @@ class TestNullResource(unittest.TestCase):
from
webdav.NullResource
import
NullResource
from
zope.interface.verify
import
verifyClass
verifyClass
(
IWriteLock
,
NullResource
,
1
)
verifyClass
(
IWriteLock
,
NullResource
)
def
test_suite
():
...
...
lib/python/webdav/tests/testResource.py
View file @
a5ccd7a2
import
unittest
import
Testing
import
Zope2
Zope2
.
startup
()
class
TestResource
(
unittest
.
TestCase
):
def
test_z3interfaces
(
self
):
from
webdav.interfaces
import
IDAVResource
from
webdav.interfaces
import
IWriteLock
from
webdav.Resource
import
Resource
from
zope.interface.verify
import
verifyClass
verifyClass
(
IDAVResource
,
Resource
,
1
)
verifyClass
(
IDAVResource
,
Resource
)
verifyClass
(
IWriteLock
,
Resource
)
def
test_suite
():
...
...
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