Commit 477d8bc1 authored by Martijn Pieters's avatar Martijn Pieters

Clean up indentation and trailing whitespace.

As the 'if 1:' block for diff preservation was heavily tabbed anyway, I
removed an indent level and the 'if 1:' statement.
parent 4ba09362
This diff is collapsed.
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__="""Cacheable object and cache management base classes. __doc__="""Cacheable object and cache management base classes.
$Id: Cache.py,v 1.9 2002/02/07 17:20:59 andreasjung Exp $""" $Id: Cache.py,v 1.10 2002/08/14 21:42:56 mj Exp $"""
__version__='$Revision: 1.9 $'[11:-2] __version__='$Revision: 1.10 $'[11:-2]
import time, sys import time, sys
import Globals import Globals
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__="""Copy interface""" __doc__="""Copy interface"""
__version__='$Revision: 1.81 $'[11:-2] __version__='$Revision: 1.82 $'[11:-2]
import sys, Globals, Moniker, tempfile, ExtensionClass import sys, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps from marshal import loads, dumps
...@@ -77,7 +77,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -77,7 +77,7 @@ class CopyContainer(ExtensionClass.Base):
REQUEST['__cp'] = cp REQUEST['__cp'] = cp
return self.manage_main(self, REQUEST) return self.manage_main(self, REQUEST)
return cp return cp
def manage_copyObjects(self, ids=None, REQUEST=None, RESPONSE=None): def manage_copyObjects(self, ids=None, REQUEST=None, RESPONSE=None):
"""Put a reference to the objects named in ids in the clip board""" """Put a reference to the objects named in ids in the clip board"""
if ids is None and REQUEST is not None: if ids is None and REQUEST is not None:
...@@ -130,7 +130,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -130,7 +130,7 @@ class CopyContainer(ExtensionClass.Base):
cp=REQUEST['__cp'] cp=REQUEST['__cp']
if cp is None: if cp is None:
raise CopyError, eNoData raise CopyError, eNoData
try: cp=_cb_decode(cp) try: cp=_cb_decode(cp)
except: raise CopyError, eInvalid except: raise CopyError, eInvalid
...@@ -186,7 +186,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -186,7 +186,7 @@ class CopyContainer(ExtensionClass.Base):
# try to make ownership explicit so that it gets carried # try to make ownership explicit so that it gets carried
# along to the new location if needed. # along to the new location if needed.
ob.manage_changeOwnershipType(explicit=1) ob.manage_changeOwnershipType(explicit=1)
aq_parent(aq_inner(ob))._delObject(id) aq_parent(aq_inner(ob))._delObject(id)
ob = aq_base(ob) ob = aq_base(ob)
orig_id=id orig_id=id
...@@ -232,7 +232,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -232,7 +232,7 @@ class CopyContainer(ExtensionClass.Base):
action ='manage_main') action ='manage_main')
ob=self._getOb(id) ob=self._getOb(id)
if not ob.cb_isMoveable(): if not ob.cb_isMoveable():
raise CopyError, eNotSupported % id raise CopyError, eNotSupported % id
self._verifyObjectPaste(ob) self._verifyObjectPaste(ob)
try: ob._notifyOfCopyTo(self, op=1) try: ob._notifyOfCopyTo(self, op=1)
except: raise CopyError, MessageDialog( except: raise CopyError, MessageDialog(
...@@ -242,7 +242,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -242,7 +242,7 @@ class CopyContainer(ExtensionClass.Base):
self._delObject(id) self._delObject(id)
ob = aq_base(ob) ob = aq_base(ob)
ob._setId(new_id) ob._setId(new_id)
# Note - because a rename always keeps the same context, we # Note - because a rename always keeps the same context, we
# can just leave the ownership info unchanged. # can just leave the ownership info unchanged.
self._setObject(new_id, ob, set_owner=0) self._setObject(new_id, ob, set_owner=0)
...@@ -308,7 +308,7 @@ class CopyContainer(ExtensionClass.Base): ...@@ -308,7 +308,7 @@ class CopyContainer(ExtensionClass.Base):
# #
# Passing a false value for the validate_src argument will skip # Passing a false value for the validate_src argument will skip
# checking the passed in object in its existing context. This is # checking the passed in object in its existing context. This is
# mainly useful for situations where the passed in object has no # mainly useful for situations where the passed in object has no
# existing context, such as checking an object during an import # existing context, such as checking an object during an import
# (the object will not yet have been connected to the acquisition # (the object will not yet have been connected to the acquisition
# heirarchy). # heirarchy).
...@@ -390,7 +390,7 @@ class CopySource(ExtensionClass.Base): ...@@ -390,7 +390,7 @@ class CopySource(ExtensionClass.Base):
__ac_permissions__=( __ac_permissions__=(
('Copy or Move', (), ('Anonymous', 'Manager',)), ('Copy or Move', (), ('Anonymous', 'Manager',)),
) )
def _canCopy(self, op=0): def _canCopy(self, op=0):
"""Called to make sure this object is copyable. The op var """Called to make sure this object is copyable. The op var
is 0 for a copy, 1 for a move.""" is 0 for a copy, 1 for a move."""
...@@ -430,7 +430,7 @@ class CopySource(ExtensionClass.Base): ...@@ -430,7 +430,7 @@ class CopySource(ExtensionClass.Base):
# Called after the copy is finished to accomodate special cases. # Called after the copy is finished to accomodate special cases.
# The op var is 0 for a copy, 1 for a move. # The op var is 0 for a copy, 1 for a move.
pass pass
def _setId(self, id): def _setId(self, id):
# Called to set the new id of a copied object. # Called to set the new id of a copied object.
self.id=id self.id=id
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""DTML Document objects.""" """DTML Document objects."""
__version__='$Revision: 1.47 $'[11:-2] __version__='$Revision: 1.48 $'[11:-2]
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import HTML, DTMLFile, MessageDialog from Globals import HTML, DTMLFile, MessageDialog
...@@ -87,12 +87,12 @@ class DTMLDocument(PropertyManager, DTMLMethod): ...@@ -87,12 +87,12 @@ class DTMLDocument(PropertyManager, DTMLMethod):
if self.wl_isLocked(): if self.wl_isLocked():
raise ResourceLockedError, ( raise ResourceLockedError, (
'This document has been locked via WebDAV.') 'This document has been locked via WebDAV.')
if type(file) is not type(''): if type(file) is not type(''):
if REQUEST and not file: if REQUEST and not file:
raise ValueError, 'No file specified' raise ValueError, 'No file specified'
file=file.read() file=file.read()
self.munge(file) self.munge(file)
self.ZCacheable_invalidate() self.ZCacheable_invalidate()
if REQUEST: if REQUEST:
...@@ -114,7 +114,7 @@ class DTMLDocument(PropertyManager, DTMLMethod): ...@@ -114,7 +114,7 @@ class DTMLDocument(PropertyManager, DTMLMethod):
if hasattr(self, 'aq_explicit'): if hasattr(self, 'aq_explicit'):
bself=self.aq_explicit bself=self.aq_explicit
else: bself=self else: bself=self
security=getSecurityManager() security=getSecurityManager()
security.addContext(self) security.addContext(self)
...@@ -178,5 +178,3 @@ def addDTMLDocument(self, id, title='', file='', REQUEST=None, submit=None): ...@@ -178,5 +178,3 @@ def addDTMLDocument(self, id, title='', file='', REQUEST=None, submit=None):
if submit==" Add and Edit ": u="%s/%s" % (u,quote(id)) if submit==" Add and Edit ": u="%s/%s" % (u,quote(id))
REQUEST.RESPONSE.redirect(u+'/manage_main') REQUEST.RESPONSE.redirect(u+'/manage_main')
return '' return ''
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""DTML Method objects.""" """DTML Method objects."""
__version__='$Revision: 1.78 $'[11:-2] __version__='$Revision: 1.79 $'[11:-2]
import History import History
from Globals import HTML, DTMLFile, MessageDialog from Globals import HTML, DTMLFile, MessageDialog
...@@ -101,7 +101,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -101,7 +101,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
if data is not _marker: if data is not _marker:
# Return cached results. # Return cached results.
return data return data
kw['document_id'] =self.getId() kw['document_id'] =self.getId()
kw['document_title']=self.title kw['document_title']=self.title
...@@ -113,7 +113,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -113,7 +113,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
self.__dict__['validate'] = security.DTMLValidate self.__dict__['validate'] = security.DTMLValidate
first_time_through = 1 first_time_through = 1
try: try:
if client is None: if client is None:
# Called as subtemplate, so don't need error propagation! # Called as subtemplate, so don't need error propagation!
r=apply(HTML.__call__, (self, client, REQUEST), kw) r=apply(HTML.__call__, (self, client, REQUEST), kw)
...@@ -179,7 +179,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -179,7 +179,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
Returns the cacheNamespaceKeys. Returns the cacheNamespaceKeys.
''' '''
return self._cache_namespace_keys return self._cache_namespace_keys
def setCacheNamespaceKeys(self, keys, REQUEST=None): def setCacheNamespaceKeys(self, keys, REQUEST=None):
''' '''
Sets the list of names that should be looked up in the Sets the list of names that should be looked up in the
...@@ -220,14 +220,14 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -220,14 +220,14 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST): def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
dr,dc = self._size_changes[SUBMIT] dr,dc = self._size_changes[SUBMIT]
rows=str(max(1,int(dtpref_rows)+dr)) rows=str(max(1,int(dtpref_rows)+dr))
if dtpref_cols[-1]=='%': if dtpref_cols[-1]=='%':
cols= str(min(100, max(25,int(dtpref_cols[:-1])+dc)))+'%' cols= str(min(100, max(25,int(dtpref_cols[:-1])+dc)))+'%'
else: else:
cols=str(max(35,int(dtpref_cols)+dc)) cols=str(max(35,int(dtpref_cols)+dc))
e=(DateTime('GMT') + 365).rfc822() e=(DateTime('GMT') + 365).rfc822()
resp=REQUEST['RESPONSE'] resp=REQUEST['RESPONSE']
resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) resp.setCookie('dtpref_rows',str(rows),path='/',expires=e)
...@@ -267,11 +267,11 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -267,11 +267,11 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
if self.wl_isLocked(): if self.wl_isLocked():
raise ResourceLockedError, 'This DTML Method is locked via WebDAV' raise ResourceLockedError, 'This DTML Method is locked via WebDAV'
if type(file) is not type(''): if type(file) is not type(''):
if REQUEST and not file: if REQUEST and not file:
raise ValueError, 'No file specified' raise ValueError, 'No file specified'
file=file.read() file=file.read()
self.munge(file) self.munge(file)
self.ZCacheable_invalidate() self.ZCacheable_invalidate()
if REQUEST: if REQUEST:
...@@ -297,7 +297,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -297,7 +297,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
raise 'Forbidden', ( raise 'Forbidden', (
'You are not authorized to change <em>%s</em> because you ' 'You are not authorized to change <em>%s</em> because you '
'do not have proxy roles.\n<!--%s, %s-->' % (self.__name__, u, roles)) 'do not have proxy roles.\n<!--%s, %s-->' % (self.__name__, u, roles))
def manage_proxy(self, roles=(), REQUEST=None): def manage_proxy(self, roles=(), REQUEST=None):
"Change Proxy Roles" "Change Proxy Roles"
...@@ -368,11 +368,11 @@ def decapitate(html, RESPONSE=None): ...@@ -368,11 +368,11 @@ def decapitate(html, RESPONSE=None):
headers.append(header) headers.append(header)
spos = m.end() + 1 spos = m.end() + 1
while spos < len(html) and html[spos] in ' \t': while spos < len(html) and html[spos] in ' \t':
eol = find(html, '\r\n', spos) eol = find(html, '\r\n', spos)
if eol <> -1: if eol <> -1:
eolen = 2 eolen = 2
else: else:
eol = find(html, '\n', spos) eol = find(html, '\n', spos)
if eol < 0: return html if eol < 0: return html
eolen = 1 eolen = 1
header.append(strip(html[spos:eol])) header.append(strip(html[spos:eol]))
...@@ -387,7 +387,7 @@ def decapitate(html, RESPONSE=None): ...@@ -387,7 +387,7 @@ def decapitate(html, RESPONSE=None):
default_dm_html="""<dtml-var standard_html_header> default_dm_html="""<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2> <h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p> <p>
This is the <dtml-var document_id> Document This is the <dtml-var document_id> Document
in the <dtml-var title_and_id> Folder. in the <dtml-var title_and_id> Folder.
</p> </p>
<dtml-var standard_html_footer>""" <dtml-var standard_html_footer>"""
...@@ -411,4 +411,3 @@ def addDTMLMethod(self, id, title='', file='', REQUEST=None, submit=None): ...@@ -411,4 +411,3 @@ def addDTMLMethod(self, id, title='', file='', REQUEST=None, submit=None):
if submit==" Add and Edit ": u="%s/%s" % (u,quote(id)) if submit==" Add and Edit ": u="%s/%s" % (u,quote(id))
REQUEST.RESPONSE.redirect(u+'/manage_main') REQUEST.RESPONSE.redirect(u+'/manage_main')
return '' return ''
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__="""Implement Observable interface (see __doc__="""Implement Observable interface (see
http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification) http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification)
This class is intended to be used as a mixin (note that it doesn't derive This class is intended to be used as a mixin (note that it doesn't derive
from any Zope persistence classes, for instance). from any Zope persistence classes, for instance).
$Id: DefaultObservable.py,v 1.5 2002/02/07 17:20:59 andreasjung Exp $""" $Id: DefaultObservable.py,v 1.6 2002/08/14 21:42:56 mj Exp $"""
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
from types import StringType from types import StringType
...@@ -57,12 +57,12 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification ...@@ -57,12 +57,12 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification
def __init__( self, debug=0 ): def __init__( self, debug=0 ):
self._observers = [] self._observers = []
self._debug = debug self._debug = debug
def _normalize( self, observer ): def _normalize( self, observer ):
# Assert that observer is a string or a sequence of strings. # Assert that observer is a string or a sequence of strings.
if type( observer ) != StringType: if type( observer ) != StringType:
observer = '/'.join( observer) observer = '/'.join( observer)
return observer return observer
...@@ -102,13 +102,13 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification ...@@ -102,13 +102,13 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification
traceback.print_exc() traceback.print_exc()
else: else:
bozos.append( observer ) bozos.append( observer )
for bozo in bozos: for bozo in bozos:
try: # avoid race condition if unregister() called before now try: # avoid race condition if unregister() called before now
self._observers.remove( bozo ) self._observers.remove( bozo )
except: except:
pass pass
# #
# Unit tests # Unit tests
...@@ -117,7 +117,7 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification ...@@ -117,7 +117,7 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification
if __name__ == '__main__': if __name__ == '__main__':
class DontGoHere( Exception ): pass class DontGoHere( Exception ): pass
class TestSubject( DefaultObservable ): class TestSubject( DefaultObservable ):
def __init__( self, paths ): def __init__( self, paths ):
...@@ -134,29 +134,29 @@ if __name__ == '__main__': ...@@ -134,29 +134,29 @@ if __name__ == '__main__':
if cbrec is None: if cbrec is None:
cbrec = callbacks[ name ] = [] cbrec = callbacks[ name ] = []
cbrec.append( ( subject, event ) ) cbrec.append( ( subject, event ) )
class TestObserver: class TestObserver:
def __call__( self, subject, event ): def __call__( self, subject, event ):
recordCallback( 'direct', subject, event ) recordCallback( 'direct', subject, event )
def namedCallback( self, subject, event ): def namedCallback( self, subject, event ):
recordCallback( 'named', subject, event ) recordCallback( 'named', subject, event )
def named2Callback( self, subject, event ): def named2Callback( self, subject, event ):
recordCallback( 'named2', subject, event ) recordCallback( 'named2', subject, event )
def boundCallback( self, subject, event ): def boundCallback( self, subject, event ):
recordCallback( 'bound', subject, event ) recordCallback( 'bound', subject, event )
def freefuncObserver( subject, event ): def freefuncObserver( subject, event ):
recordCallback( 'freefunc', subject, event ) recordCallback( 'freefunc', subject, event )
def tryVeto( subject, event ): def tryVeto( subject, event ):
""" Simulate attempted veto. """ """ Simulate attempted veto. """
raise 'Idawanna!' raise 'Idawanna!'
observer = TestObserver() observer = TestObserver()
# Simulate Zope's path traversal mechanism. # Simulate Zope's path traversal mechanism.
...@@ -204,4 +204,3 @@ if __name__ == '__main__': ...@@ -204,4 +204,3 @@ if __name__ == '__main__':
print '[%s]' % key print '[%s]' % key
for cb in callbacks[ key ]: for cb in callbacks[ key ]:
print ' %s' % `cb` print ' %s' % `cb`
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Deprecated - use DTMLMethod""" """Deprecated - use DTMLMethod"""
__version__='$Revision: 1.75 $'[11:-2] __version__='$Revision: 1.76 $'[11:-2]
import DTMLMethod import DTMLMethod
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""FTP Support for Zope classes. """FTP Support for Zope classes.
...@@ -23,11 +23,11 @@ All FTP methods should be governed by a single permission: ...@@ -23,11 +23,11 @@ All FTP methods should be governed by a single permission:
class FTPInterface: class FTPInterface:
"Interface for FTP objects" "Interface for FTP objects"
# XXX The stat and list marshal format should probably # XXX The stat and list marshal format should probably
# be XML, not marshal, maybe Andrew K's xml-marshal. # be XML, not marshal, maybe Andrew K's xml-marshal.
# This will probably be changed later. # This will probably be changed later.
def manage_FTPstat(self,REQUEST): def manage_FTPstat(self,REQUEST):
"""Returns a stat-like tuple. (marshalled to a string) Used by """Returns a stat-like tuple. (marshalled to a string) Used by
FTP for directory listings, and MDTM and SIZE""" FTP for directory listings, and MDTM and SIZE"""
...@@ -37,13 +37,13 @@ class FTPInterface: ...@@ -37,13 +37,13 @@ class FTPInterface:
(id,stat) tuples, marshaled to a string. Note, the listing it (id,stat) tuples, marshaled to a string. Note, the listing it
should include '..' if there is a Folder above the current should include '..' if there is a Folder above the current
one. one.
In the case of non-foldoid objects it should return a single In the case of non-foldoid objects it should return a single
tuple (id,stat) representing itself.""" tuple (id,stat) representing itself."""
# Optional method to support FTP download. # Optional method to support FTP download.
# Should not be implemented by Foldoid objects. # Should not be implemented by Foldoid objects.
def manage_FTPget(self): def manage_FTPget(self):
"""Returns the source content of an object. For example, the """Returns the source content of an object. For example, the
source text of a Document, or the data of a file.""" source text of a Document, or the data of a file."""
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__="""Find support""" __doc__="""Find support"""
__version__='$Revision: 1.30 $'[11:-2] __version__='$Revision: 1.31 $'[11:-2]
import sys, os, time, Globals, ExtensionClass import sys, os, time, Globals, ExtensionClass
...@@ -42,10 +42,10 @@ class FindSupport(ExtensionClass.Base): ...@@ -42,10 +42,10 @@ class FindSupport(ExtensionClass.Base):
('manage_findFrame', 'manage_findForm', 'manage_findAdv', ('manage_findFrame', 'manage_findForm', 'manage_findAdv',
'manage_findResult')), 'manage_findResult')),
) )
manage_options=( manage_options=(
{'label':'Find', 'action':'manage_findForm', {'label':'Find', 'action':'manage_findForm',
'help':('OFSP','Find.stx')}, 'help':('OFSP','Find.stx')},
) )
def ZopeFind(self, obj, obj_ids=None, obj_metatypes=None, def ZopeFind(self, obj, obj_ids=None, obj_metatypes=None,
...@@ -61,7 +61,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -61,7 +61,7 @@ class FindSupport(ExtensionClass.Base):
if obj_metatypes and 'all' in obj_metatypes: if obj_metatypes and 'all' in obj_metatypes:
obj_metatypes=None obj_metatypes=None
if obj_mtime and type(obj_mtime)==type('s'): if obj_mtime and type(obj_mtime)==type('s'):
obj_mtime=DateTime(obj_mtime).timeTime() obj_mtime=DateTime(obj_mtime).timeTime()
...@@ -70,7 +70,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -70,7 +70,7 @@ class FindSupport(ExtensionClass.Base):
if obj_roles and type(obj_roles) is type('s'): if obj_roles and type(obj_roles) is type('s'):
obj_roles=[obj_roles] obj_roles=[obj_roles]
if obj_expr: if obj_expr:
# Setup expr machinations # Setup expr machinations
md=td() md=td()
...@@ -97,7 +97,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -97,7 +97,7 @@ class FindSupport(ExtensionClass.Base):
for id, ob in items: for id, ob in items:
if pre: p="%s/%s" % (pre, id) if pre: p="%s/%s" % (pre, id)
else: p=id else: p=id
dflag=0 dflag=0
if hasattr(ob, '_p_changed') and (ob._p_changed == None): if hasattr(ob, '_p_changed') and (ob._p_changed == None):
dflag=1 dflag=1
...@@ -148,9 +148,9 @@ class FindSupport(ExtensionClass.Base): ...@@ -148,9 +148,9 @@ class FindSupport(ExtensionClass.Base):
PrincipiaFind=ZopeFind PrincipiaFind=ZopeFind
def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None, def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None,
obj_searchterm=None, obj_expr=None, obj_searchterm=None, obj_expr=None,
obj_mtime=None, obj_mspec=None, obj_mtime=None, obj_mspec=None,
...@@ -165,7 +165,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -165,7 +165,7 @@ class FindSupport(ExtensionClass.Base):
if obj_metatypes and 'all' in obj_metatypes: if obj_metatypes and 'all' in obj_metatypes:
obj_metatypes=None obj_metatypes=None
if obj_mtime and type(obj_mtime)==type('s'): if obj_mtime and type(obj_mtime)==type('s'):
obj_mtime=DateTime(obj_mtime).timeTime() obj_mtime=DateTime(obj_mtime).timeTime()
...@@ -174,7 +174,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -174,7 +174,7 @@ class FindSupport(ExtensionClass.Base):
if obj_roles and type(obj_roles) is type('s'): if obj_roles and type(obj_roles) is type('s'):
obj_roles=[obj_roles] obj_roles=[obj_roles]
if obj_expr: if obj_expr:
# Setup expr machinations # Setup expr machinations
md=td() md=td()
...@@ -196,7 +196,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -196,7 +196,7 @@ class FindSupport(ExtensionClass.Base):
for id, ob in items: for id, ob in items:
if pre: p="%s/%s" % (pre, id) if pre: p="%s/%s" % (pre, id)
else: p=id else: p=id
dflag=0 dflag=0
if hasattr(ob, '_p_changed') and (ob._p_changed == None): if hasattr(ob, '_p_changed') and (ob._p_changed == None):
dflag=1 dflag=1
...@@ -229,7 +229,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -229,7 +229,7 @@ class FindSupport(ExtensionClass.Base):
else: else:
add_result((p, ob)) add_result((p, ob))
dflag=0 dflag=0
if search_sub and hasattr(bs, 'objectItems'): if search_sub and hasattr(bs, 'objectItems'):
self.ZopeFindAndApply(ob, obj_ids, obj_metatypes, self.ZopeFindAndApply(ob, obj_ids, obj_metatypes,
obj_searchterm, obj_expr, obj_searchterm, obj_expr,
...@@ -261,14 +261,14 @@ def expr_match(ob, ed, c=InstanceDict, r=0): ...@@ -261,14 +261,14 @@ def expr_match(ob, ed, c=InstanceDict, r=0):
def mtime_match(ob, t, q, fn=hasattr): def mtime_match(ob, t, q, fn=hasattr):
if not fn(ob, '_p_mtime'): if not fn(ob, '_p_mtime'):
return 0 return 0
return q=='<' and (ob._p_mtime < t) or (ob._p_mtime > t) return q=='<' and (ob._p_mtime < t) or (ob._p_mtime > t)
def role_match(ob, permission, roles, lt=type([]), tt=type(())): def role_match(ob, permission, roles, lt=type([]), tt=type(())):
pr=[] pr=[]
fn=pr.append fn=pr.append
while 1: while 1:
if hasattr(ob, permission): if hasattr(ob, permission):
p=getattr(ob, permission) p=getattr(ob, permission)
...@@ -307,5 +307,3 @@ def absattr(attr): ...@@ -307,5 +307,3 @@ def absattr(attr):
def p_name(name): def p_name(name):
return '_' + translate(name, name_trans) + '_Permission' return '_' + translate(name, name_trans) + '_Permission'
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Folder object """Folder object
Folders are the basic container objects and are analogous to directories. Folders are the basic container objects and are analogous to directories.
$Id: Folder.py,v 1.100 2002/06/07 18:10:31 caseman Exp $""" $Id: Folder.py,v 1.101 2002/08/14 21:42:56 mj Exp $"""
__version__='$Revision: 1.100 $'[11:-2] __version__='$Revision: 1.101 $'[11:-2]
import Globals, SimpleItem, ObjectManager, PropertyManager import Globals, SimpleItem, ObjectManager, PropertyManager
import AccessControl.Role, webdav.Collection, FindSupport import AccessControl.Role, webdav.Collection, FindSupport
...@@ -46,7 +46,7 @@ def manage_addFolder(self, id, title='', ...@@ -46,7 +46,7 @@ def manage_addFolder(self, id, title='',
self._setObject(id, ob) self._setObject(id, ob)
ob=self._getOb(id) ob=self._getOb(id)
checkPermission=getSecurityManager().checkPermission checkPermission=getSecurityManager().checkPermission
if createUserF: if createUserF:
if not checkPermission('Add User Folders', ob): if not checkPermission('Add User Folders', ob):
...@@ -61,7 +61,7 @@ def manage_addFolder(self, id, title='', ...@@ -61,7 +61,7 @@ def manage_addFolder(self, id, title='',
'You are not authorized to add Page Templates.' 'You are not authorized to add Page Templates.'
) )
ob.manage_addProduct['PageTemplates'].manage_addPageTemplate( ob.manage_addProduct['PageTemplates'].manage_addPageTemplate(
id='index_html', title='') id='index_html', title='')
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1) return self.manage_main(self, REQUEST, update_menu=1)
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Object Histories""" """Object Histories"""
__version__='$Revision: 1.13 $'[11:-2] __version__='$Revision: 1.14 $'[11:-2]
import Globals, ExtensionClass, difflib import Globals, ExtensionClass, difflib
from DateTime import DateTime from DateTime import DateTime
...@@ -92,7 +92,7 @@ class Historical(ExtensionClass.Base): ...@@ -92,7 +92,7 @@ class Historical(ExtensionClass.Base):
) )
), ),
) )
manage_options=({'label':'History', 'action':'manage_change_history_page', manage_options=({'label':'History', 'action':'manage_change_history_page',
'help':('OFSP','History.stx') 'help':('OFSP','History.stx')
}, },
...@@ -110,7 +110,7 @@ class Historical(ExtensionClass.Base): ...@@ -110,7 +110,7 @@ class Historical(ExtensionClass.Base):
if request is not None: if request is not None:
first=request.get('first_transaction', first) first=request.get('first_transaction', first)
last=request.get('last_transaction',last) last=request.get('last_transaction',last)
r=self._p_jar.db().history(self._p_oid, None, last) r=self._p_jar.db().history(self._p_oid, None, last)
r=r[first:] r=r[first:]
...@@ -146,7 +146,7 @@ class Historical(ExtensionClass.Base): ...@@ -146,7 +146,7 @@ class Historical(ExtensionClass.Base):
base._p_deactivate() base._p_deactivate()
base.__setstate__(state) base.__setstate__(state)
base._p_changed=1 base._p_changed=1
self.manage_afterHistoryCopy() self.manage_afterHistoryCopy()
if RESPONSE is not None and URL1 is not None: if RESPONSE is not None and URL1 is not None:
...@@ -154,7 +154,7 @@ class Historical(ExtensionClass.Base): ...@@ -154,7 +154,7 @@ class Historical(ExtensionClass.Base):
def manage_afterHistoryCopy(self): pass # ? (Hook) def manage_afterHistoryCopy(self): pass # ? (Hook)
_manage_historyComparePage=Globals.DTMLFile( _manage_historyComparePage=Globals.DTMLFile(
'dtml/historyCompare', globals(), management_view='History') 'dtml/historyCompare', globals(), management_view='History')
def manage_historyCompare(self, rev1, rev2, REQUEST, def manage_historyCompare(self, rev1, rev2, REQUEST,
...@@ -174,10 +174,10 @@ class Historical(ExtensionClass.Base): ...@@ -174,10 +174,10 @@ class Historical(ExtensionClass.Base):
if len(keys) > 2: if len(keys) > 2:
raise HistorySelectionError, ( raise HistorySelectionError, (
"Only two historical revision can be compared<p>") "Only two historical revision can be compared<p>")
serial=apply(pack, ('>HHHH',)+tuple(map(int, keys[-1].split('.')))) serial=apply(pack, ('>HHHH',)+tuple(map(int, keys[-1].split('.'))))
rev1=historicalRevision(self, serial) rev1=historicalRevision(self, serial)
if len(keys)==2: if len(keys)==2:
serial=apply(pack, serial=apply(pack,
('>HHHH',)+tuple(map(int, keys[0].split('.')))) ('>HHHH',)+tuple(map(int, keys[0].split('.'))))
...@@ -187,7 +187,7 @@ class Historical(ExtensionClass.Base): ...@@ -187,7 +187,7 @@ class Historical(ExtensionClass.Base):
rev2=self rev2=self
return self.manage_historyCompare(rev1, rev2, REQUEST) return self.manage_historyCompare(rev1, rev2, REQUEST)
Globals.default__class_init__(Historical) Globals.default__class_init__(Historical)
def dump(tag, x, lo, hi, r): def dump(tag, x, lo, hi, r):
......
This diff is collapsed.
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Object monikers """Object monikers
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
and aquisition relationships via a simple interface. and aquisition relationships via a simple interface.
""" """
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
import Globals import Globals
...@@ -28,7 +28,7 @@ class Moniker: ...@@ -28,7 +28,7 @@ class Moniker:
persistent object. A moniker can be turned back into persistent object. A moniker can be turned back into
a real object that retains its correct version context a real object that retains its correct version context
and acquisition relationships via a simple interface.""" and acquisition relationships via a simple interface."""
def __init__(self, ob=None): def __init__(self, ob=None):
if ob is None: return if ob is None: return
self.idpath = ob.getPhysicalPath() self.idpath = ob.getPhysicalPath()
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.157 2002/08/14 19:59:18 mj Exp $""" $Id: ObjectManager.py,v 1.158 2002/08/14 21:42:56 mj Exp $"""
__version__='$Revision: 1.157 $'[11:-2] __version__='$Revision: 1.158 $'[11:-2]
import App.Management, Acquisition, Globals, CopySupport, Products import App.Management, Acquisition, Globals, CopySupport, Products
import os, App.FactoryDispatcher, re, Products import os, App.FactoryDispatcher, re, Products
...@@ -102,7 +102,7 @@ class ObjectManager( ...@@ -102,7 +102,7 @@ class ObjectManager(
): ):
"""Generic object manager """Generic object manager
This class provides core behavior for collections of heterogeneous objects. This class provides core behavior for collections of heterogeneous objects.
""" """
__ac_permissions__=( __ac_permissions__=(
...@@ -123,7 +123,7 @@ class ObjectManager( ...@@ -123,7 +123,7 @@ class ObjectManager(
meta_type ='Object Manager' meta_type ='Object Manager'
meta_types=() # Sub-object types that are specific to this object meta_types=() # Sub-object types that are specific to this object
_objects =() _objects =()
manage_main=DTMLFile('dtml/main', globals()) manage_main=DTMLFile('dtml/main', globals())
...@@ -148,7 +148,7 @@ class ObjectManager( ...@@ -148,7 +148,7 @@ class ObjectManager(
except: pass except: pass
mt.sort() mt.sort()
self.meta_types=tuple(mt) self.meta_types=tuple(mt)
default__class_init__(self) default__class_init__(self)
def all_meta_types(self, interfaces=None): def all_meta_types(self, interfaces=None):
...@@ -179,11 +179,11 @@ class ObjectManager( ...@@ -179,11 +179,11 @@ class ObjectManager(
eil = entry.get('interfaces',None) eil = entry.get('interfaces',None)
if eil is not None: if eil is not None:
for ei in eil: for ei in eil:
for i in interfaces: for i in interfaces:
if ei is i or ei.extends(i): if ei is i or ei.extends(i):
interface_constrained_meta_types.append(entry) interface_constrained_meta_types.append(entry)
raise BreakoutException # only append 1ce raise BreakoutException # only append 1ce
except BreakoutException: except BreakoutException:
pass pass
# Meta types specified by this instance are not checked against the # Meta types specified by this instance are not checked against the
...@@ -316,7 +316,7 @@ class ObjectManager( ...@@ -316,7 +316,7 @@ class ObjectManager(
self._objects=tuple(filter(lambda i,n=id: i['id']!=n, self._objects)) self._objects=tuple(filter(lambda i,n=id: i['id']!=n, self._objects))
self._delOb(id) self._delOb(id)
# Indicate to the object that it has been deleted. This is # Indicate to the object that it has been deleted. This is
# necessary for object DB mount points. Note that we have to # necessary for object DB mount points. Note that we have to
# tolerate failure here because the object being deleted could # tolerate failure here because the object being deleted could
# be a Broken object, and it is not possible to set attributes # be a Broken object, and it is not possible to set attributes
...@@ -410,7 +410,7 @@ class ObjectManager( ...@@ -410,7 +410,7 @@ class ObjectManager(
vals.append(get(id)) vals.append(get(id))
seen[physicalPath]=1 seen[physicalPath]=1
except: pass except: pass
if hasattr(obj,'aq_parent'): if hasattr(obj,'aq_parent'):
obj=obj.aq_parent obj=obj.aq_parent
relativePhysicalPath = ('..',) + relativePhysicalPath relativePhysicalPath = ('..',) + relativePhysicalPath
...@@ -424,7 +424,7 @@ class ObjectManager( ...@@ -424,7 +424,7 @@ class ObjectManager(
def manage_delObjects(self, ids=[], REQUEST=None): def manage_delObjects(self, ids=[], REQUEST=None):
"""Delete a subordinate object """Delete a subordinate object
The objects specified in 'ids' get deleted. The objects specified in 'ids' get deleted.
""" """
if type(ids) is type(''): ids=[ids] if type(ids) is type(''): ids=[ids]
...@@ -447,7 +447,7 @@ class ObjectManager( ...@@ -447,7 +447,7 @@ class ObjectManager(
self._delObject(id) self._delObject(id)
del ids[-1] del ids[-1]
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST, update_menu=1) return self.manage_main(self, REQUEST, update_menu=1)
def tpValues(self): def tpValues(self):
...@@ -475,7 +475,7 @@ class ObjectManager( ...@@ -475,7 +475,7 @@ class ObjectManager(
def manage_exportObject(self, id='', download=None, toxml=None, def manage_exportObject(self, id='', download=None, toxml=None,
RESPONSE=None,REQUEST=None): RESPONSE=None,REQUEST=None):
"""Exports an object to a file and returns that file.""" """Exports an object to a file and returns that file."""
if not id: if not id:
# can't use getId() here (breaks on "old" exported objects) # can't use getId() here (breaks on "old" exported objects)
id=self.id id=self.id
...@@ -484,7 +484,7 @@ class ObjectManager( ...@@ -484,7 +484,7 @@ class ObjectManager(
else: ob=self._getOb(id) else: ob=self._getOb(id)
suffix=toxml and 'xml' or 'zexp' suffix=toxml and 'xml' or 'zexp'
if download: if download:
f=StringIO() f=StringIO()
if toxml: XMLExportImport.exportXML(ob._p_jar, ob._p_oid, f) if toxml: XMLExportImport.exportXML(ob._p_jar, ob._p_oid, f)
...@@ -502,7 +502,7 @@ class ObjectManager( ...@@ -502,7 +502,7 @@ class ObjectManager(
ob._p_jar.exportFile(ob._p_oid, f) ob._p_jar.exportFile(ob._p_oid, f)
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST, return self.manage_main(self, REQUEST,
manage_tabs_message= manage_tabs_message=
'<em>%s</em> sucessfully exported to <em>%s</em>' % (id,f), '<em>%s</em> sucessfully exported to <em>%s</em>' % (id,f),
title = 'Object exported') title = 'Object exported')
...@@ -518,7 +518,7 @@ class ObjectManager( ...@@ -518,7 +518,7 @@ class ObjectManager(
instance_home = INSTANCE_HOME instance_home = INSTANCE_HOME
zope_home = ZOPE_HOME zope_home = ZOPE_HOME
for impath in (instance_home, zope_home): for impath in (instance_home, zope_home):
filepath = os.path.join(impath, 'import', file) filepath = os.path.join(impath, 'import', file)
if os.path.exists(filepath): if os.path.exists(filepath):
...@@ -528,9 +528,9 @@ class ObjectManager( ...@@ -528,9 +528,9 @@ class ObjectManager(
self._importObjectFromFile(filepath, verify=not not REQUEST, self._importObjectFromFile(filepath, verify=not not REQUEST,
set_owner=set_owner) set_owner=set_owner)
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST, return self.manage_main(self, REQUEST,
manage_tabs_message='<em>%s</em> sucessfully imported' % id, manage_tabs_message='<em>%s</em> sucessfully imported' % id,
title = 'Object imported', title = 'Object imported',
update_menu=1) update_menu=1)
...@@ -556,7 +556,7 @@ class ObjectManager( ...@@ -556,7 +556,7 @@ class ObjectManager(
ob.manage_changeOwnershipType(explicit=0) ob.manage_changeOwnershipType(explicit=0)
# FTP support methods # FTP support methods
def manage_FTPlist(self, REQUEST): def manage_FTPlist(self, REQUEST):
"Directory listing for FTP" "Directory listing for FTP"
out=() out=()
...@@ -569,7 +569,7 @@ class ObjectManager( ...@@ -569,7 +569,7 @@ class ObjectManager(
if not hasattr(ob,'aq_parent'): if not hasattr(ob,'aq_parent'):
break break
ob=ob.aq_parent ob=ob.aq_parent
files=self.objectItems() files=self.objectItems()
# recursive ride through all subfolders (ls -R) (ajung) # recursive ride through all subfolders (ls -R) (ajung)
...@@ -582,7 +582,7 @@ class ObjectManager( ...@@ -582,7 +582,7 @@ class ObjectManager(
all_files.extend(findChilds(f[1])) all_files.extend(findChilds(f[1]))
else: else:
all_files.append(f) all_files.append(f)
files = all_files files = all_files
try: try:
...@@ -592,7 +592,7 @@ class ObjectManager( ...@@ -592,7 +592,7 @@ class ObjectManager(
files.sort() files.sort()
# Perform globbing on list of files (ajung) # Perform globbing on list of files (ajung)
globbing = REQUEST.environ.get('GLOBBING','') globbing = REQUEST.environ.get('GLOBBING','')
if globbing : if globbing :
files = filter(lambda x,g=globbing: fnmatch.fnmatch(x[0],g) , files) files = filter(lambda x,g=globbing: fnmatch.fnmatch(x[0],g) , files)
...@@ -602,7 +602,7 @@ class ObjectManager( ...@@ -602,7 +602,7 @@ class ObjectManager(
except AttributeError: except AttributeError:
files=list(files) files=list(files)
files.sort() files.sort()
if not (hasattr(self,'isTopLevelPrincipiaApplicationObject') and if not (hasattr(self,'isTopLevelPrincipiaApplicationObject') and
self.isTopLevelPrincipiaApplicationObject): self.isTopLevelPrincipiaApplicationObject):
files.insert(0,('..',self.aq_parent)) files.insert(0,('..',self.aq_parent))
...@@ -614,7 +614,7 @@ class ObjectManager( ...@@ -614,7 +614,7 @@ class ObjectManager(
except: stat=None except: stat=None
if stat is not None: if stat is not None:
out=out+((k,stat),) out=out+((k,stat),)
return marshal.dumps(out) return marshal.dumps(out)
def manage_FTPstat(self,REQUEST): def manage_FTPstat(self,REQUEST):
"Psuedo stat used for FTP listings" "Psuedo stat used for FTP listings"
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # This software is subject to the provisions of the Zope Public License,
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Property management""" """Property management"""
__version__='$Revision: 1.45 $'[11:-2] __version__='$Revision: 1.46 $'[11:-2]
import ExtensionClass, Globals import ExtensionClass, Globals
import ZDOM import ZDOM
...@@ -90,9 +90,9 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -90,9 +90,9 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
manage_options=( manage_options=(
{'label':'Properties', 'action':'manage_propertiesForm', {'label':'Properties', 'action':'manage_propertiesForm',
'help':('OFSP','Properties.stx')}, 'help':('OFSP','Properties.stx')},
) )
manage_propertiesForm=DTMLFile('dtml/properties', globals(), manage_propertiesForm=DTMLFile('dtml/properties', globals(),
property_extensible_schema__=1) property_extensible_schema__=1)
manage_propertyTypeForm=DTMLFile('dtml/propertyType', globals()) manage_propertyTypeForm=DTMLFile('dtml/propertyType', globals())
...@@ -134,7 +134,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -134,7 +134,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
return 0 return 0
def getProperty(self, id, d=None): def getProperty(self, id, d=None):
"""Get the property 'id', returning the optional second """Get the property 'id', returning the optional second
argument or None if no such property is found.""" argument or None if no such property is found."""
if self.hasProperty(id): if self.hasProperty(id):
return getattr(self, id) return getattr(self, id)
...@@ -165,7 +165,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -165,7 +165,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
# for selection and multiple selection properties # for selection and multiple selection properties
# the value argument indicates the select variable # the value argument indicates the select variable
# of the property # of the property
self._wrapperCheck(value) self._wrapperCheck(value)
if not self.valid_property_id(id): if not self.valid_property_id(id):
raise 'Bad Request', 'Invalid or duplicate property id' raise 'Bad Request', 'Invalid or duplicate property id'
...@@ -213,7 +213,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -213,7 +213,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
def propertyItems(self): 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'])), return map(lambda i,s=self: (i['id'],getattr(s,i['id'])),
self._properties) self._properties)
def _propertyMap(self): def _propertyMap(self):
"""Return a tuple of mappings, giving meta-data for properties """ """Return a tuple of mappings, giving meta-data for properties """
...@@ -289,7 +289,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -289,7 +289,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
return self.manage_propertiesForm(self,REQUEST,manage_tabs_message=message) return self.manage_propertiesForm(self,REQUEST,manage_tabs_message=message)
# Note - this is experimental, pending some community input. # Note - this is experimental, pending some community input.
def manage_changePropertyTypes(self, old_ids, props, REQUEST=None): def manage_changePropertyTypes(self, old_ids, props, REQUEST=None):
"""Replace one set of properties with another """Replace one set of properties with another
...@@ -307,7 +307,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes): ...@@ -307,7 +307,7 @@ class PropertyManager(ExtensionClass.Base, ZDOM.ElementWithAttributes):
self._setProperty(prop.new_id, prop.new_value, prop.new_type) self._setProperty(prop.new_id, prop.new_value, prop.new_type)
if REQUEST is not None: if REQUEST is not None:
return self.manage_propertiesForm(self, REQUEST) return self.manage_propertiesForm(self, REQUEST)
def manage_delProperties(self, ids=None, REQUEST=None): def manage_delProperties(self, ids=None, REQUEST=None):
"""Delete one or more properties specified by 'ids'.""" """Delete one or more properties specified by 'ids'."""
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Property sheets""" """Property sheets"""
__version__='$Revision: 1.86 $'[11:-2] __version__='$Revision: 1.87 $'[11:-2]
import time, App.Management, Globals import time, App.Management, Globals
from webdav.WriteLockInterface import WriteLockInterface from webdav.WriteLockInterface import WriteLockInterface
...@@ -43,7 +43,7 @@ class View(App.Management.Tabs, Base): ...@@ -43,7 +43,7 @@ class View(App.Management.Tabs, Base):
RESPONSE.redirect(URL1+'/manage') RESPONSE.redirect(URL1+'/manage')
def tpURL(self): return self.getId() def tpURL(self): return self.getId()
def manage_options(self): def manage_options(self):
"""Return a manage option data structure for me instance """Return a manage option data structure for me instance
""" """
...@@ -58,7 +58,7 @@ class View(App.Management.Tabs, Base): ...@@ -58,7 +58,7 @@ class View(App.Management.Tabs, Base):
if l >= 0: if l >= 0:
pre=pre[:l] pre=pre[:l]
pre=pre+'/' pre=pre+'/'
r=[] r=[]
for d in self.aq_parent.aq_parent.manage_options: for d in self.aq_parent.aq_parent.manage_options:
path=d['action'] path=d['action']
...@@ -109,7 +109,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -109,7 +109,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
), ),
) )
__reserved_ids= ('values','items') __reserved_ids= ('values','items')
def property_extensible_schema__(self): def property_extensible_schema__(self):
"""Return a flag indicating whether new properties may be """Return a flag indicating whether new properties may be
...@@ -195,7 +195,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -195,7 +195,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
if hasattr(aq_base(self),id): if hasattr(aq_base(self),id):
if not (id=='title' and not self.__dict__.has_key(id)): if not (id=='title' and not self.__dict__.has_key(id)):
raise 'Bad Request', ( raise 'Bad Request', (
'Invalid property id, <em>%s</em>. It is in use.' % 'Invalid property id, <em>%s</em>. It is in use.' %
escape(id)) escape(id))
if meta is None: meta={} if meta is None: meta={}
prop={'id':id, 'type':type, 'meta':meta} prop={'id':id, 'type':type, 'meta':meta}
...@@ -261,7 +261,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -261,7 +261,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
def propertyItems(self): 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'], s.getProperty(i['id'])), return map(lambda i, s=self: (i['id'], s.getProperty(i['id'])),
self._propertyMap()) self._propertyMap())
def propertyInfo(self, id): def propertyInfo(self, id):
...@@ -316,7 +316,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -316,7 +316,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
attrs=''.join(attrs) attrs=''.join(attrs)
else: else:
# Quote non-xml items here? # Quote non-xml items here?
attrs='' attrs=''
if hasattr(self,"dav__"+name): if hasattr(self,"dav__"+name):
prop=' <n:%s%s>%s</n:%s>' % (name, attrs, value, name) prop=' <n:%s%s>%s</n:%s>' % (name, attrs, value, name)
...@@ -326,7 +326,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -326,7 +326,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
result.append(prop) result.append(prop)
if not result: return '' if not result: return ''
result='\n'.join(result) result='\n'.join(result)
return propstat % (self.xml_namespace(), result, '200 OK', '') return propstat % (self.xml_namespace(), result, '200 OK', '')
def dav__propnames(self, propstat=propstat): def dav__propnames(self, propstat=propstat):
...@@ -375,7 +375,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -375,7 +375,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
if not result.has_key(code): if not result.has_key(code):
result[code]=[prop] result[code]=[prop]
else: result[code].append(prop) else: result[code].append(prop)
return return
del propstat del propstat
...@@ -383,7 +383,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -383,7 +383,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
# Web interface # Web interface
manage=DTMLFile('dtml/properties', globals()) manage=DTMLFile('dtml/properties', globals())
def manage_propertiesForm(self, URL1): def manage_propertiesForm(self, URL1):
" " " "
...@@ -456,7 +456,7 @@ class Virtual: ...@@ -456,7 +456,7 @@ class Virtual:
def __init__(self): def __init__(self):
pass pass
def v_self(self): def v_self(self):
return self.aq_parent.aq_parent return self.aq_parent.aq_parent
...@@ -485,7 +485,7 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -485,7 +485,7 @@ class DAVProperties(Virtual, PropertySheet, View):
{'id':'supportedlock', 'mode':'r'}, {'id':'supportedlock', 'mode':'r'},
{'id':'lockdiscovery', 'mode':'r'}, {'id':'lockdiscovery', 'mode':'r'},
) )
def getProperty(self, id, default=None): def getProperty(self, id, default=None):
method='dav__%s' % id method='dav__%s' % id
if not hasattr(self, method): if not hasattr(self, method):
...@@ -506,10 +506,10 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -506,10 +506,10 @@ class DAVProperties(Virtual, PropertySheet, View):
if hasattr(self.v_self(), '_p_mtime'): if hasattr(self.v_self(), '_p_mtime'):
return self.pm + ({'id':'getlastmodified', 'mode':'r'},) return self.pm + ({'id':'getlastmodified', 'mode':'r'},)
return self.pm return self.pm
def propertyMap(self): def propertyMap(self):
return map(lambda dict: dict.copy(), self._propertyMap()) return map(lambda dict: dict.copy(), self._propertyMap())
def dav__creationdate(self): def dav__creationdate(self):
return iso8601_date(43200.0) return iso8601_date(43200.0)
...@@ -518,7 +518,7 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -518,7 +518,7 @@ class DAVProperties(Virtual, PropertySheet, View):
def dav__resourcetype(self): def dav__resourcetype(self):
vself=self.v_self() vself=self.v_self()
if (isDavCollection(vself) or if (isDavCollection(vself) or
getattr(aq_base(vself), 'isAnObjectManager', None)): getattr(aq_base(vself), 'isAnObjectManager', None)):
return '<n:collection/>' return '<n:collection/>'
return '' return ''
...@@ -559,7 +559,7 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -559,7 +559,7 @@ class DAVProperties(Virtual, PropertySheet, View):
def dav__lockdiscovery(self): def dav__lockdiscovery(self):
security = getSecurityManager() security = getSecurityManager()
user = security.getUser().getUserName() user = security.getUser().getUserName()
vself = self.v_self() vself = self.v_self()
out = '\n' out = '\n'
...@@ -570,9 +570,9 @@ class DAVProperties(Virtual, PropertySheet, View): ...@@ -570,9 +570,9 @@ class DAVProperties(Virtual, PropertySheet, View):
creator = lock.getCreator()[-1] creator = lock.getCreator()[-1]
if creator == user: fake=0 if creator == user: fake=0
else: fake=1 else: fake=1
out = '%s\n%s' % (out, lock.asLockDiscoveryProperty('n',fake=fake)) out = '%s\n%s' % (out, lock.asLockDiscoveryProperty('n',fake=fake))
out = '%s\n' % out out = '%s\n' % out
return out return out
...@@ -584,7 +584,7 @@ Globals.default__class_init__(DAVProperties) ...@@ -584,7 +584,7 @@ Globals.default__class_init__(DAVProperties)
class PropertySheets(Traversable, Implicit, App.Management.Tabs): class PropertySheets(Traversable, Implicit, App.Management.Tabs):
"""A tricky container to keep property sets from polluting """A tricky container to keep property sets from polluting
an object's direct attribute namespace.""" an object's direct attribute namespace."""
id='propertysheets' id='propertysheets'
__ac_permissions__=( __ac_permissions__=(
...@@ -603,7 +603,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -603,7 +603,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
webdav =DAVProperties() webdav =DAVProperties()
def _get_defaults(self): def _get_defaults(self):
return (self.webdav,) return (self.webdav,)
def __propsets__(self): def __propsets__(self):
propsets=self.aq_parent.__propsets__ propsets=self.aq_parent.__propsets__
__traceback_info__= propsets, type(propsets) __traceback_info__= propsets, type(propsets)
...@@ -631,7 +631,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -631,7 +631,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
r.append((id, n.__of__(self))) r.append((id, n.__of__(self)))
return r return r
def get(self, name, default=None): def get(self, name, default=None):
for propset in self.__propsets__(): for propset in self.__propsets__():
if propset.id==name or (hasattr(propset, 'xml_namespace') and \ if propset.id==name or (hasattr(propset, 'xml_namespace') and \
...@@ -657,7 +657,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -657,7 +657,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
if propset.getId() != name and propset.xml_namespace() != name: if propset.getId() != name and propset.xml_namespace() != name:
result.append(propset) result.append(propset)
self.parent.__propsets__=tuple(result) self.parent.__propsets__=tuple(result)
def __len__(self): def __len__(self):
return len(self.__propsets__()) return len(self.__propsets__())
...@@ -683,7 +683,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -683,7 +683,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
if l >= 0: if l >= 0:
pre=pre[:l] pre=pre[:l]
pre=pre+'/' pre=pre+'/'
r=[] r=[]
for d in self.aq_parent.manage_options: for d in self.aq_parent.manage_options:
r.append({'label': d['label'], 'action': pre+d['action']}) r.append({'label': d['label'], 'action': pre+d['action']})
...@@ -734,7 +734,7 @@ class FixedSchema(PropertySheet): ...@@ -734,7 +734,7 @@ class FixedSchema(PropertySheet):
if 'd' in mode: if 'd' in mode:
d['mode']=filter(lambda c: c != 'd', mode) d['mode']=filter(lambda c: c != 'd', mode)
r.append(d) r.append(d)
return tuple(r) return tuple(r)
def propertyMap(self): def propertyMap(self):
...@@ -745,7 +745,7 @@ class FixedSchema(PropertySheet): ...@@ -745,7 +745,7 @@ class FixedSchema(PropertySheet):
return self._base._extensible return self._base._extensible
Globals.default__class_init__(FixedSchema) Globals.default__class_init__(FixedSchema)
class vps(Base): class vps(Base):
...@@ -757,7 +757,7 @@ class vps(Base): ...@@ -757,7 +757,7 @@ class vps(Base):
""" """
def __init__(self, c=PropertySheets): def __init__(self, c=PropertySheets):
self.c=c self.c=c
def __of__(self, parent): def __of__(self, parent):
return self.c().__of__(parent) return self.c().__of__(parent)
...@@ -771,7 +771,7 @@ def xml_escape(v): ...@@ -771,7 +771,7 @@ def xml_escape(v):
""" convert any content from ISO-8859-1 to UTF-8 """ convert any content from ISO-8859-1 to UTF-8
The main use is to escape non-US object property values The main use is to escape non-US object property values
(e.g. containing accented characters). Also we convert "<" and ">" (e.g. containing accented characters). Also we convert "<" and ">"
to entities to keep the properties XML compliant. to entities to keep the properties XML compliant.
""" """
v = str(v) v = str(v)
v = v.replace('&', '&amp;') v = v.replace('&', '&amp;')
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # 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 '''This module implements a simple item mix-in for objects that have a
very simple (e.g. one-screen) management interface, like documents, very simple (e.g. one-screen) management interface, like documents,
Aqueduct database adapters, etc. Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new This module can also be used as a simple template for implementing new
item types. item types.
$Id: SimpleItem.py,v 1.101 2002/06/25 20:52:56 caseman Exp $''' $Id: SimpleItem.py,v 1.102 2002/08/14 21:42:56 mj Exp $'''
__version__='$Revision: 1.101 $'[11:-2] __version__='$Revision: 1.102 $'[11:-2]
import re, sys, Globals, App.Management, Acquisition, App.Undo import re, sys, Globals, App.Management, Acquisition, App.Undo
import AccessControl.Role, AccessControl.Owned, App.Common import AccessControl.Role, AccessControl.Owned, App.Common
...@@ -49,7 +49,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -49,7 +49,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
"""A common base class for simple, non-container objects.""" """A common base class for simple, non-container objects."""
isPrincipiaFolderish=0 isPrincipiaFolderish=0
isTopLevelPrincipiaApplicationObject=0 isTopLevelPrincipiaApplicationObject=0
def manage_afterAdd(self, item, container): pass def manage_afterAdd(self, item, container): pass
def manage_beforeDelete(self, item, container): pass def manage_beforeDelete(self, item, container): pass
def manage_afterClone(self, item): pass def manage_afterClone(self, item): pass
...@@ -81,17 +81,17 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -81,17 +81,17 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
# Meta type used for selecting all objects of a given type. # Meta type used for selecting all objects of a given type.
meta_type='simple item' meta_type='simple item'
# Default title. # Default title.
title='' title=''
# Default propertysheet info: # Default propertysheet info:
__propsets__=() __propsets__=()
manage_options=( manage_options=(
App.Undo.UndoSupport.manage_options App.Undo.UndoSupport.manage_options
+AccessControl.Owned.Owned.manage_options +AccessControl.Owned.Owned.manage_options
) )
# Attributes that must be acquired # Attributes that must be acquired
REQUEST=Acquisition.Acquired REQUEST=Acquisition.Acquired
...@@ -121,7 +121,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -121,7 +121,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
title=title() title=title()
id = self.getId() id = self.getId()
return title and ("%s (%s)" % (title,id)) or id return title and ("%s (%s)" % (title,id)) or id
def this(self): def this(self):
# Handy way to talk to ourselves in document templates. # Handy way to talk to ourselves in document templates.
return self return self
...@@ -147,7 +147,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -147,7 +147,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
try: try:
if error_type is None: error_type =sys.exc_info()[0] if error_type is None: error_type =sys.exc_info()[0]
if error_value is None: error_value=sys.exc_info()[1] if error_value is None: error_value=sys.exc_info()[1]
# allow for a few different traceback options # allow for a few different traceback options
if tb is None and error_tb is None: if tb is None and error_tb is None:
tb=sys.exc_info()[2] tb=sys.exc_info()[2]
...@@ -171,7 +171,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -171,7 +171,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
# Stop if there is recursion. # Stop if there is recursion.
raise error_type, error_value, tb raise error_type, error_value, tb
self._v_eek=1 self._v_eek=1
if str(error_type).lower() in ('redirect',): if str(error_type).lower() in ('redirect',):
raise error_type, error_value, tb raise error_type, error_value, tb
...@@ -227,7 +227,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -227,7 +227,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
def manage(self, URL1): def manage(self, URL1):
" " " "
raise 'Redirect', "%s/manage_main" % URL1 raise 'Redirect', "%s/manage_main" % URL1
# This keeps simple items from acquiring their parents # This keeps simple items from acquiring their parents
# objectValues, etc., when used in simple tree tags. # objectValues, etc., when used in simple tree tags.
...@@ -236,14 +236,14 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -236,14 +236,14 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
objectIds=objectItems=objectValues objectIds=objectItems=objectValues
# FTP support methods # FTP support methods
def manage_FTPstat(self,REQUEST): 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 from AccessControl.User import nobody
mode=0100000 mode=0100000
# check read permissions # check read permissions
if (hasattr(aq_base(self),'manage_FTPget') and if (hasattr(aq_base(self),'manage_FTPget') and
hasattr(self.manage_FTPget, '__roles__')): hasattr(self.manage_FTPget, '__roles__')):
try: try:
if getSecurityManager().validateValue(self.manage_FTPget): if getSecurityManager().validateValue(self.manage_FTPget):
...@@ -252,17 +252,17 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -252,17 +252,17 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
if nobody.allowed(self.manage_FTPget, if nobody.allowed(self.manage_FTPget,
self.manage_FTPget.__roles__): self.manage_FTPget.__roles__):
mode=mode | 0004 mode=mode | 0004
# check write permissions # check write permissions
if hasattr(aq_base(self),'PUT') and hasattr(self.PUT, '__roles__'): if hasattr(aq_base(self),'PUT') and hasattr(self.PUT, '__roles__'):
try: try:
if getSecurityManager().validateValue(self.PUT): if getSecurityManager().validateValue(self.PUT):
mode=mode | 0220 mode=mode | 0220
except: pass except: pass
if nobody.allowed(self.PUT, self.PUT.__roles__): if nobody.allowed(self.PUT, self.PUT.__roles__):
mode=mode | 0002 mode=mode | 0002
# get size # get size
if hasattr(aq_base(self), 'get_size'): if hasattr(aq_base(self), 'get_size'):
size=self.get_size() size=self.get_size()
...@@ -295,7 +295,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -295,7 +295,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
if not hasattr(ob,'aq_parent'): if not hasattr(ob,'aq_parent'):
break break
ob=ob.aq_parent ob=ob.aq_parent
stat=marshal.loads(self.manage_FTPstat(REQUEST)) stat=marshal.loads(self.manage_FTPstat(REQUEST))
id = self.getId() id = self.getId()
return marshal.dumps((id,stat)) return marshal.dumps((id,stat))
...@@ -331,11 +331,11 @@ class Item_w__name__(Item): ...@@ -331,11 +331,11 @@ class Item_w__name__(Item):
and getPhysicalPath() are designed to operate together. and getPhysicalPath() are designed to operate together.
''' '''
path = (self.__name__,) path = (self.__name__,)
p = aq_parent(aq_inner(self)) p = aq_parent(aq_inner(self))
if p is not None: if p is not None:
path = p.getPhysicalPath() + path path = p.getPhysicalPath() + path
return path return path
...@@ -358,7 +358,7 @@ class SimpleItem(Item, Globals.Persistent, ...@@ -358,7 +358,7 @@ class SimpleItem(Item, Globals.Persistent,
'action':'manage_access', 'action':'manage_access',
'help':('OFSP', 'Security.stx')}, 'help':('OFSP', 'Security.stx')},
) )
__ac_permissions__=(('View', ()),) __ac_permissions__=(('View', ()),)
def __repr__(self): def __repr__(self):
...@@ -385,4 +385,3 @@ class SimpleItem(Item, Globals.Persistent, ...@@ -385,4 +385,3 @@ class SimpleItem(Item, Globals.Persistent,
res += ' used for %s' % context_path res += ' used for %s' % context_path
res += '>' res += '>'
return res return res
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # 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. '''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.14 2002/02/07 17:20:59 andreasjung Exp $''' $Id: Traversable.py,v 1.15 2002/08/14 21:42:56 mj Exp $'''
__version__='$Revision: 1.14 $'[11:-2] __version__='$Revision: 1.15 $'[11:-2]
from Acquisition import Acquired, aq_inner, aq_parent, aq_base from Acquisition import Acquired, aq_inner, aq_parent, aq_base
...@@ -57,9 +57,9 @@ class Traversable: ...@@ -57,9 +57,9 @@ class Traversable:
and getPhysicalPath() are designed to operate together. and getPhysicalPath() are designed to operate together.
''' '''
path = (self.getId(),) path = (self.getId(),)
p = aq_parent(aq_inner(self)) p = aq_parent(aq_inner(self))
if p is not None: if p is not None:
path = p.getPhysicalPath() + path path = p.getPhysicalPath() + path
return path return path
...@@ -94,7 +94,7 @@ class Traversable: ...@@ -94,7 +94,7 @@ class Traversable:
self=self.getPhysicalRoot() self=self.getPhysicalRoot()
if (restricted and not securityManager.validateValue(self)): if (restricted and not securityManager.validateValue(self)):
raise Unauthorized, name raise Unauthorized, name
try: try:
object = self object = self
while path: while path:
...@@ -127,7 +127,7 @@ class Traversable: ...@@ -127,7 +127,7 @@ class Traversable:
if (not securityManager.validate(object, if (not securityManager.validate(object,
container, name, o)): container, name, o)):
raise Unauthorized, name raise Unauthorized, name
else: else:
o=get(object, name, M) o=get(object, name, M)
if o is not M: if o is not M:
...@@ -142,7 +142,7 @@ class Traversable: ...@@ -142,7 +142,7 @@ class Traversable:
if not securityManager.validate( if not securityManager.validate(
object, N, name, o): object, N, name, o):
raise Unauthorized, name raise Unauthorized, name
else: else:
o=object[name] o=object[name]
if (restricted and not securityManager.validate( if (restricted and not securityManager.validate(
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
""" """
Objects for packages that have been uninstalled. Objects for packages that have been uninstalled.
...@@ -23,7 +23,7 @@ from cgi import escape ...@@ -23,7 +23,7 @@ from cgi import escape
broken_klasses={} broken_klasses={}
broken_klasses_lock = allocate_lock() broken_klasses_lock = allocate_lock()
class BrokenClass(Acquisition.Explicit, SimpleItem.Item, class BrokenClass(Acquisition.Explicit, SimpleItem.Item,
Persistence.Overridable): Persistence.Overridable):
_p_changed=0 _p_changed=0
meta_type='Broken Because Product is Gone' meta_type='Broken Because Product is Gone'
...@@ -47,7 +47,7 @@ class BrokenClass(Acquisition.Explicit, SimpleItem.Item, ...@@ -47,7 +47,7 @@ class BrokenClass(Acquisition.Explicit, SimpleItem.Item,
manage=manage_main=Globals.DTMLFile('dtml/brokenEdit',globals()) manage=manage_main=Globals.DTMLFile('dtml/brokenEdit',globals())
manage_workspace=manage manage_workspace=manage
def Broken(self, oid, pair): def Broken(self, oid, pair):
broken_klasses_lock.acquire() broken_klasses_lock.acquire()
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import Shared.DC.xml.ppml import Shared.DC.xml.ppml
ppml=Shared.DC.xml.ppml ppml=Shared.DC.xml.ppml
...@@ -117,4 +117,3 @@ def importXML(jar, file, clue=''): ...@@ -117,4 +117,3 @@ def importXML(jar, file, clue=''):
r=p.Parse(data) r=p.Parse(data)
outfile.seek(0) outfile.seek(0)
return jar.importFile(outfile,clue) return jar.importFile(outfile,clue)
This diff is collapsed.
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""A utility module for content-type handling.""" """A utility module for content-type handling."""
__version__='$Revision: 1.17 $'[11:-2] __version__='$Revision: 1.18 $'[11:-2]
import re, mimetypes import re, mimetypes
...@@ -86,15 +86,14 @@ def guess_content_type(name='', body='', default=None): ...@@ -86,15 +86,14 @@ def guess_content_type(name='', body='', default=None):
if find_binary(body) is not None: if find_binary(body) is not None:
type=default or 'application/octet-stream' type=default or 'application/octet-stream'
else: else:
type=(default or text_type(body) type=(default or text_type(body)
or 'text/x-unknown-content-type') or 'text/x-unknown-content-type')
else: else:
type=default or 'text/x-unknown-content-type' type=default or 'text/x-unknown-content-type'
return type.lower(), enc and enc.lower() or None return type.lower(), enc and enc.lower() or None
if __name__=='__main__': if __name__=='__main__':
items=mimetypes.types_map.items() items=mimetypes.types_map.items()
items.sort() items.sort()
for item in items: print "%s:\t%s" % item for item in items: print "%s:\t%s" % item
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
from App.ImageFile import ImageFile from App.ImageFile import ImageFile
...@@ -21,7 +21,7 @@ class misc_: ...@@ -21,7 +21,7 @@ class misc_:
class p_: class p_:
"Shared system information" "Shared system information"
__roles__=None __roles__=None
broken=ImageFile('www/broken.gif', globals()) broken=ImageFile('www/broken.gif', globals())
User_icon =ImageFile('AccessControl/www/User_icon.gif') User_icon =ImageFile('AccessControl/www/User_icon.gif')
......
...@@ -14,7 +14,7 @@ Print a human-friendly file difference report to stdout. Both inter- ...@@ -14,7 +14,7 @@ Print a human-friendly file difference report to stdout. Both inter-
and intra-line differences are noted. In the second form, recreate file1 and intra-line differences are noted. In the second form, recreate file1
(-r1) or file2 (-r2) on stdout, from an ndiff report on stdin. (-r1) or file2 (-r2) on stdout, from an ndiff report on stdin.
In the first form, if -q ("quiet") is not specified, the first two lines In the first form, if -q ("quiet") is not specified, the first two lines
of output are of output are
-: file1 -: file1
...@@ -28,7 +28,7 @@ Each remaining line begins with a two-letter code: ...@@ -28,7 +28,7 @@ Each remaining line begins with a two-letter code:
"? " line not present in either input file "? " line not present in either input file
Lines beginning with "? " attempt to guide the eye to intraline Lines beginning with "? " attempt to guide the eye to intraline
differences, and were not present in either input file. These lines can differences, and were not present in either input file. These lines can
be confusing if the source files contain tab characters. be confusing if the source files contain tab characters.
The first file can be recovered by retaining only lines that begin with The first file can be recovered by retaining only lines that begin with
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 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, # 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. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
"""Restricted unpickler""" """Restricted unpickler"""
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
import pickle import pickle
...@@ -42,5 +42,3 @@ def register(mod, cls, obj): ...@@ -42,5 +42,3 @@ def register(mod, cls, obj):
def unregister(mod, cls): def unregister(mod, cls):
"""Unregister a class""" """Unregister a class"""
del reg[(mod,cls)] del reg[(mod,cls)]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment