[Zope-Checkins] SVN: Zope/trunk/lib/python/ Some cosmetic changes
(in preparation for creating z3 interfaces):
Yvo Schubbe
y.2005- at wcm-solutions.de
Sun May 15 11:56:18 EDT 2005
Log message for revision 30356:
Some cosmetic changes (in preparation for creating z3 interfaces):
- docstring cleanup
- whitespace cleanup
- import cleanup
Changed:
UU Zope/trunk/lib/python/AccessControl/Owned.py
UU Zope/trunk/lib/python/AccessControl/PermissionMapping.py
UU Zope/trunk/lib/python/AccessControl/Role.py
UU Zope/trunk/lib/python/OFS/Application.py
UU Zope/trunk/lib/python/OFS/CopySupport.py
UU Zope/trunk/lib/python/OFS/ObjectManager.py
UU Zope/trunk/lib/python/OFS/PropertyManager.py
UU Zope/trunk/lib/python/OFS/SimpleItem.py
UU Zope/trunk/lib/python/OFS/Traversable.py
UU Zope/trunk/lib/python/webdav/Collection.py
UU Zope/trunk/lib/python/webdav/EtagSupport.py
UU Zope/trunk/lib/python/webdav/Lockable.py
UU Zope/trunk/lib/python/webdav/WriteLockInterface.py
-=-
Modified: Zope/trunk/lib/python/AccessControl/Owned.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/Owned.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/AccessControl/Owned.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -19,6 +19,7 @@
from AccessControl import getSecurityManager, Unauthorized
from Acquisition import aq_get, aq_parent, aq_base
+
UnownableOwner=[]
def ownableFilter(self):
_owner = aq_get(self, '_owner', None, 1)
@@ -137,10 +138,12 @@
changeOwnership__roles__=()
def changeOwnership(self, user, recursive=0):
- """Change the ownership to the given user. If 'recursive' is
- true then also take ownership of all sub-objects, otherwise
- sub-objects retain their ownership information."""
+ """Change the ownership to the given user.
+ If 'recursive' is true then also take ownership of all sub-objects,
+ otherwise sub-objects retain their ownership information.
+ """
+
new=ownerInfo(user)
if new is None: return # Special user!
old = self.getOwnerTuple()
@@ -167,10 +170,10 @@
return security.checkPermission('Take ownership', self)
def manage_takeOwnership(self, REQUEST, RESPONSE, recursive=0):
+ """Take ownership (responsibility) for an object.
+
+ If 'recursive' is true, then also take ownership of all sub-objects.
"""
- Take ownership (responsibility) for an object. If 'recursive'
- is true, then also take ownership of all sub-objects.
- """
security=getSecurityManager()
want_referer=REQUEST['URL1']+'/manage_owner'
got_referer=("%s://%s%s" %
@@ -261,13 +264,16 @@
except: pass
if s is None: object._p_deactivate()
-
Globals.default__class_init__(Owned)
+
class EmergencyUserCannotOwn(Exception):
+
"The emergency user cannot own anything"
+
class EditUnowned(Exception):
+
"Can't edit unowned executables"
Property changes on: Zope/trunk/lib/python/AccessControl/Owned.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.24
Modified: Zope/trunk/lib/python/AccessControl/PermissionMapping.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/PermissionMapping.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/AccessControl/PermissionMapping.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -15,15 +15,21 @@
Sometimes, we need an object's permissions to be remapped to other permissions
when the object is used in specual ways. This is rather hard, since we
need the object's ordinary permissions intact so we can manage it.
+
+$Id$
"""
+from cgi import escape
+
import ExtensionClass, Acquisition
-from Permission import pname
-from Owned import UnownableOwner
from Globals import InitializeClass
-from cgi import escape
+from Owned import UnownableOwner
+from Permission import pname
+
+
class RoleManager:
+
def manage_getPermissionMapping(self):
"""Return the permission mapping for the object
@@ -96,7 +102,9 @@
base=getattr(p, 'aq_base', None)
return type(base) is PermissionMapper
+InitializeClass(RoleManager)
+
def getPermissionMapping(name, obj, st=type('')):
obj=getattr(obj, 'aq_base', obj)
name=pname(name)
@@ -148,5 +156,3 @@
Acquisition.ImplicitAcquisitionWrapper(
w, parent))
return apply(self, args, kw)
-
-InitializeClass(RoleManager)
Property changes on: Zope/trunk/lib/python/AccessControl/PermissionMapping.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.14
Name: svn:keywords
+ Id
Modified: Zope/trunk/lib/python/AccessControl/Role.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/Role.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/AccessControl/Role.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -14,14 +14,16 @@
$Id$
"""
+from cgi import escape
+
from Globals import DTMLFile, MessageDialog, Dictionary
from Acquisition import Implicit, Acquired, aq_get
import Globals, ExtensionClass, PermissionMapping, Products
-from Permission import Permission
from App.Common import aq_base
-from cgi import escape
+from Permission import Permission
+
DEFAULTMAXLISTUSERS=250
def _isBeingUsedAsAMethod(self):
@@ -30,7 +32,9 @@
def _isNotBeingUsedAsAMethod(self):
return not aq_get(self, '_isBeingUsedAsAMethod_', 0)
+
class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
+
"""An object that has configurable permissions"""
__ac_permissions__=(
@@ -89,9 +93,10 @@
return tuple(r)
def permission_settings(self, permission=None):
- """Return user-role permission settings. If 'permission'
- is passed to the method then only the settings for 'permission'
- is returned.
+ """Return user-role permission settings.
+
+ If 'permission' is passed to the method then only the settings for
+ 'permission' is returned.
"""
result=[]
valid=self.valid_roles()
@@ -127,7 +132,8 @@
help_product='OFSP')
def manage_role(self, role_to_manage, permissions=[], REQUEST=None):
- "Change the permissions given to the given role"
+ """Change the permissions given to the given role.
+ """
self._isBeingUsedAsAMethod(REQUEST, 0)
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
@@ -142,7 +148,8 @@
help_product='OFSP')
def manage_acquiredPermissions(self, permissions=[], REQUEST=None):
- "Change the permissions that acquire"
+ """Change the permissions that acquire.
+ """
self._isBeingUsedAsAMethod(REQUEST, 0)
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
@@ -161,11 +168,12 @@
def manage_permission(self, permission_to_manage,
roles=[], acquire=0, REQUEST=None):
- """Change the settings for the given permission
+ """Change the settings for the given permission.
If optional arg acquire is true, then the roles for the permission
are acquired, in addition to the ones specified, otherwise the
- permissions are restricted to only the designated roles."""
+ permissions are restricted to only the designated roles.
+ """
self._isBeingUsedAsAMethod(REQUEST, 0)
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
@@ -186,7 +194,8 @@
_method_manage_access=DTMLFile('dtml/methodAccess', globals())
def manage_access(self, REQUEST, **kw):
- "Return an interface for making permissions settings"
+ """Return an interface for making permissions settings.
+ """
if hasattr(self, '_isBeingUsedAsAMethod') and \
self._isBeingUsedAsAMethod():
return apply(self._method_manage_access,(), kw)
@@ -194,7 +203,8 @@
return apply(self._normal_manage_access,(), kw)
def manage_changePermissions(self, REQUEST):
- "Change all permissions settings, called by management screen"
+ """Change all permissions settings, called by management screen.
+ """
self._isBeingUsedAsAMethod(REQUEST, 0)
valid_roles=self.valid_roles()
indexes=range(len(valid_roles))
@@ -223,9 +233,9 @@
message='Your changes have been saved',
action ='manage_access')
-
def permissionsOfRole(self, role):
- "used by management screen"
+ """Used by management screen.
+ """
r=[]
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
@@ -237,7 +247,8 @@
return r
def rolesOfPermission(self, permission):
- "used by management screen"
+ """Used by management screen.
+ """
valid_roles=self.valid_roles()
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
@@ -255,7 +266,8 @@
"The permission <em>%s</em> is invalid." % escape(permission))
def acquiredRolesAreUsedBy(self, permission):
- "used by management screen"
+ """Used by management screen.
+ """
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
if name==permission:
@@ -380,14 +392,12 @@
stat='Your changes have been saved.'
return self.manage_listLocalRoles(self, REQUEST, stat=stat)
-
-
-
#------------------------------------------------------------
access_debug_info__roles__=()
def access_debug_info(self):
- "Return debug info"
+ """Return debug info.
+ """
clas=class_attrs(self)
inst=instance_attrs(self)
data=[]
@@ -407,7 +417,8 @@
return data
def valid_roles(self):
- "Return list of valid roles"
+ """Return list of valid roles.
+ """
obj=self
dict={}
dup =dict.has_key
@@ -427,7 +438,8 @@
return tuple(roles)
def validate_roles(self, roles):
- "Return true if all given roles are valid"
+ """Return true if all given roles are valid.
+ """
valid=self.valid_roles()
for role in roles:
if role not in valid:
@@ -435,17 +447,18 @@
return 1
def userdefined_roles(self):
- "Return list of user-defined roles"
+ """Return list of user-defined roles.
+ """
roles=list(self.__ac_roles__)
for role in classattr(self.__class__,'__ac_roles__'):
try: roles.remove(role)
except: pass
return tuple(roles)
+ def manage_defined_roles(self, submit=None, REQUEST=None):
+ """Called by management screen.
+ """
- def manage_defined_roles(self,submit=None,REQUEST=None):
- """Called by management screen."""
-
if submit=='Add Role':
role=reqattr(REQUEST, 'role')
return self._addRole(role, REQUEST)
@@ -473,7 +486,6 @@
if REQUEST is not None:
return self.manage_access(REQUEST)
-
def _delRoles(self, roles, REQUEST=None):
if not roles:
return MessageDialog(
@@ -488,21 +500,19 @@
if REQUEST is not None:
return self.manage_access(REQUEST)
-
def _has_user_defined_role(self, role):
return role in self.__ac_roles__
-
# Compatibility names only!!
smallRolesWidget=selectedRoles=aclAChecked=aclPChecked=aclEChecked=''
validRoles=valid_roles
#manage_rolesForm=manage_access
- def manage_editRoles(self,REQUEST,acl_type='A',acl_roles=[]):
+ def manage_editRoles(self, REQUEST, acl_type='A', acl_roles=[]):
pass
- def _setRoles(self,acl_type,acl_roles):
+ def _setRoles(self, acl_type, acl_roles):
pass
def possible_permissions(self):
@@ -520,7 +530,6 @@
return d
-
Globals.default__class_init__(RoleManager)
Property changes on: Zope/trunk/lib/python/AccessControl/Role.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.61
Modified: Zope/trunk/lib/python/OFS/Application.py
===================================================================
--- Zope/trunk/lib/python/OFS/Application.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/OFS/Application.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -15,33 +15,37 @@
$Id$
"""
-import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
-import time, traceback, os, Products
-from DateTime import DateTime
+import os, sys, traceback
+from cgi import escape
+from StringIO import StringIO
+
+import Globals, Products, App.Product, App.ProductRegistry, misc_
+import transaction
from AccessControl.User import UserFolder
+from Acquisition import aq_base
from App.ApplicationManager import ApplicationManager
-from webdav.NullResource import NullResource
-from FindSupport import FindSupport
-from cgi import escape
-from urllib import quote
-from StringIO import StringIO
-from AccessControl.PermissionRole import PermissionRole
+from App.config import getConfiguration
+from App.Product import doInstall
from App.ProductContext import ProductContext
+from DateTime import DateTime
+from HelpSys.HelpSys import HelpSys
from misc_ import Misc_
-import ZDOM
+from webdav.NullResource import NullResource
+from zExceptions import Redirect as RedirectException, Forbidden
from zLOG import LOG, ERROR, WARNING, INFO
-from zExceptions import Redirect as RedirectException, Forbidden
-from HelpSys.HelpSys import HelpSys
-from Acquisition import aq_base
-from App.Product import doInstall
-from App.config import getConfiguration
-import transaction
+import Folder
+import ZDOM
+from FindSupport import FindSupport
+
+
class Application(Globals.ApplicationDefaultPermissions,
ZDOM.Root, Folder.Folder,
App.ProductRegistry.ProductRegistry, FindSupport):
+
"""Top-level system object"""
- title ='Zope'
+
+ title ='Zope'
#__roles__=['Manager', 'Anonymous']
__defined_roles__=('Manager','Anonymous','Owner')
web__form__method='GET'
@@ -70,9 +74,6 @@
_initializer_registry = None
- def title_and_id(self): return self.title
- def title_or_id(self): return self.title
-
def __init__(self):
# Initialize users
uf=UserFolder()
@@ -89,15 +90,23 @@
try: return self.REQUEST['SCRIPT_NAME'][1:]
except: return self.title
- def __class_init__(self): Globals.default__class_init__(self)
+ def title_and_id(self):
+ return self.title
- def PrincipiaRedirect(self,destination,URL1):
+ def title_or_id(self):
+ return self.title
+
+ def __class_init__(self):
+ Globals.default__class_init__(self)
+
+ def PrincipiaRedirect(self, destination, URL1):
"""Utility function to allow user-controlled redirects"""
if destination.find('//') >= 0:
raise RedirectException, destination
raise RedirectException, ("%s/%s" % (URL1, destination))
- Redirect=ZopeRedirect=PrincipiaRedirect
+ Redirect = ZopeRedirect = PrincipiaRedirect
+
def __bobo_traverse__(self, REQUEST, name=None):
try: return getattr(self, name)
@@ -117,8 +126,9 @@
def PrincipiaTime(self, *args):
"""Utility function to return current date/time"""
return apply(DateTime, args)
- ZopeTime=PrincipiaTime
+ ZopeTime = PrincipiaTime
+
ZopeAttributionButton__roles__=None
def ZopeAttributionButton(self):
"""Returns an HTML fragment that displays the 'powered by zope'
@@ -139,10 +149,11 @@
raise Forbidden, 'This resource cannot be moved.'
test_url___allow_groups__=None
- test_url=ZopeAttributionButton
+ test_url = ZopeAttributionButton
def absolute_url(self, relative=0):
- '''The absolute URL of the root object is BASE1 or "/".'''
+ """The absolute URL of the root object is BASE1 or "/".
+ """
if relative: return ''
try:
# Take advantage of computed URL cache
@@ -151,26 +162,32 @@
return '/'
def absolute_url_path(self):
- '''The absolute URL path of the root object is BASEPATH1 or "/".'''
+ """The absolute URL path of the root object is BASEPATH1 or "/".
+ """
try:
return self.REQUEST['BASEPATH1'] or '/'
except (AttributeError, KeyError):
return '/'
def virtual_url_path(self):
- '''The virtual URL path of the root object is empty.'''
+ """The virtual URL path of the root object is empty.
+ """
return ''
+ def getPhysicalRoot(self):
+ return self
+
def getPhysicalPath(self):
- '''Returns a path that can be used to access this object again
- later, for example in a copy/paste operation. Designed to
- be used with getPhysicalRoot().
- '''
+ """Get the physical path of the object.
+
+ Returns a path (an immutable sequence of strings) that can be used to
+ access this object again later, for example in a copy/paste operation.
+ getPhysicalRoot() and getPhysicalPath() are designed to operate
+ together.
+ """
# We're at the base of the path.
return ('',)
- def getPhysicalRoot(self): return self
-
fixupZClassDependencies__roles__=()
def fixupZClassDependencies(self, rebuild=0):
# Note that callers should not catch exceptions from this method
@@ -258,7 +275,9 @@
reg = {}
return reg.get(flag)
+
class Expired(Globals.Persistent):
+
icon='p_/broken'
def __setstate__(self, s={}):
@@ -279,7 +298,9 @@
initializer = AppInitializer(app)
initializer.initialize()
+
class AppInitializer:
+
""" Initialze an Application object (called at startup) """
def __init__(self, app):
@@ -880,9 +901,8 @@
def removeProductMetaTypes(pid):
- '''
- Unregisters the meta types registered by a product.
- '''
+ """Unregisters the meta types registered by a product.
+ """
meta_types = Products.meta_types
new_mts = []
changed = 0
Property changes on: Zope/trunk/lib/python/OFS/Application.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.201
Modified: Zope/trunk/lib/python/OFS/CopySupport.py
===================================================================
--- Zope/trunk/lib/python/OFS/CopySupport.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/OFS/CopySupport.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -14,27 +14,32 @@
$Id$
"""
-import re, sys, Globals, Moniker, tempfile, ExtensionClass
+
+import re, sys, tempfile
+from cgi import escape
from marshal import loads, dumps
from urllib import quote, unquote
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 webdav.Lockable import ResourceLockedError
-from cgi import escape
-import transaction
CopyError='Copy Error'
copy_re = re.compile('^copy([0-9]*)_of_(.*)')
_marker=[]
+
+
class CopyContainer(ExtensionClass.Base):
+
"""Interface for containerish objects which allow cut/copy/paste"""
__ac_permissions__=(
@@ -48,8 +53,12 @@
# The following three methods should be overridden to store sub-objects
# as non-attributes.
- def _setOb(self, id, object): setattr(self, id, object)
- def _delOb(self, id): delattr(self, id)
+ def _setOb(self, id, object):
+ setattr(self, id, object)
+
+ def _delOb(self, id):
+ delattr(self, id)
+
def _getOb(self, id, default=_marker):
if hasattr(aq_base(self), id):
return getattr(self, id)
@@ -136,9 +145,11 @@
def manage_pasteObjects(self, cb_copy_data=None, REQUEST=None):
"""Paste previously copied objects into the current object.
- If calling manage_pasteObjects from python code, pass
- the result of a previous call to manage_cutObjects or
- manage_copyObjects as the first argument."""
+
+ If calling manage_pasteObjects from python code, pass the result of a
+ previous call to manage_cutObjects or manage_copyObjects as the first
+ argument.
+ """
cp=None
if cb_copy_data is not None:
cp=cb_copy_data
@@ -421,6 +432,7 @@
class CopySource(ExtensionClass.Base):
+
"""Interface for objects which allow themselves to be copied."""
# declare a dummy permission for Copy or Move here that we check
@@ -430,14 +442,18 @@
)
def _canCopy(self, op=0):
- """Called to make sure this object is copyable. The op var
- is 0 for a copy, 1 for a move."""
+ """Called to make sure this object is copyable.
+
+ The op var is 0 for a copy, 1 for a move.
+ """
return 1
def _notifyOfCopyTo(self, container, op=0):
- """Overide this to be pickly about where you go! If you dont
- want to go there, raise an exception. The op variable is
- 0 for a copy, 1 for a move."""
+ """Overide this to be pickly about where you go!
+
+ If you dont want to go there, raise an exception. The op variable is 0
+ for a copy, 1 for a move.
+ """
pass
def _getCopy(self, container):
Property changes on: Zope/trunk/lib/python/OFS/CopySupport.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.91
Modified: Zope/trunk/lib/python/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/lib/python/OFS/ObjectManager.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/OFS/ObjectManager.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -14,32 +14,33 @@
$Id$
"""
-import App.Management, Acquisition, Globals, CopySupport, Products
-import os, App.FactoryDispatcher, re, Products
-from OFS.Traversable import Traversable
-from OFS import SimpleItem
+
+import sys, fnmatch, copy, os, re
+import marshal
+from cgi import escape
+from cStringIO import StringIO
+from types import StringType, UnicodeType
+
+import App.Management, Acquisition, Globals, Products
+import App.FactoryDispatcher, Products
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 AccessControl.SecurityInfo import ClassSecurityInfo
from webdav.Lockable import ResourceLockedError
from ZODB.POSException import ConflictError
-from urllib import quote
-from cStringIO import StringIO
-import marshal
import App.Common
from App.config import getConfiguration
from AccessControl import getSecurityManager
from AccessControl.ZopeSecurityPolicy import getRoles
from zLOG import LOG, ERROR
from zExceptions import BadRequest
-import sys,fnmatch,copy
-from cgi import escape
-from types import StringType, UnicodeType
+from OFS.Traversable import Traversable
+import CopySupport
+
# the name BadRequestException is relied upon by 3rd-party code
BadRequestException = BadRequest
@@ -92,10 +93,20 @@
raise BadRequest, (
'The id "%s" contains characters illegal in URLs.' % id)
-class BeforeDeleteException( Exception ): pass # raise to veto deletion
-class BreakoutException ( Exception ): pass # raised to break out of loops
+class BeforeDeleteException(Exception):
+
+ pass # raise to veto deletion
+
+
+class BreakoutException(Exception):
+
+ pass # raised to break out of loops
+
+
_marker=[]
+
+
class ObjectManager(
CopySupport.CopyContainer,
App.Management.Navigation,
@@ -105,6 +116,7 @@
Collection,
Traversable,
):
+
"""Generic object manager
This class provides core behavior for collections of heterogeneous objects.
@@ -125,11 +137,11 @@
)
- meta_type ='Object Manager'
+ meta_type = 'Object Manager'
meta_types=() # Sub-object types that are specific to this object
- _objects =()
+ _objects = ()
manage_main=DTMLFile('dtml/main', globals())
manage_index_main=DTMLFile('dtml/index_main', globals())
@@ -232,8 +244,12 @@
_checkId = checkValidId
- def _setOb(self, id, object): setattr(self, id, object)
- def _delOb(self, id): delattr(self, id)
+ def _setOb(self, id, object):
+ setattr(self, id, object)
+
+ def _delOb(self, id):
+ delattr(self, id)
+
def _getOb(self, id, default=_marker):
# FIXME: what we really need to do here is ensure that only
# sub-items are returned. That could have a measurable hit
@@ -245,7 +261,7 @@
raise AttributeError, id
return default
- def _setObject(self,id,object,roles=None,user=None, set_owner=1):
+ def _setObject(self, id, object, roles=None, user=None, set_owner=1):
v=self._checkId(id)
if v is not None: id=v
try: t=object.meta_type
@@ -353,14 +369,12 @@
return set
return [ o['id'] for o in self._objects ]
-
def objectValues(self, spec=None):
# Returns a list of actual subobjects of the current object.
# If 'spec' is specified, returns only objects whose meta_type
# match 'spec'.
return [ self._getOb(id) for id in self.objectIds(spec) ]
-
def objectItems(self, spec=None):
# Returns a list of (id, subobject) tuples of the current object.
# If 'spec' is specified, returns only objects whose meta_type match
@@ -371,7 +385,7 @@
# Return a tuple of mappings containing subobject meta-data
return tuple(map(lambda dict: dict.copy(), self._objects))
- def objectIds_d(self,t=None):
+ def objectIds_d(self, t=None):
if hasattr(self, '_reserved_names'): n=self._reserved_names
else: n=()
if not n: return self.objectIds(t)
@@ -381,17 +395,17 @@
if id not in n: a(id)
return r
- def objectValues_d(self,t=None):
+ def objectValues_d(self, t=None):
return map(self._getOb, self.objectIds_d(t))
- def objectItems_d(self,t=None):
+ def objectItems_d(self, t=None):
r=[]
a=r.append
g=self._getOb
for id in self.objectIds_d(t): a((id, g(id)))
return r
- def objectMap_d(self,t=None):
+ def objectMap_d(self, t=None):
if hasattr(self, '_reserved_names'): n=self._reserved_names
else: n=()
if not n: return self._objects
@@ -401,7 +415,7 @@
if d['id'] not in n: a(d.copy())
return r
- def superValues(self,t):
+ def superValues(self, t):
# Return all of the objects of a given type located in
# this object and containing objects.
if type(t)==type('s'): t=(t,)
@@ -584,11 +598,12 @@
listing += [f for f in os.listdir(directory)
if f.endswith('.zexp') or f.endswith('.xml')]
return listing
-
+
# FTP support methods
def manage_FTPlist(self, REQUEST):
- "Directory listing for FTP"
+ """Directory listing for FTP.
+ """
out=()
# check to see if we are being acquiring or not
@@ -650,9 +665,9 @@
if not REQUEST['id'] in self.objectIds():
raise KeyError(REQUEST['id'])
-
def manage_FTPstat(self,REQUEST):
- "Psuedo stat used for FTP listings"
+ """Psuedo stat, used by FTP for directory listings.
+ """
mode=0040000
from AccessControl.User import nobody
# check to see if we are acquiring our objectValues or not
@@ -678,7 +693,6 @@
break
return marshal.dumps((mode,0,0,1,owner,group,0,mtime,mtime,mtime))
-
def __getitem__(self, key):
v=self._getOb(key, None)
if v is not None: return v
@@ -689,6 +703,7 @@
return NullResource(self, key, request).__of__(self)
raise KeyError, key
+
def findChildren(obj,dirname=''):
""" recursive walk through the object hierarchy to
find all children of an object (ajung)
@@ -703,7 +718,9 @@
return lst
+
class IFAwareObjectManager:
+
def all_meta_types(self, interfaces=None):
if interfaces is None:
Property changes on: Zope/trunk/lib/python/OFS/ObjectManager.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.175
Modified: Zope/trunk/lib/python/OFS/PropertyManager.py
===================================================================
--- Zope/trunk/lib/python/OFS/PropertyManager.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/OFS/PropertyManager.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -14,19 +14,23 @@
$Id$
"""
+
+from cgi import escape
+from types import ListType
+
import ExtensionClass, Globals
-import ZDOM
-from PropertySheets import DefaultPropertySheets, vps
from ZPublisher.Converters import type_converters
from Globals import DTMLFile, MessageDialog
-from Acquisition import Implicit, aq_base
+from Acquisition import aq_base
from Globals import Persistent
from zExceptions import BadRequest
-from cgi import escape
-from types import ListType
+import ZDOM
+from PropertySheets import DefaultPropertySheets, vps
+
class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
+
"""
The PropertyManager mixin class provides an object with
transparent property management. An object which wants to
@@ -128,22 +132,28 @@
return 1
def hasProperty(self, id):
- """Return true if object has a property 'id'"""
+ """Return true if object has a property 'id'.
+ """
for p in self._properties:
if id==p['id']:
return 1
return 0
def getProperty(self, id, d=None):
- """Get the property 'id', returning the optional second
- argument or None if no such property is found."""
+ """Get the property 'id'.
+
+ Returns the optional second argument or None if no such property is
+ found.
+ """
if self.hasProperty(id):
return getattr(self, id)
return d
def getPropertyType(self, id):
- """Get the type of property 'id', returning None if no
- such property exists"""
+ """Get the type of property 'id'.
+
+ Returns None if no such property exists.
+ """
for md in self._properties:
if md['id']==id:
return md.get('type', 'string')
@@ -207,24 +217,28 @@
self._properties))
def propertyIds(self):
- """Return a list of property ids """
+ """Return a list of property ids.
+ """
return map(lambda i: i['id'], self._properties)
def propertyValues(self):
- """Return a list of actual property objects """
+ """Return a list of actual property objects.
+ """
return map(lambda i,s=self: getattr(s,i['id']), self._properties)
def propertyItems(self):
- """Return a list of (id,property) tuples """
+ """Return a list of (id,property) tuples.
+ """
return map(lambda i,s=self: (i['id'],getattr(s,i['id'])),
self._properties)
def _propertyMap(self):
- """Return a tuple of mappings, giving meta-data for properties """
+ """Return a tuple of mappings, giving meta-data for properties.
+ """
return self._properties
def propertyMap(self):
- """
- Return a tuple of mappings, giving meta-data for properties.
+ """Return a tuple of mappings, giving meta-data for properties.
+
Return copies of the real definitions for security.
"""
return tuple(map(lambda dict: dict.copy(), self._propertyMap()))
@@ -247,8 +261,10 @@
# Web interface
def manage_addProperty(self, id, value, type, REQUEST=None):
- """Add a new property via the web. Sets a new property with
- the given id, type, and value."""
+ """Add a new property via the web.
+
+ Sets a new property with the given id, type, and value.
+ """
if type_converters.has_key(type):
value=type_converters[type](value)
self._setProperty(id.strip(), value, type)
@@ -257,6 +273,7 @@
def manage_editProperties(self, REQUEST):
"""Edit object properties via the web.
+
The purpose of this method is to change all property values,
even those not listed in REQUEST; otherwise checkboxes that
get turned off will be ignored. Use manage_changeProperties()
@@ -346,7 +363,4 @@
if REQUEST is not None:
return self.manage_propertiesForm(self, REQUEST)
-
-
-
Globals.default__class_init__(PropertyManager)
Property changes on: Zope/trunk/lib/python/OFS/PropertyManager.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.56
Modified: Zope/trunk/lib/python/OFS/SimpleItem.py
===================================================================
--- Zope/trunk/lib/python/OFS/SimpleItem.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/OFS/SimpleItem.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -19,50 +19,59 @@
$Id$
"""
-import re, sys, Globals, App.Management, Acquisition, App.Undo
+
+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 CopySupport import CopySource
-from types import InstanceType, StringType
from ComputedAttribute import ComputedAttribute
from AccessControl import getSecurityManager, Unauthorized
-from Traversable import Traversable
+from AccessControl.ZopeSecurityPolicy import getRoles
from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire
from DocumentTemplate.ustr import ustr
from zExceptions.ExceptionFormatter import format_exception
from zExceptions import Redirect
-import time
from zLOG import LOG, BLATHER
-from AccessControl.ZopeSecurityPolicy import getRoles
-import marshal
+from CopySupport import CopySource
+from Traversable import Traversable
import ZDOM
HTML=Globals.HTML
-StringType=type('')
+
class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
ZDOM.Element,
AccessControl.Owned.Owned,
App.Undo.UndoSupport,
):
+
"""A common base class for simple, non-container objects."""
+
isPrincipiaFolderish=0
isTopLevelPrincipiaApplicationObject=0
- def manage_afterAdd(self, item, container): pass
- def manage_beforeDelete(self, item, container): pass
- def manage_afterClone(self, item): pass
+ def manage_afterAdd(self, item, container):
+ pass
+ def manage_beforeDelete(self, item, container):
+ pass
+
+ def manage_afterClone(self, item):
+ pass
+
# Direct use of the 'id' attribute is deprecated - use getId()
id=''
getId__roles__=None
def getId(self):
- """Return the id of the object as a string. This method
- should be used in preference to accessing an id attribute
- of an object directly. The getId method is public."""
+ """Return the id of the object as a string.
+
+ This method should be used in preference to accessing an id attribute
+ of an object directly. The getId method is public.
+ """
name=getattr(self, 'id', None)
if callable(name):
return name()
@@ -99,12 +108,9 @@
# Allow (reluctantly) access to unprotected attributes
__allow_access_to_unprotected_subobjects__=1
-
def title_or_id(self):
+ """Return the title if it is not blank and the id otherwise.
"""
- Utility that returns the title if it is not blank and the id
- otherwise.
- """
title=self.title
if callable(title):
title=title()
@@ -112,11 +118,10 @@
return self.getId()
def title_and_id(self):
+ """Return the title if it is not blank and the id otherwise.
+
+ If the title is not blank, then the id is included in parens.
"""
- Utility that returns the title if it is not blank and the id
- otherwise. If the title is not blank, then the id is included
- in parens.
- """
title=self.title
if callable(title):
title=title()
@@ -222,7 +227,8 @@
tb=None
def manage(self, URL1):
- " "
+ """
+ """
raise Redirect, "%s/manage_main" % URL1
# This keeps simple items from acquiring their parents
@@ -234,7 +240,8 @@
# FTP support methods
def manage_FTPstat(self,REQUEST):
- "psuedo stat, used by FTP for directory listings"
+ """Psuedo stat, used by FTP for directory listings.
+ """
from AccessControl.User import nobody
mode=0100000
@@ -245,7 +252,7 @@
mode=mode | 0440
except Unauthorized:
pass
-
+
if nobody.allowed(
self.manage_FTPget,
getRoles(self, 'manage_FTPget', self.manage_FTPget, ()),
@@ -288,8 +295,11 @@
return marshal.dumps((mode,0,0,1,owner,group,size,mtime,mtime,mtime))
def manage_FTPlist(self,REQUEST):
- """Directory listing for FTP. In the case of non-Foldoid objects,
- the listing should contain one object, the object itself."""
+ """Directory listing for FTP.
+
+ In the case of non-Foldoid objects, the listing should contain one
+ object, the object itself.
+ """
# check to see if we are being acquiring or not
ob=self
while 1:
@@ -306,25 +316,27 @@
def __len__(self):
return 1
-
Globals.default__class_init__(Item)
+
class Item_w__name__(Item):
"""Mixin class to support common name/id functions"""
def getId(self):
- """Returns the id"""
+ """Return the id of the object as a string.
+ """
return self.__name__
def title_or_id(self):
- """Utility that returns the title if it is not blank and the id
- otherwise."""
+ """Return the title if it is not blank and the id otherwise.
+ """
return self.title or self.__name__
def title_and_id(self):
- """Utility that returns the title if it is not blank and the id
- otherwise. If the title is not blank, then the id is included
- in parens."""
+ """Return the title if it is not blank and the id otherwise.
+
+ If the title is not blank, then the id is included in parens.
+ """
t=self.title
return t and ("%s (%s)" % (t,self.__name__)) or self.__name__
@@ -332,11 +344,13 @@
self.__name__=id
def getPhysicalPath(self):
- '''Returns a path (an immutable sequence of strings)
- that can be used to access this object again
- later, for example in a copy/paste operation. getPhysicalRoot()
- and getPhysicalPath() are designed to operate together.
- '''
+ """Get the physical path of the object.
+
+ Returns a path (an immutable sequence of strings) that can be used to
+ access this object again later, for example in a copy/paste operation.
+ getPhysicalRoot() and getPhysicalPath() are designed to operate
+ together.
+ """
path = (self.__name__,)
p = aq_parent(aq_inner(self))
@@ -356,6 +370,7 @@
Acquisition.Implicit,
AccessControl.Role.RoleManager,
):
+
# Blue-plate special, Zope Masala
"""Mix-in class combining the most common set of basic mix-ins
"""
Property changes on: Zope/trunk/lib/python/OFS/SimpleItem.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.110
Modified: Zope/trunk/lib/python/OFS/Traversable.py
===================================================================
--- Zope/trunk/lib/python/OFS/Traversable.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/OFS/Traversable.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -14,23 +14,24 @@
$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 urllib import quote
-
from zExceptions import NotFound
_marker = object()
+
class Traversable:
absolute_url__roles__=None # Public
def absolute_url(self, relative=0):
- """
- Return the absolute URL of the object.
+ """Return the absolute URL of the object.
This a canonical URL based on the object's physical
containment path. It is affected by the virtual host
@@ -57,8 +58,7 @@
absolute_url_path__roles__=None # Public
def absolute_url_path(self):
- """
- Return the path portion of the absolute URL of the object.
+ """Return the path portion of the absolute URL of the object.
This includes the leading slash, and can be used as an
'absolute-path reference' as defined in RFC 2396.
@@ -72,8 +72,7 @@
virtual_url_path__roles__=None # Public
def virtual_url_path(self):
- """
- Return a URL for the object, relative to the site root.
+ """Return a URL for the object, relative to the site root.
If a virtual host is configured, the URL is a path relative to
the virtual host's root object. Otherwise, it is the physical
@@ -91,11 +90,13 @@
getPhysicalPath__roles__=None # Public
def getPhysicalPath(self):
- '''Returns a path (an immutable sequence of strings)
- that can be used to access this object again
- later, for example in a copy/paste operation. getPhysicalRoot()
- and getPhysicalPath() are designed to operate together.
- '''
+ """Get the physical path of the object.
+
+ Returns a path (an immutable sequence of strings) that can be used to
+ access this object again later, for example in a copy/paste operation.
+ getPhysicalRoot() and getPhysicalPath() are designed to operate
+ together.
+ """
path = (self.getId(),)
p = aq_parent(aq_inner(self))
@@ -106,26 +107,26 @@
unrestrictedTraverse__roles__=() # Private
def unrestrictedTraverse(self, path, default=_marker, restricted=0):
- """Lookup an object by path,
-
+ """Lookup an object by path.
+
path -- The path to the object. May be a sequence of strings or a slash
separated string. If the path begins with an empty path element
(i.e., an empty string or a slash) then the lookup is performed
from the application root. Otherwise, the lookup is relative to
self. Two dots (..) as a path element indicates an upward traversal
to the acquisition parent.
-
+
default -- If provided, this is the value returned if the path cannot
be traversed for any reason (i.e., no object exists at that path or
the object is inaccessible).
-
+
restricted -- If false (default) then no security checking is performed.
If true, then all of the objects along the path are validated with
the security machinery. Usually invoked using restrictedTraverse().
"""
if not path:
return self
-
+
_getattr = getattr
_none = None
marker = _marker
Property changes on: Zope/trunk/lib/python/OFS/Traversable.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.24
Modified: Zope/trunk/lib/python/webdav/Collection.py
===================================================================
--- Zope/trunk/lib/python/webdav/Collection.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/webdav/Collection.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -10,11 +10,11 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
+"""WebDAV support - collection objects.
-"""WebDAV support - collection objects."""
+$Id$
+"""
-__version__='$Revision: 1.27 $'[11:-2]
-
import Globals, davcmds, Lockable
from common import urlfix, rfc1123_date
from Resource import Resource
@@ -23,6 +23,7 @@
from zExceptions import MethodNotAllowed, NotFound
from webdav.common import Locked, PreconditionFailed
+
class Collection(Resource):
"""The Collection class provides basic WebDAV support for
collection objects. It provides default implementations
@@ -131,8 +132,5 @@
if objectValues is not None:
return objectValues()
return []
-
-
-
Globals.default__class_init__(Collection)
Property changes on: Zope/trunk/lib/python/webdav/Collection.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.27
Name: svn:keywords
+ Id
Modified: Zope/trunk/lib/python/webdav/EtagSupport.py
===================================================================
--- Zope/trunk/lib/python/webdav/EtagSupport.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/webdav/EtagSupport.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -10,14 +10,19 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
+"""Etag support.
-__version__ = "$Revision: 1.11 $"[11:-2]
+$Id$
+"""
+import time
-import time, Interface
+from Interface import Interface
+
from webdav.common import PreconditionFailed
-class EtagBaseInterface(Interface.Base):
+
+class EtagBaseInterface(Interface):
"""\
Basic Etag support interface, meaning the object supports generating
an Etag that can be used by certain HTTP and WebDAV Requests.
@@ -53,6 +58,7 @@
Thus, Etags need to be refreshed manually when an object changes.
"""
+
class EtagSupport:
"""\
This class is the basis for supporting Etags in Zope. It's main
Property changes on: Zope/trunk/lib/python/webdav/EtagSupport.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.11
Name: svn:keywords
+ Id
Modified: Zope/trunk/lib/python/webdav/Lockable.py
===================================================================
--- Zope/trunk/lib/python/webdav/Lockable.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/webdav/Lockable.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -10,16 +10,21 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
+"""WebDAV support - lockable item.
-__version__ = "$Revision: 1.10 $"[11:-2]
+$Id$
+"""
-from WriteLockInterface import WriteLockInterface, LockItemInterface
-from EtagSupport import EtagSupport
-from LockItem import LockItem
from AccessControl import ClassSecurityInfo
+from Globals import InitializeClass
from Globals import PersistentMapping
import Acquisition
+from EtagSupport import EtagSupport
+from WriteLockInterface import LockItemInterface
+from WriteLockInterface import WriteLockInterface
+
+
class ResourceLockedError(Exception): pass
class LockableItem(EtagSupport):
@@ -134,11 +139,9 @@
if hasattr(Acquisition.aq_base(self), '__no_valid_write_locks__'):
self.__no_valid_write_locks__()
+InitializeClass(LockableItem)
-import Globals
-Globals.default__class_init__(LockableItem)
-
### Utility functions
def wl_isLocked(ob):
Property changes on: Zope/trunk/lib/python/webdav/Lockable.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.10
Name: svn:keywords
+ Id
Modified: Zope/trunk/lib/python/webdav/WriteLockInterface.py
===================================================================
--- Zope/trunk/lib/python/webdav/WriteLockInterface.py 2005-05-15 15:31:25 UTC (rev 30355)
+++ Zope/trunk/lib/python/webdav/WriteLockInterface.py 2005-05-15 15:56:18 UTC (rev 30356)
@@ -10,15 +10,19 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
+"""Write lock interfaces.
-__version__='$Revision: 1.6 $'[11:-2]
+$Id$
+"""
-import Interface
+from Interface import Interface
-class LockItemInterface(Interface.Base):
- """\
- A LockItem contains information about a lock. This includes:
+class LockItemInterface(Interface):
+ """A LockItem contains information about a lock.
+
+ This includes:
+
o The locktoken uri (used to identify the lock by WebDAV)
o The lock owner (The string passed in the 'owner' property by WebDAV)
@@ -36,7 +40,7 @@
"""
# XXX: WAAAA! What is a ctor doing in the interface?
- def __init__(self, creator, owner, depth=0, timeout='Infinity',
+ def __init__(creator, owner, depth=0, timeout='Infinity',
locktype='write', lockscope='exclusive', token=None):
"""\
If any of the following are untrue, a **ValueError** exception
@@ -139,11 +143,10 @@
""" Render a full XML representation of a lock for WebDAV,
used when returning the value of a newly created lock. """
-class WriteLockInterface(Interface.Base):
- """\
- This represents the basic protocol needed to support the write lock
- machinery.
+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?
@@ -170,10 +173,8 @@
**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.
Property changes on: Zope/trunk/lib/python/webdav/WriteLockInterface.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.6
Name: svn:keywords
+ Id
More information about the Zope-Checkins
mailing list