Commit 4be8d559 authored by Andreas Jung's avatar Andreas Jung

replaced string module calls by string methods

parent f84b5394
...@@ -12,12 +12,11 @@ ...@@ -12,12 +12,11 @@
############################################################################## ##############################################################################
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.179 2002/01/09 19:14:03 andreasjung Exp $''' $Id: Application.py,v 1.180 2002/02/07 17:20:59 andreasjung Exp $'''
__version__='$Revision: 1.179 $'[11:-2] __version__='$Revision: 1.180 $'[11:-2]
import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_ import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
import time, traceback, os, string, Products import time, traceback, os, Products
from string import strip, lower, find, rfind, join
from DateTime import DateTime from DateTime import DateTime
from AccessControl.User import UserFolder from AccessControl.User import UserFolder
from App.ApplicationManager import ApplicationManager from App.ApplicationManager import ApplicationManager
...@@ -83,7 +82,7 @@ class Application(Globals.ApplicationDefaultPermissions, ...@@ -83,7 +82,7 @@ class Application(Globals.ApplicationDefaultPermissions,
def PrincipiaRedirect(self,destination,URL1): def PrincipiaRedirect(self,destination,URL1):
"""Utility function to allow user-controlled redirects""" """Utility function to allow user-controlled redirects"""
if find(destination,'//') >= 0: raise 'Redirect', destination if destination.find('//') >= 0: raise 'Redirect', destination
raise 'Redirect', ("%s/%s" % (URL1, destination)) raise 'Redirect', ("%s/%s" % (URL1, destination))
Redirect=ZopeRedirect=PrincipiaRedirect Redirect=ZopeRedirect=PrincipiaRedirect
......
...@@ -12,12 +12,11 @@ ...@@ -12,12 +12,11 @@
############################################################################## ##############################################################################
__doc__="""Cacheable object and cache management base classes. __doc__="""Cacheable object and cache management base classes.
$Id: Cache.py,v 1.8 2001/11/28 15:50:57 matt Exp $""" $Id: Cache.py,v 1.9 2002/02/07 17:20:59 andreasjung Exp $"""
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
import time, sys import time, sys
from string import join
import Globals import Globals
from Globals import DTMLFile from Globals import DTMLFile
from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base
...@@ -373,7 +372,7 @@ def findCacheables(ob, manager_id, require_assoc, subfolders, ...@@ -373,7 +372,7 @@ def findCacheables(ob, manager_id, require_assoc, subfolders,
icon = getattr(aq_base(subob), 'icon', '') icon = getattr(aq_base(subob), 'icon', '')
info = { info = {
'sortkey': subpath, 'sortkey': subpath,
'path': join(subpath, '/'), 'path': '/'.join(subpath),
'title': getattr(aq_base(subob), 'title', ''), 'title': getattr(aq_base(subob), 'title', ''),
'icon': icon, 'icon': icon,
'associated': associated,} 'associated': associated,}
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
# #
############################################################################## ##############################################################################
__doc__="""Copy interface""" __doc__="""Copy interface"""
__version__='$Revision: 1.77 $'[11:-2] __version__='$Revision: 1.78 $'[11:-2]
import sys, string, Globals, Moniker, tempfile, ExtensionClass import sys, Globals, Moniker, tempfile, ExtensionClass
from marshal import loads, dumps from marshal import loads, dumps
from urllib import quote, unquote from urllib import quote, unquote
from zlib import compress, decompress from zlib import compress, decompress
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
############################################################################## ##############################################################################
"""DTML Document objects.""" """DTML Document objects."""
__version__='$Revision: 1.45 $'[11:-2] __version__='$Revision: 1.46 $'[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
...@@ -23,7 +23,6 @@ from webdav.common import rfc1123_date ...@@ -23,7 +23,6 @@ from webdav.common import rfc1123_date
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from webdav.WriteLockInterface import WriteLockInterface from webdav.WriteLockInterface import WriteLockInterface
from sgmllib import SGMLParser from sgmllib import SGMLParser
from string import find
from urllib import quote from urllib import quote
import Globals import Globals
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
......
...@@ -12,11 +12,10 @@ ...@@ -12,11 +12,10 @@
############################################################################## ##############################################################################
"""DTML Method objects.""" """DTML Method objects."""
__version__='$Revision: 1.73 $'[11:-2] __version__='$Revision: 1.74 $'[11:-2]
import History import History
from Globals import HTML, DTMLFile, MessageDialog from Globals import HTML, DTMLFile, MessageDialog
from string import join,split,strip,rfind,atoi,lower
from SimpleItem import Item_w__name__, pretty_tb from SimpleItem import Item_w__name__, pretty_tb
from OFS.content_types import guess_content_type from OFS.content_types import guess_content_type
from PropertyManager import PropertyManager from PropertyManager import PropertyManager
...@@ -188,7 +187,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -188,7 +187,7 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
''' '''
ks = [] ks = []
for key in keys: for key in keys:
key = strip(str(key)) key = str(key).strip()
if key: if key:
ks.append(key) ks.append(key)
self._cache_namespace_keys = tuple(ks) self._cache_namespace_keys = tuple(ks)
...@@ -222,8 +221,8 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -222,8 +221,8 @@ 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=max(1,atoi(dtpref_rows)+dr) rows=max(1,int(dtpref_rows)+dr)
cols=max(40,atoi(dtpref_cols)+dc) cols=max(40,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)
...@@ -338,7 +337,6 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager, ...@@ -338,7 +337,6 @@ class DTMLMethod(RestrictedDTML, HTML, Acquisition.Implicit, RoleManager,
)) ))
import re import re
from string import find, strip
token = "[a-zA-Z0-9!#$%&'*+\-.\\\\^_`|~]+" token = "[a-zA-Z0-9!#$%&'*+\-.\\\\^_`|~]+"
hdr_start = re.compile(r'(%s):(.*)' % token).match hdr_start = re.compile(r'(%s):(.*)' % token).match
...@@ -355,9 +353,9 @@ def decapitate(html, RESPONSE=None): ...@@ -355,9 +353,9 @@ 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, '\n', spos) eol = html.find( '\n', spos)
if eol < 0: return html if eol < 0: return html
header.append(strip(html[spos:eol])) header.append(html[spos:eol].strip())
spos = eol + 1 spos = eol + 1
if RESPONSE is not None: if RESPONSE is not None:
for header in headers: for header in headers:
......
...@@ -15,11 +15,10 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification) ...@@ -15,11 +15,10 @@ 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.4 2001/11/28 15:50:57 matt Exp $""" $Id: DefaultObservable.py,v 1.5 2002/02/07 17:20:59 andreasjung Exp $"""
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
import string
from types import StringType from types import StringType
class DefaultObservable: class DefaultObservable:
...@@ -63,7 +62,7 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification ...@@ -63,7 +62,7 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification
# 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 = string.join( observer, '/' ) observer = '/'.join( observer)
return observer return observer
......
...@@ -11,16 +11,16 @@ ...@@ -11,16 +11,16 @@
# #
############################################################################## ##############################################################################
__doc__="""Find support""" __doc__="""Find support"""
__version__='$Revision: 1.28 $'[11:-2] __version__='$Revision: 1.29 $'[11:-2]
import sys, os, string, time, Globals, ExtensionClass import sys, os, time, Globals, ExtensionClass
from DocumentTemplate.DT_Util import Eval from DocumentTemplate.DT_Util import Eval
from AccessControl.Permission import name_trans from AccessControl.Permission import name_trans
from Globals import DTMLFile from Globals import DTMLFile
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
from DateTime import DateTime from DateTime import DateTime
from string import find from string import translate
from AccessControl.DTML import RestrictedDTML from AccessControl.DTML import RestrictedDTML
class FindSupport(ExtensionClass.Base): class FindSupport(ExtensionClass.Base):
...@@ -114,7 +114,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -114,7 +114,7 @@ class FindSupport(ExtensionClass.Base):
and and
(not obj_searchterm or (not obj_searchterm or
(hasattr(ob, 'PrincipiaSearchSource') and (hasattr(ob, 'PrincipiaSearchSource') and
find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0 ob.PrincipiaSearchSource().find(obj_searchterm) >= 0
)) ))
and and
(not obj_expr or expr_match(ob, obj_expr)) (not obj_expr or expr_match(ob, obj_expr))
...@@ -213,7 +213,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -213,7 +213,7 @@ class FindSupport(ExtensionClass.Base):
and and
(not obj_searchterm or (not obj_searchterm or
(hasattr(ob, 'PrincipiaSearchSource') and (hasattr(ob, 'PrincipiaSearchSource') and
find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0 ob.PrincipiaSearchSource().find(obj_searchterm) >= 0
)) ))
and and
(not obj_expr or expr_match(ob, obj_expr)) (not obj_expr or expr_match(ob, obj_expr))
...@@ -306,6 +306,6 @@ def absattr(attr): ...@@ -306,6 +306,6 @@ def absattr(attr):
def p_name(name): def p_name(name):
return '_' + string.translate(name, name_trans) + '_Permission' return '_' + translate(name, name_trans) + '_Permission'
...@@ -12,12 +12,11 @@ ...@@ -12,12 +12,11 @@
############################################################################## ##############################################################################
"""Object Histories""" """Object Histories"""
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import Globals, ndiff, ExtensionClass import Globals, ndiff, ExtensionClass
from DateTime import DateTime from DateTime import DateTime
from Acquisition import Implicit, aq_base from Acquisition import Implicit, aq_base
from string import join, split, atoi, strip
from struct import pack, unpack from struct import pack, unpack
from cgi import escape from cgi import escape
...@@ -59,7 +58,7 @@ class Historian(Implicit): ...@@ -59,7 +58,7 @@ class Historian(Implicit):
def __getitem__(self, key): def __getitem__(self, key):
self=self.aq_parent self=self.aq_parent
serial=apply(pack, ('>HHHH',)+tuple(map(atoi, split(key,'.')))) serial=apply(pack, ('>HHHH',)+tuple(map(int, key.split('.'))))
if serial == self._p_serial: return self if serial == self._p_serial: return self
...@@ -117,7 +116,7 @@ class Historical(ExtensionClass.Base): ...@@ -117,7 +116,7 @@ class Historical(ExtensionClass.Base):
for d in r: for d in r:
d['time']=DateTime(d['time']) d['time']=DateTime(d['time'])
d['key']=join(map(str, unpack(">HHHH", d['serial'])),'.') d['key']='.'.join(map(str, unpack(">HHHH", d['serial'])))
return r return r
...@@ -135,7 +134,7 @@ class Historical(ExtensionClass.Base): ...@@ -135,7 +134,7 @@ class Historical(ExtensionClass.Base):
"copied to the present.<p>") "copied to the present.<p>")
key=keys[0] key=keys[0]
serial=apply(pack, ('>HHHH',)+tuple(map(atoi, split(key,'.')))) serial=apply(pack, ('>HHHH',)+tuple(map(int, key.split('.'))))
if serial != self._p_serial: if serial != self._p_serial:
self.manage_beforeHistoryCopy() self.manage_beforeHistoryCopy()
...@@ -175,12 +174,12 @@ class Historical(ExtensionClass.Base): ...@@ -175,12 +174,12 @@ class Historical(ExtensionClass.Base):
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(atoi, split(keys[-1],'.')))) 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(atoi, split(keys[0],'.')))) ('>HHHH',)+tuple(map(int, keys[0].split('.'))))
rev2=historicalRevision(self, serial) rev2=historicalRevision(self, serial)
else: else:
...@@ -200,7 +199,7 @@ def dump(tag, x, lo, hi, r): ...@@ -200,7 +199,7 @@ def dump(tag, x, lo, hi, r):
"<td><pre>\n%s\n</pre></td>\n" "<td><pre>\n%s\n</pre></td>\n"
"<td><pre>\n%s\n</pre></td>\n" "<td><pre>\n%s\n</pre></td>\n"
"</tr>\n" "</tr>\n"
% (join(r1,'\n'), escape(join(r2, '\n')))) % ('\n'.join(r1), escape('\n'.join(r2))))
def replace(x, xlo, xhi, y, ylo, yhi, r): def replace(x, xlo, xhi, y, ylo, yhi, r):
...@@ -221,12 +220,13 @@ def replace(x, xlo, xhi, y, ylo, yhi, r): ...@@ -221,12 +220,13 @@ def replace(x, xlo, xhi, y, ylo, yhi, r):
"<td><pre>\n%s\n%s\n</pre></td>\n" "<td><pre>\n%s\n%s\n</pre></td>\n"
"<td><pre>\n%s\n%s\n</pre></td>\n" "<td><pre>\n%s\n%s\n</pre></td>\n"
"</tr>\n" "</tr>\n"
% (join(rx1, '\n'), join(ry1, '\n'), % ('\n'.join(rx1), '\n'.join(ry1),
escape(join(rx2, '\n')), escape(join(ry2, '\n')))) escape('\n'.join(rx2)), escape('\n'.join(ry2))))
def html_diff(s1, s2): def html_diff(s1, s2):
a=split(s1,'\n') from string import split
b=split(s2,'\n') a=s1.split('\n')
b=s2.split('\n')
cruncher=ndiff.SequenceMatcher(isjunk=split, a=a, b=b) cruncher=ndiff.SequenceMatcher(isjunk=split, a=a, b=b)
r=['<table border=1>'] r=['<table border=1>']
...@@ -243,4 +243,4 @@ def html_diff(s1, s2): ...@@ -243,4 +243,4 @@ def html_diff(s1, s2):
raise ValueError, 'unknown tag ' + `tag` raise ValueError, 'unknown tag ' + `tag`
r.append('</table>') r.append('</table>')
return join(r, '\n') return '\n'.join(r)
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
############################################################################## ##############################################################################
"""Image object""" """Image object"""
__version__='$Revision: 1.134 $'[11:-2] __version__='$Revision: 1.135 $'[11:-2]
import Globals, string, struct import Globals, struct
from OFS.content_types import guess_content_type from OFS.content_types import guess_content_type
from Globals import DTMLFile from Globals import DTMLFile
from PropertyManager import PropertyManager from PropertyManager import PropertyManager
...@@ -133,7 +133,7 @@ class File(Persistent, Implicit, PropertyManager, ...@@ -133,7 +133,7 @@ class File(Persistent, Implicit, PropertyManager,
# HTTP If-Modified-Since header handling. # HTTP If-Modified-Since header handling.
header=REQUEST.get_header('If-Modified-Since', None) header=REQUEST.get_header('If-Modified-Since', None)
if header is not None: if header is not None:
header=string.split(header, ';')[0] header=header.split( ';')[0]
# Some proxies seem to send invalid date strings for this # Some proxies seem to send invalid date strings for this
# header. If the date string is not valid, we ignore it # header. If the date string is not valid, we ignore it
# rather than raise an error to be generally consistent # rather than raise an error to be generally consistent
...@@ -192,7 +192,7 @@ class File(Persistent, Implicit, PropertyManager, ...@@ -192,7 +192,7 @@ class File(Persistent, Implicit, PropertyManager,
ranges = None ranges = None
else: else:
# Date # Date
date = string.split(if_range, ';')[0] date = if_range.split( ';')[0]
try: mod_since=long(DateTime(date).timeTime()) try: mod_since=long(DateTime(date).timeTime())
except: mod_since=None except: mod_since=None
if mod_since is not None: if mod_since is not None:
...@@ -745,7 +745,7 @@ class Image(File): ...@@ -745,7 +745,7 @@ class Image(File):
if width: if width:
result = '%s width="%s"' % (result, width) result = '%s width="%s"' % (result, width)
if not 'border' in map(string.lower, args.keys()): if not 'border' in [ x.lower() for x in args.keys()]:
result = '%s border="0"' % result result = '%s border="0"' % result
if css_class is not None: if css_class is not None:
...@@ -762,9 +762,9 @@ def cookId(id, title, file): ...@@ -762,9 +762,9 @@ def cookId(id, title, file):
if not id and hasattr(file,'filename'): if not id and hasattr(file,'filename'):
filename=file.filename filename=file.filename
title=title or filename title=title or filename
id=filename[max(string.rfind(filename, '/'), id=filename[max(filename.rfind('/'),
string.rfind(filename, '\\'), filename.rfind('\\'),
string.rfind(filename, ':'), filename.rfind(':'),
)+1:] )+1:]
return id, title return id, title
...@@ -793,7 +793,7 @@ class Pdata(Persistent, Implicit): ...@@ -793,7 +793,7 @@ class Pdata(Persistent, Implicit):
r.append(self.data) r.append(self.data)
next=self.next next=self.next
return string.join(r,'') return ''.join(r)
......
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
and aquisition relationships via a simple interface. and aquisition relationships via a simple interface.
""" """
__version__='$Revision: 1.14 $'[11:-2] __version__='$Revision: 1.15 $'[11:-2]
import Globals import Globals
import string
class Moniker: class Moniker:
"""An object moniker is an intelligent reference to a """An object moniker is an intelligent reference to a
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
############################################################################## ##############################################################################
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.145 2001/11/28 15:50:57 matt Exp $""" $Id: ObjectManager.py,v 1.146 2002/02/07 17:20:59 andreasjung Exp $"""
__version__='$Revision: 1.145 $'[11:-2] __version__='$Revision: 1.146 $'[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
...@@ -31,7 +31,7 @@ import marshal ...@@ -31,7 +31,7 @@ import marshal
import App.Common import App.Common
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
import sys,string,fnmatch,copy import sys,fnmatch,copy
import XMLExportImport import XMLExportImport
customImporters={ customImporters={
......
...@@ -12,14 +12,13 @@ ...@@ -12,14 +12,13 @@
############################################################################## ##############################################################################
"""Property management""" """Property management"""
__version__='$Revision: 1.42 $'[11:-2] __version__='$Revision: 1.43 $'[11:-2]
import ExtensionClass, Globals import ExtensionClass, Globals
import ZDOM import ZDOM
from PropertySheets import DefaultPropertySheets, vps from PropertySheets import DefaultPropertySheets, vps
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import DTMLFile, MessageDialog from Globals import DTMLFile, MessageDialog
from string import find,join,lower,split
from Acquisition import Implicit, aq_base from Acquisition import Implicit, aq_base
from Globals import Persistent from Globals import Persistent
......
...@@ -12,13 +12,12 @@ ...@@ -12,13 +12,12 @@
############################################################################## ##############################################################################
"""Property sheets""" """Property sheets"""
__version__='$Revision: 1.81 $'[11:-2] __version__='$Revision: 1.82 $'[11:-2]
import time, string, App.Management, Globals import time, App.Management, Globals
from webdav.WriteLockInterface import WriteLockInterface from webdav.WriteLockInterface import WriteLockInterface
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import DTMLFile, MessageDialog from Globals import DTMLFile, MessageDialog
from string import find,join,lower,split,rfind
from Acquisition import Implicit, Explicit from Acquisition import Implicit, Explicit
from App.Common import rfc1123_date, iso8601_date from App.Common import rfc1123_date, iso8601_date
from webdav.common import urlbase from webdav.common import urlbase
...@@ -52,7 +51,7 @@ class View(App.Management.Tabs, Base): ...@@ -52,7 +51,7 @@ class View(App.Management.Tabs, Base):
else: else:
pre=r['URL'] pre=r['URL']
for i in (1,2,3): for i in (1,2,3):
l=rfind(pre,'/') l=pre.rfind('/')
if l >= 0: if l >= 0:
pre=pre[:l] pre=pre[:l]
pre=pre+'/' pre=pre+'/'
...@@ -70,10 +69,10 @@ class View(App.Management.Tabs, Base): ...@@ -70,10 +69,10 @@ class View(App.Management.Tabs, Base):
return r return r
def tabs_path_info(self, script, path): def tabs_path_info(self, script, path):
l=rfind(path,'/') l=path.rfind('/')
if l >= 0: if l >= 0:
path=path[:l] path=path[:l]
l=rfind(path,'/') l=path.rfind('/')
if l >= 0: path=path[:l] if l >= 0: path=path[:l]
return View.inheritedAttribute('tabs_path_info')( return View.inheritedAttribute('tabs_path_info')(
self, script, path) self, script, path)
...@@ -285,7 +284,7 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -285,7 +284,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
' %s\n' \ ' %s\n' \
' </d:responsedescription>\n' ' </d:responsedescription>\n'
def dav__allprop(self, propstat=propstat, join=string.join): def dav__allprop(self, propstat=propstat ):
# DAV helper method - return one or more propstat elements # DAV helper method - return one or more propstat elements
# indicating property names and values for all properties. # indicating property names and values for all properties.
result=[] result=[]
...@@ -294,14 +293,14 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -294,14 +293,14 @@ class PropertySheet(Traversable, Persistent, Implicit):
value=self.getProperty(name) value=self.getProperty(name)
if type=='tokens': if type=='tokens':
value=join(str(value), ' ') value=' '.join(str(value))
elif type=='lines': elif type=='lines':
value=join(str(value), '\n') value='\n'.join(str(value))
# check for xml property # check for xml property
attrs=item.get('meta', {}).get('__xml_attrs__', None) attrs=item.get('meta', {}).get('__xml_attrs__', None)
if attrs is not None: if attrs is not None:
attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=map(lambda n: ' %s="%s"' % n, attrs.items())
attrs=join(attrs, '') attrs=''.join(attrs)
else: else:
# Quote non-xml items here? # Quote non-xml items here?
attrs='' attrs=''
...@@ -313,24 +312,23 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -313,24 +312,23 @@ class PropertySheet(Traversable, Persistent, Implicit):
result.append(prop) result.append(prop)
if not result: return '' if not result: return ''
result=join(result, '\n') 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, join=string.join): def dav__propnames(self, propstat=propstat):
# DAV helper method - return a propstat element indicating # DAV helper method - return a propstat element indicating
# property names for all properties in this PropertySheet. # property names for all properties in this PropertySheet.
result=[] result=[]
for name in self.propertyIds(): for name in self.propertyIds():
result.append(' <n:%s/>' % name) result.append(' <n:%s/>' % name)
if not result: return '' if not result: return ''
result=join(result, '\n') result='\n'.join(result)
return propstat % (self.xml_namespace(), result, '200 OK', '') return propstat % (self.xml_namespace(), result, '200 OK', '')
def dav__propstat(self, name, result, def dav__propstat(self, name, result,
propstat=propstat, propdesc=propdesc, propstat=propstat, propdesc=propdesc):
join=string.join):
# DAV helper method - return a propstat element indicating # DAV helper method - return a propstat element indicating
# property name and value for the requested property. # property name and value for the requested property.
xml_id=self.xml_namespace() xml_id=self.xml_namespace()
...@@ -347,14 +345,14 @@ class PropertySheet(Traversable, Persistent, Implicit): ...@@ -347,14 +345,14 @@ class PropertySheet(Traversable, Persistent, Implicit):
name, type=item['id'], item.get('type','string') name, type=item['id'], item.get('type','string')
value=self.getProperty(name) value=self.getProperty(name)
if type=='tokens': if type=='tokens':
value=join(str(value), ' ') value=' '.join(str(value))
elif type=='lines': elif type=='lines':
value=join(str(value), '\n') value='\n'.join(str(value))
# allow for xml properties # allow for xml properties
attrs=item.get('meta', {}).get('__xml_attrs__', None) attrs=item.get('meta', {}).get('__xml_attrs__', None)
if attrs is not None: if attrs is not None:
attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=map(lambda n: ' %s="%s"' % n, attrs.items())
attrs=join(attrs, '') attrs=''.join(attrs)
else: else:
# quote non-xml items here? # quote non-xml items here?
attrs='' attrs=''
...@@ -664,7 +662,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -664,7 +662,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
else: else:
pre=r['URL'] pre=r['URL']
for i in (1,2): for i in (1,2):
l=rfind(pre,'/') l=pre.rfind('/')
if l >= 0: if l >= 0:
pre=pre[:l] pre=pre[:l]
pre=pre+'/' pre=pre+'/'
...@@ -675,7 +673,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -675,7 +673,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
return r return r
def tabs_path_info(self, script, path): def tabs_path_info(self, script, path):
l=rfind(path,'/') l=path.rfind('/')
if l >= 0: path=path[:l] if l >= 0: path=path[:l]
return PropertySheets.inheritedAttribute('tabs_path_info')( return PropertySheets.inheritedAttribute('tabs_path_info')(
self, script, path) self, script, path)
......
...@@ -17,15 +17,14 @@ Aqueduct database adapters, etc. ...@@ -17,15 +17,14 @@ 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.92 2001/11/28 15:50:57 matt Exp $''' $Id: SimpleItem.py,v 1.93 2002/02/07 17:20:59 andreasjung Exp $'''
__version__='$Revision: 1.92 $'[11:-2] __version__='$Revision: 1.93 $'[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
from webdav.Resource import Resource from webdav.Resource import Resource
from ExtensionClass import Base from ExtensionClass import Base
from CopySupport import CopySource from CopySupport import CopySource
from string import join, lower, find, split
from types import InstanceType, StringType from types import InstanceType, StringType
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
...@@ -162,7 +161,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -162,7 +161,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
raise error_type, error_value, tb raise error_type, error_value, tb
self._v_eek=1 self._v_eek=1
if lower(str(error_type)) in ('redirect',): if str(error_type).lower() in ('redirect',):
raise error_type, error_value, tb raise error_type, error_value, tb
if not error_message: if not error_message:
...@@ -342,12 +341,12 @@ def format_exception(etype,value,tb,limit=None): ...@@ -342,12 +341,12 @@ def format_exception(etype,value,tb,limit=None):
except: pass except: pass
tb = tb.tb_next tb = tb.tb_next
n = n+1 n = n+1
result.append(join(traceback.format_exception_only(etype, value),' ')) result.append(' '.join(traceback.format_exception_only(etype, value)))
return result return result
def pretty_tb(t,v,tb): def pretty_tb(t,v,tb):
tb=format_exception(t,v,tb,200) tb=format_exception(t,v,tb,200)
tb=join(tb,'\n') tb='\n'.join(tb)
return tb return tb
class SimpleItem(Item, Globals.Persistent, class SimpleItem(Item, Globals.Persistent,
......
...@@ -12,14 +12,13 @@ ...@@ -12,14 +12,13 @@
############################################################################## ##############################################################################
'''This module implements a mix-in for traversable objects. '''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.13 2001/11/28 15:50:57 matt Exp $''' $Id: Traversable.py,v 1.14 2002/02/07 17:20:59 andreasjung Exp $'''
__version__='$Revision: 1.13 $'[11:-2] __version__='$Revision: 1.14 $'[11:-2]
from Acquisition import Acquired, aq_inner, aq_parent, aq_base from Acquisition import Acquired, aq_inner, aq_parent, aq_base
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl import Unauthorized from AccessControl import Unauthorized
from string import split, join
from urllib import quote from urllib import quote
_marker=[] _marker=[]
...@@ -44,8 +43,8 @@ class Traversable: ...@@ -44,8 +43,8 @@ class Traversable:
path = map(quote, spp[i:]) path = map(quote, spp[i:])
if relative: if relative:
# This is useful for physical path relative to a VirtualRoot # This is useful for physical path relative to a VirtualRoot
return join(path, '/') return '/'.join(path)
return join([req['SERVER_URL']] + req._script + path, '/') return '/'.join([req['SERVER_URL']] + req._script + path)
getPhysicalRoot__roles__=() # Private getPhysicalRoot__roles__=() # Private
getPhysicalRoot=Acquired getPhysicalRoot=Acquired
...@@ -75,7 +74,7 @@ class Traversable: ...@@ -75,7 +74,7 @@ class Traversable:
N=None N=None
M=_marker M=_marker
if type(path) is StringType: path = split(path,'/') if type(path) is StringType: path = path.split('/')
else: path=list(path) else: path=list(path)
REQUEST={'TraversalRequestNameStack': path} REQUEST={'TraversalRequestNameStack': path}
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
""" """
Objects for packages that have been uninstalled. Objects for packages that have been uninstalled.
""" """
import string, SimpleItem, Globals, Acquisition import SimpleItem, Globals, Acquisition
from Acquisition import Acquired from Acquisition import Acquired
import Persistence import Persistence
from thread import allocate_lock from thread import allocate_lock
...@@ -59,7 +59,7 @@ def Broken(self, oid, pair): ...@@ -59,7 +59,7 @@ def Broken(self, oid, pair):
exec ("class %s(BrokenClass): ' '; __module__=%s" exec ("class %s(BrokenClass): ' '; __module__=%s"
% (klassname, `module`)) in d % (klassname, `module`)) in d
klass = broken_klasses[pair] = d[klassname] klass = broken_klasses[pair] = d[klassname]
module=string.split(module,'.') module=module.split('.')
if len(module) > 2 and module[0]=='Products': if len(module) > 2 and module[0]=='Products':
klass.product_name= module[1] klass.product_name= module[1]
klass.title=( klass.title=(
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import Shared.DC.xml.ppml, string import Shared.DC.xml.ppml
ppml=Shared.DC.xml.ppml ppml=Shared.DC.xml.ppml
from base64 import encodestring from base64 import encodestring
from cStringIO import StringIO from cStringIO import StringIO
...@@ -89,7 +89,7 @@ def save_record(parser, tag, data): ...@@ -89,7 +89,7 @@ def save_record(parser, tag, data):
file.seek(pos) file.seek(pos)
a=data[1] a=data[1]
if a.has_key('id'): oid=a['id'] if a.has_key('id'): oid=a['id']
oid=ppml.p64(string.atoi(oid)) oid=ppml.p64(int(oid))
v='' v=''
for x in data[2:]: for x in data[2:]:
v=v+x v=v+x
......
...@@ -15,7 +15,6 @@ DOM implementation in ZOPE : Read-Only methods ...@@ -15,7 +15,6 @@ DOM implementation in ZOPE : Read-Only methods
All standard Zope objects support DOM to a limited extent. All standard Zope objects support DOM to a limited extent.
""" """
import string
import Acquisition import Acquisition
...@@ -250,7 +249,7 @@ class DOMImplementation: ...@@ -250,7 +249,7 @@ class DOMImplementation:
will cause the method to return true. Return Value true if the will cause the method to return true. Return Value true if the
feature is implemented in the specified version, false otherwise. feature is implemented in the specified version, false otherwise.
""" """
feature=string.lower(feature) feature=feature.lower()
if feature == 'html': return 0 if feature == 'html': return 0
if feature == 'xml': if feature == 'xml':
if version is None: return 1 if version is None: return 1
......
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
# #
############################################################################## ##############################################################################
"""A utility module for content-type handling.""" """A utility module for content-type handling."""
__version__='$Revision: 1.16 $'[11:-2] __version__='$Revision: 1.17 $'[11:-2]
from string import split, strip, lower, find
import re, mimetypes import re, mimetypes
...@@ -21,7 +20,7 @@ find_binary=re.compile('[\0-\7]').search ...@@ -21,7 +20,7 @@ find_binary=re.compile('[\0-\7]').search
def text_type(s): def text_type(s):
# Yuk. See if we can figure out the type by content. # Yuk. See if we can figure out the type by content.
if (lower(strip(s)[:6]) == '<html>' or find(s, '</') > 0): if (s.strip().lower()[:6] == '<html>' or s.find('</') > 0):
return 'text/html' return 'text/html'
elif s.strip().startswith('<?xml'): elif s.strip().startswith('<?xml'):
...@@ -92,7 +91,7 @@ def guess_content_type(name='', body='', default=None): ...@@ -92,7 +91,7 @@ def guess_content_type(name='', body='', default=None):
else: else:
type=default or 'text/x-unknown-content-type' type=default or 'text/x-unknown-content-type'
return lower(type), enc and lower(enc) 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()
......
...@@ -97,7 +97,6 @@ __version__ = 1, 4, 0 ...@@ -97,7 +97,6 @@ __version__ = 1, 4, 0
# is sent to stdout. Or you can call main(args), passing what would # is sent to stdout. Or you can call main(args), passing what would
# have been in sys.argv[1:] had the cmd-line form been used. # have been in sys.argv[1:] had the cmd-line form been used.
import string
TRACE = 0 TRACE = 0
# define what "junk" means # define what "junk" means
...@@ -515,7 +514,7 @@ def fancy_replace(a, alo, ahi, b, blo, bhi): ...@@ -515,7 +514,7 @@ def fancy_replace(a, alo, ahi, b, blo, bhi):
btags = btags + ' ' * (la - lb) btags = btags + ' ' * (la - lb)
combined = map(lambda x,y: _combine[x+y], atags, btags) combined = map(lambda x,y: _combine[x+y], atags, btags)
print '-', aelt, '+', belt, '?', \ print '-', aelt, '+', belt, '?', \
string.rstrip(string.join(combined, '')) ''.string.join(combined).rstrip()
else: else:
# the synch pair is identical # the synch pair is identical
print ' ', aelt, print ' ', aelt,
......
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