Commit d891e363 authored by Andreas Jung's avatar Andreas Jung

string module free zone

parent df576780
...@@ -16,10 +16,9 @@ ...@@ -16,10 +16,9 @@
This product provides support for external methods, which allow This product provides support for external methods, which allow
domain-specific customization of web environments. domain-specific customization of web environments.
""" """
__version__='$Revision: 1.45 $'[11:-2] __version__='$Revision: 1.46 $'[11:-2]
from Globals import Persistent, DTMLFile, MessageDialog, HTML from Globals import Persistent, DTMLFile, MessageDialog, HTML
import OFS.SimpleItem, Acquisition import OFS.SimpleItem, Acquisition
from string import split, join, find, lower
import AccessControl.Role, sys, os, stat, traceback import AccessControl.Role, sys, os, stat, traceback
from OFS.SimpleItem import pretty_tb from OFS.SimpleItem import pretty_tb
from App.Extensions import getObject, getPath, FuncCode from App.Extensions import getObject, getPath, FuncCode
......
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__rcs_id__='$Id: MIMETag.py,v 1.8 2001/11/28 15:50:59 matt Exp $' __rcs_id__='$Id: MIMETag.py,v 1.9 2002/03/11 15:54:38 andreasjung Exp $'
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
from DocumentTemplate.DT_Util import * from DocumentTemplate.DT_Util import *
from DocumentTemplate.DT_String import String from DocumentTemplate.DT_String import String
from MimeWriter import MimeWriter from MimeWriter import MimeWriter
from cStringIO import StringIO from cStringIO import StringIO
import string, mimetools import mimetools
MIMEError = "MIME Tag Error" MIMEError = "MIME Tag Error"
......
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
############################################################################## ##############################################################################
"""SMTP mail objects """SMTP mail objects
$Id: MailHost.py,v 1.69 2002/01/15 14:58:37 jens Exp $""" $Id: MailHost.py,v 1.70 2002/03/11 15:54:38 andreasjung Exp $"""
__version__ = "$Revision: 1.69 $"[11:-2] __version__ = "$Revision: 1.70 $"[11:-2]
from Globals import Persistent, DTMLFile, InitializeClass from Globals import Persistent, DTMLFile, InitializeClass
from smtplib import SMTP from smtplib import SMTP
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
from operator import truth from operator import truth
import Acquisition, sys, string, types, mimetools import Acquisition, sys, types, mimetools
import OFS.SimpleItem, re, quopri, rfc822 import OFS.SimpleItem, re, quopri, rfc822
from cStringIO import StringIO from cStringIO import StringIO
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -84,7 +84,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -84,7 +84,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
title=str(title) title=str(title)
smtp_host=str(smtp_host) smtp_host=str(smtp_host)
if type(smtp_port) is not type(1): if type(smtp_port) is not type(1):
smtp_port=string.atoi(smtp_port) smtp_port=int(smtp_port)
self.title=title self.title=title
self.smtp_host=smtp_host self.smtp_host=smtp_host
...@@ -142,7 +142,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -142,7 +142,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
if mto: if mto:
if type(mto) is type('s'): if type(mto) is type('s'):
mto=map(string.strip, string.split(mto,',')) mto=[ x.strip() for x in mto.split(',')]
headers['to'] = filter(None, mto) headers['to'] = filter(None, mto)
if mfrom: if mfrom:
headers['from'] = mfrom headers['from'] = mfrom
...@@ -169,7 +169,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager): ...@@ -169,7 +169,7 @@ class MailBase(Acquisition.Implicit, OFS.SimpleItem.Item, RoleManager):
messageText) messageText)
if mto: if mto:
if type(mto) is type('s'): if type(mto) is type('s'):
mto=map(string.strip, string.split(mto,',')) mto=[ x.strip() for x in mto.split(',')]
headers['to'] = filter(truth, mto) headers['to'] = filter(truth, mto)
if mfrom: if mfrom:
headers['from'] = mfrom headers['from'] = mfrom
...@@ -215,7 +215,7 @@ def _encode(body, encode=None): ...@@ -215,7 +215,7 @@ def _encode(body, encode=None):
if mo.getencoding() != '7bit': if mo.getencoding() != '7bit':
raise MailHostError, 'Message already encoded' raise MailHostError, 'Message already encoded'
newmfile=StringIO() newmfile=StringIO()
newmfile.write(string.joinfields(mo.headers, '')) newmfile.write(''.join(mo.headers))
newmfile.write('Content-Transfer-Encoding: %s\n' % encode) newmfile.write('Content-Transfer-Encoding: %s\n' % encode)
if not mo.has_key('Mime-Version'): if not mo.has_key('Mime-Version'):
newmfile.write('Mime-Version: 1.0\n') newmfile.write('Mime-Version: 1.0\n')
...@@ -226,7 +226,7 @@ def _encode(body, encode=None): ...@@ -226,7 +226,7 @@ def _encode(body, encode=None):
def extractheaders(message): def extractheaders(message):
# return headers of message # return headers of message
mfile=StringIO(string.strip(message)) mfile=StringIO(message.strip())
mo=rfc822.Message(mfile) mo=rfc822.Message(mfile)
hd={} hd={}
......
...@@ -10,14 +10,13 @@ ...@@ -10,14 +10,13 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__rcs_id__='$Id: SendMailTag.py,v 1.15 2002/01/15 14:58:37 jens Exp $' __rcs_id__='$Id: SendMailTag.py,v 1.16 2002/03/11 15:54:38 andreasjung Exp $'
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
from MailHost import MailBase from MailHost import MailBase
from DocumentTemplate.DT_Util import parse_params,render_blocks from DocumentTemplate.DT_Util import parse_params,render_blocks
from DocumentTemplate.DT_String import String from DocumentTemplate.DT_String import String
from socket import gethostname from socket import gethostname
import string
class SendMailTag: class SendMailTag:
'''the send mail tag, used like thus: '''the send mail tag, used like thus:
...@@ -93,7 +92,7 @@ class SendMailTag: ...@@ -93,7 +92,7 @@ class SendMailTag:
self.mailfrom=args['mailfrom'] self.mailfrom=args['mailfrom']
self.subject=None or args['subject'] self.subject=None or args['subject']
if args['port'] and type(args['port']) is type('s'): if args['port'] and type(args['port']) is type('s'):
self.port=args['port']=string.atoi(args['port']) self.port=args['port']=int(args['port'])
elif args['port']=='': elif args['port']=='':
self.port=args['port']=25 self.port=args['port']=25
else: else:
......
...@@ -14,7 +14,6 @@ import Globals, AccessControl.User ...@@ -14,7 +14,6 @@ import Globals, AccessControl.User
from Globals import Persistent from Globals import Persistent
from Acquisition import Implicit from Acquisition import Implicit
from OFS import SimpleItem from OFS import SimpleItem
from string import rfind
manage_addPrincipiaDraftForm=Globals.HTMLFile('dtml/draftAdd',globals()) manage_addPrincipiaDraftForm=Globals.HTMLFile('dtml/draftAdd',globals())
def manage_addPrincipiaDraft(self, id, baseid, PATH_INFO, REQUEST=None): def manage_addPrincipiaDraft(self, id, baseid, PATH_INFO, REQUEST=None):
...@@ -39,7 +38,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item): ...@@ -39,7 +38,7 @@ class Draft(Persistent, Implicit, SimpleItem.Item):
self.id=id self.id=id
self._refid=baseid self._refid=baseid
version=PATH_INFO version=PATH_INFO
l=rfind(version,'/') l=version.rfind(/')
if l >= 0: version=version[:l] if l >= 0: version=version[:l]
self._version="%s/%s" % (version, id) self._version="%s/%s" % (version, id)
self.users__draft__=uf=AccessControl.User.UserFolder() self.users__draft__=uf=AccessControl.User.UserFolder()
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
############################################################################## ##############################################################################
"""Version object""" """Version object"""
__version__='$Revision: 1.51 $'[11:-2] __version__='$Revision: 1.52 $'[11:-2]
import Globals, time import Globals, time
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
...@@ -20,7 +20,6 @@ from Globals import MessageDialog ...@@ -20,7 +20,6 @@ from Globals import MessageDialog
from Globals import Persistent from Globals import Persistent
from Acquisition import Implicit from Acquisition import Implicit
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from string import rfind, join
from Globals import HTML from Globals import HTML
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
from OFS.ObjectManager import BeforeDeleteException from OFS.ObjectManager import BeforeDeleteException
...@@ -186,7 +185,7 @@ class Version(Persistent,Implicit,RoleManager,Item): ...@@ -186,7 +185,7 @@ class Version(Persistent,Implicit,RoleManager,Item):
def manage_afterAdd(self, item, container): def manage_afterAdd(self, item, container):
if not self.cookie: if not self.cookie:
# Physical path # Physical path
self.cookie=join(self.getPhysicalPath(),'/') self.cookie='/'.join(self.getPhysicalPath())
def manage_beforeDelete(self, item, container): def manage_beforeDelete(self, item, container):
if self.nonempty(): if self.nonempty():
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################ ############################################################################
import re, time, string, sys import re, time, sys
import Globals import Globals
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Acquisition import Implicit, Explicit, aq_base from Acquisition import Implicit, Explicit, aq_base
...@@ -150,7 +150,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -150,7 +150,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
'Container path contains characters invalid in a Zope ' 'Container path contains characters invalid in a Zope '
'object path' 'object path'
) )
self.obpath = string.split(path, '/') self.obpath = path.split('/')
elif type(path) in (type([]), type(())): elif type(path) in (type([]), type(())):
self.obpath = list(path) # sequence self.obpath = list(path) # sequence
else: else:
...@@ -160,7 +160,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -160,7 +160,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
def getContainerPath(self): def getContainerPath(self):
""" """ """ """
if self.obpath is not None: if self.obpath is not None:
return string.join(self.obpath, '/') return '/'.join(self.obpath)
return '' # blank string represents undefined state return '' # blank string represents undefined state
def _hasSessionDataObject(self, key): def _hasSessionDataObject(self, key):
...@@ -194,7 +194,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -194,7 +194,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
# be construed as a security hole, albeit a minor one. # be construed as a security hole, albeit a minor one.
# unrestrictedTraverse is also much faster. # unrestrictedTraverse is also much faster.
if DEBUG and not hasattr(self, '_v_wrote_dc_type'): if DEBUG and not hasattr(self, '_v_wrote_dc_type'):
args = string.join(self.obpath, '/') args = '/'.join(self.obpath)
LOG('Session Tracking', BLATHER, LOG('Session Tracking', BLATHER,
'External data container at %s in use' % args) 'External data container at %s in use' % args)
self._v_wrote_dc_type = 1 self._v_wrote_dc_type = 1
...@@ -202,7 +202,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -202,7 +202,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
except: except:
raise SessionDataManagerErr, ( raise SessionDataManagerErr, (
"External session data container '%s' not found." % "External session data container '%s' not found." %
string.join(self.obpath,'/') '/'.join(self.obpath)
) )
security.declareProtected(MGMT_SCREEN_PERM, 'getRequestName') security.declareProtected(MGMT_SCREEN_PERM, 'getRequestName')
......
...@@ -19,7 +19,7 @@ from OFS.History import Historical ...@@ -19,7 +19,7 @@ from OFS.History import Historical
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from OFS.ObjectManager import ObjectManager, IFAwareObjectManager from OFS.ObjectManager import ObjectManager, IFAwareObjectManager
import string, os, sys, time import os, sys, time
from Acquisition import Implicit from Acquisition import Implicit
from Persistence import Persistent from Persistence import Persistent
......
...@@ -16,7 +16,7 @@ from Globals import HTML, DTMLFile, MessageDialog ...@@ -16,7 +16,7 @@ from Globals import HTML, DTMLFile, MessageDialog
import DateTime import DateTime
import DocumentTemplate import DocumentTemplate
import StructuredText import StructuredText
import string, re import re
pre_pat=re.compile(r'<PRE>(.+?)</PRE>', re.IGNORECASE|re.DOTALL) pre_pat=re.compile(r'<PRE>(.+?)</PRE>', re.IGNORECASE|re.DOTALL)
...@@ -45,7 +45,7 @@ class TutorialTopic(TextTopic): ...@@ -45,7 +45,7 @@ class TutorialTopic(TextTopic):
if REQUEST.has_key('tutorialExamplesURL'): if REQUEST.has_key('tutorialExamplesURL'):
url=REQUEST['tutorialExamplesURL'] url=REQUEST['tutorialExamplesURL']
base=REQUEST['BASE1'] base=REQUEST['BASE1']
if string.index(url, base) == 0: if url.index(base) == 0:
url=url[len(base):] url=url[len(base):]
try: try:
self.getPhysicalRoot().unrestrictedTraverse(url) self.getPhysicalRoot().unrestrictedTraverse(url)
...@@ -129,7 +129,7 @@ class GlossaryTopic(TutorialTopic): ...@@ -129,7 +129,7 @@ class GlossaryTopic(TutorialTopic):
""" """
Returns the URL to a API documentation for a given class. Returns the URL to a API documentation for a given class.
""" """
names=string.split(klass, '.') names=klass.split('.')
url="%s/Control_Panel/Products/%s/Help/%s.py#%s" % (REQUEST['SCRIPT_NAME'], url="%s/Control_Panel/Products/%s/Help/%s.py#%s" % (REQUEST['SCRIPT_NAME'],
names[0], names[1], names[2]) names[0], names[1], names[2])
return '<a href="%s">API Documentation</a>' % url return '<a href="%s">API Documentation</a>' % url
...@@ -207,28 +207,28 @@ def clean_pre(match): ...@@ -207,28 +207,28 @@ def clean_pre(match):
Reformat a pre tag to get rid of extra indentation Reformat a pre tag to get rid of extra indentation
and extra blank lines. and extra blank lines.
""" """
lines=string.split(match.group(1), '\n') lines=match.group(1).split('\n')
nlines=[] nlines=[]
min_indent=None min_indent=None
for line in lines: for line in lines:
indent=len(line) - len(string.lstrip(line)) indent=len(line) - len(line.lstrip())
if min_indent is None or indent < min_indent: if min_indent is None or indent < min_indent:
if string.strip(line): if line.strip():
min_indent=indent min_indent=indent
for line in lines: for line in lines:
nlines.append(line[min_indent:]) nlines.append(line[min_indent:])
while 1: while 1:
if not string.strip(nlines[0]): if not nlines[0].strip():
nlines.pop(0) nlines.pop(0)
else: else:
break break
while 1: while 1:
if not string.strip(nlines[-1]): if not nlines[-1].strip():
nlines.pop() nlines.pop()
else: else:
break break
return "<PRE>%s</PRE>" % string.join(nlines, '\n') return "<PRE>%s</PRE>" % '\n'.join(nlines)
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
import TutorialTopic import TutorialTopic
import App.Common import App.Common
import os.path import os.path
import string
import os import os
import stat import stat
from DateTime import DateTime from DateTime import DateTime
...@@ -62,14 +61,14 @@ def initialize(context): ...@@ -62,14 +61,14 @@ def initialize(context):
while 1: while 1:
line = f.readline() line = f.readline()
if (string.strip(line) and string.find(line, ' ') != 0) or line=='': if (line.strip() and line.find(' ') != 0) or line=='':
# new topic # new topic
if lines: if lines:
id = id + 1 id = id + 1
topic_id = 'topic_%02d' % id topic_id = 'topic_%02d' % id
text=string.join(lines[1:], '') text=''.join(lines[1:])
text=term_pat.sub(glossaryTerm, text) text=term_pat.sub(glossaryTerm, text)
topic=TutorialTopic.TutorialTopic(topic_id, string.strip(lines[0]), spacestrip(text)) topic=TutorialTopic.TutorialTopic(topic_id, lines[0].strip(), spacestrip(text))
context.registerHelpTopic(topic_id, topic) context.registerHelpTopic(topic_id, topic)
lines=[line] lines=[line]
else: else:
...@@ -89,12 +88,12 @@ def spacestrip(txt): ...@@ -89,12 +88,12 @@ def spacestrip(txt):
""" """
l = [] l = []
for x in string.split(txt,"\n"): for x in txt.split("\n"):
if len(x)>2 and x[:2]==' ': if len(x)>2 and x[:2]==' ':
l.append(x[2:]) l.append(x[2:])
else: l.append(x) else: l.append(x)
return string.join(l,'\n') return '\n'.join(l)
# Glossary functions # Glossary functions
......
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