Commit f2be2bb6 authored by Andreas Jung's avatar Andreas Jung

string module free zone

parent 36babae5
...@@ -7,7 +7,6 @@ from Globals import DTMLFile, MessageDialog, Persistent ...@@ -7,7 +7,6 @@ from Globals import DTMLFile, MessageDialog, Persistent
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Acquisition import Implicit, ImplicitAcquisitionWrapper from Acquisition import Implicit, ImplicitAcquisitionWrapper
from ExtensionClass import Base from ExtensionClass import Base
from string import split, strip
from ZPublisher import BeforeTraverse from ZPublisher import BeforeTraverse
import os import os
...@@ -81,9 +80,9 @@ class SiteRoot(Traverser, Implicit): ...@@ -81,9 +80,9 @@ class SiteRoot(Traverser, Implicit):
def __init__(self, title, base, path): def __init__(self, title, base, path):
'''Title''' '''Title'''
self.title = strip(title) self.title = title.strip()
self.base = base = strip(base) self.base = base = base.strip()
self.path = path = strip(path) self.path = path = path.strip()
if base: self.SiteRootBASE = base if base: self.SiteRootBASE = base
else: else:
try: del self.SiteRootBASE try: del self.SiteRootBASE
......
...@@ -6,7 +6,6 @@ Defines the VirtualHostMonster class ...@@ -6,7 +6,6 @@ Defines the VirtualHostMonster class
from Globals import DTMLFile, MessageDialog, Persistent from Globals import DTMLFile, MessageDialog, Persistent
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Acquisition import Implicit, aq_inner, aq_parent from Acquisition import Implicit, aq_inner, aq_parent
from string import split, strip, join, find, lower, replace
from ZPublisher import BeforeTraverse from ZPublisher import BeforeTraverse
import os import os
...@@ -34,22 +33,22 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -34,22 +33,22 @@ class VirtualHostMonster(Persistent, Item, Implicit):
def set_map(self, map_text, RESPONSE=None): def set_map(self, map_text, RESPONSE=None):
"Set domain to path mappings." "Set domain to path mappings."
lines = split(map_text, '\n') lines = map_text.split('\n')
self.fixed_map = fixed_map = {} self.fixed_map = fixed_map = {}
self.sub_map = sub_map = {} self.sub_map = sub_map = {}
new_lines = [] new_lines = []
for line in lines: for line in lines:
line = strip(split(line, '#!')[0]) line = line.split('#!')[0].strip()
if not line: if not line:
continue continue
try: try:
# Drop the protocol, if any # Drop the protocol, if any
line = split(line, '://')[-1] line = line.split('://')[-1]
try: try:
host, path = map(strip, split(line, '/', 1)) host, path = [x.strip() for x in line.split('/', 1)]
except: except:
raise 'LineError', 'Needs a slash between host and path' raise 'LineError', 'Needs a slash between host and path'
pp = filter(None, split(path, '/')) pp = filter(None, path.split( '/'))
if pp: if pp:
obpath = pp[:] obpath = pp[:]
if obpath[0] == 'VirtualHostBase': if obpath[0] == 'VirtualHostBase':
...@@ -71,7 +70,7 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -71,7 +70,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
pp.append('/') pp.append('/')
pp.reverse() pp.reverse()
try: try:
int(replace(host,'.','')) int(host.replace('.',''))
raise 'LineError', 'IP addresses are not mappable' raise 'LineError', 'IP addresses are not mappable'
except ValueError: except ValueError:
pass pass
...@@ -80,7 +79,7 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -80,7 +79,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
host = host[2:] host = host[2:]
else: else:
host_map = fixed_map host_map = fixed_map
hostname, port = (split(host, ':', 1) + [None])[:2] hostname, port = (host.split( ':', 1) + [None])[:2]
if not host_map.has_key(hostname): if not host_map.has_key(hostname):
host_map[hostname] = {} host_map[hostname] = {}
host_map[hostname][port] = pp host_map[hostname][port] = pp
...@@ -130,7 +129,7 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -130,7 +129,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
protocol = stack.pop() protocol = stack.pop()
host = stack.pop() host = stack.pop()
if ':' in host: if ':' in host:
host, port = split(host, ':') host, port = host.split(':')
request.setServerURL(protocol, host, port) request.setServerURL(protocol, host, port)
else: else:
request.setServerURL(protocol, host) request.setServerURL(protocol, host)
...@@ -148,9 +147,9 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -148,9 +147,9 @@ class VirtualHostMonster(Persistent, Item, Implicit):
if vh >= 0: if vh >= 0:
for jj in range(vh, ii): for jj in range(vh, ii):
pp.insert(1, stack[jj][4:]) pp.insert(1, stack[jj][4:])
stack[vh:ii + 1] = [join(pp, '/'), self.id] stack[vh:ii + 1] = ['/'.join(pp), self.id]
elif ii > 0 and stack[ii - 1][:1] == '/': elif ii > 0 and stack[ii - 1][:1] == '/':
pp = split(stack[ii - 1], '/') pp = stack[ii - 1].split('/')
stack[ii] = self.id stack[ii] = self.id
else: else:
stack[ii] = self.id stack[ii] = self.id
...@@ -169,8 +168,8 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -169,8 +168,8 @@ class VirtualHostMonster(Persistent, Item, Implicit):
vh_used = 1 # Only retry once. vh_used = 1 # Only retry once.
# Try to apply the host map if one exists, and if no # Try to apply the host map if one exists, and if no
# VirtualHost directives were found. # VirtualHost directives were found.
host = lower(split(request['SERVER_URL'], '://')[1]) host = request['SERVER_URL'].split('://')[1].lower()
hostname, port = (split(host, ':', 1) + [None])[:2] hostname, port = (host.split( ':', 1) + [None])[:2]
ports = self.fixed_map.get(hostname, 0) ports = self.fixed_map.get(hostname, 0)
if not ports and self.sub_map: if not ports and self.sub_map:
get = self.sub_map.get get = self.sub_map.get
...@@ -180,7 +179,7 @@ class VirtualHostMonster(Persistent, Item, Implicit): ...@@ -180,7 +179,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):
break break
if '.' not in hostname: if '.' not in hostname:
return return
hostname = split(hostname, '.', 1)[1] hostname = hostname.split('.', 1)[1]
if ports: if ports:
pp = ports.get(port, 0) pp = ports.get(port, 0)
if pp == 0 and port is not None: if pp == 0 and port is not None:
......
...@@ -12,13 +12,12 @@ ...@@ -12,13 +12,12 @@
############################################################################## ##############################################################################
"""Mounted database support """Mounted database support
$Id: TemporaryFolder.py,v 1.4 2001/11/28 15:51:08 matt Exp $""" $Id: TemporaryFolder.py,v 1.5 2002/03/11 16:09:19 andreasjung Exp $"""
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
import Globals import Globals
from Globals import HTMLFile from Globals import HTMLFile
from ZODB.Mount import MountPoint from ZODB.Mount import MountPoint
import string
import OFS import OFS
import os, os.path import os, os.path
......
...@@ -16,7 +16,6 @@ import Acquisition ...@@ -16,7 +16,6 @@ import Acquisition
import ExtensionClass import ExtensionClass
from Products.PluginIndexes.TextIndex.Lexicon import Lexicon from Products.PluginIndexes.TextIndex.Lexicon import Lexicon
from MultiMapping import MultiMapping from MultiMapping import MultiMapping
from string import lower
import Record import Record
from Missing import MV from Missing import MV
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
...@@ -593,7 +592,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -593,7 +592,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
so=kw['sort_order'] so=kw['sort_order']
else: so=None else: so=None
if (type(so) is type('') and if (type(so) is type('') and
lower(so) in ('reverse', 'descending')): so.lower() in ('reverse', 'descending')):
r.reverse() r.reverse()
r=map(lambda i: i[1], r) r=map(lambda i: i[1], r)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
backward-compatibility. All new code should use CatalogPathAwareness. backward-compatibility. All new code should use CatalogPathAwareness.
""" """
import urllib, string import urllib
from Globals import DTMLFile from Globals import DTMLFile
class CatalogAware: class CatalogAware:
...@@ -74,7 +74,7 @@ class CatalogAware: ...@@ -74,7 +74,7 @@ class CatalogAware:
for user, roles in self.get_local_roles(): for user, roles in self.get_local_roles():
if 'Owner' in roles: if 'Owner' in roles:
users.append(user) users.append(user)
return string.join(users, ', ') return ', '.join(users)
def onDeleteObject(self): def onDeleteObject(self):
"""Object delete handler. I think this is obsoleted by """Object delete handler. I think this is obsoleted by
...@@ -92,7 +92,7 @@ class CatalogAware: ...@@ -92,7 +92,7 @@ class CatalogAware:
script_name=self.REQUEST['SCRIPT_NAME'] script_name=self.REQUEST['SCRIPT_NAME']
__traceback_info__=(`uri`, `script_name`) __traceback_info__=(`uri`, `script_name`)
if script_name: if script_name:
uri=filter(None, string.split(uri, script_name))[0] uri=filter(None, uri.split(script_name))[0]
if not uri: if not uri:
uri = '/' uri = '/'
if uri[0] != '/': if uri[0] != '/':
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""ZCatalog Findable class""" """ZCatalog Findable class"""
import urllib, string import urllib
from Globals import DTMLFile from Globals import DTMLFile
from Acquisition import aq_base from Acquisition import aq_base
...@@ -71,7 +71,7 @@ class CatalogAware: ...@@ -71,7 +71,7 @@ class CatalogAware:
for user, roles in self.get_local_roles(): for user, roles in self.get_local_roles():
if 'Owner' in roles: if 'Owner' in roles:
users.append(user) users.append(user)
return string.join(users, ', ') return ', '.join(users, ', ')
def onDeleteObject(self): def onDeleteObject(self):
"""Object delete handler. I think this is obsoleted by """Object delete handler. I think this is obsoleted by
...@@ -80,7 +80,7 @@ class CatalogAware: ...@@ -80,7 +80,7 @@ class CatalogAware:
def getPath(self): def getPath(self):
"""Return the physical path for an object.""" """Return the physical path for an object."""
return string.join(self.getPhysicalPath(), '/') return '/'.join(self.getPhysicalPath())
def summary(self, num=200): def summary(self, num=200):
"""Return a summary of the text content of the object.""" """Return a summary of the text content of the object."""
......
...@@ -32,7 +32,7 @@ from ZCatalogIndexes import ZCatalogIndexes ...@@ -32,7 +32,7 @@ from ZCatalogIndexes import ZCatalogIndexes
from Products.PluginIndexes.common.PluggableIndex import PluggableIndexInterface from Products.PluginIndexes.common.PluggableIndex import PluggableIndexInterface
from Products.PluginIndexes.TextIndex.Vocabulary import Vocabulary from Products.PluginIndexes.TextIndex.Vocabulary import Vocabulary
from Products.PluginIndexes.TextIndex import Splitter from Products.PluginIndexes.TextIndex import Splitter
import string, urllib, os, sys, time, types import urllib, os, sys, time, types
...@@ -211,7 +211,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -211,7 +211,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def manage_edit(self, RESPONSE, URL1, threshold=1000, REQUEST=None): def manage_edit(self, RESPONSE, URL1, threshold=1000, REQUEST=None):
""" edit the catalog """ """ edit the catalog """
if type(threshold) is not type(1): if type(threshold) is not type(1):
threshold=string.atoi(threshold) threshold=int(threshold)
self.threshold = threshold self.threshold = threshold
RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Catalog%20Changed') RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Catalog%20Changed')
...@@ -312,7 +312,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -312,7 +312,7 @@ class ZCatalog(Folder, Persistent, Implicit):
words = 0 words = 0
obj = REQUEST.PARENTS[1] obj = REQUEST.PARENTS[1]
path = string.join(obj.getPhysicalPath(), '/') path = '/'.join(obj.getPhysicalPath())
results = self.ZopeFindAndApply(obj, results = self.ZopeFindAndApply(obj,
......
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