[wwwsearch-commits] r17752 - wwwsearch/ClientForm/trunk
jjlee at codespeak.net
jjlee at codespeak.net
Thu Sep 22 00:43:38 CEST 2005
Author: jjlee
Date: Thu Sep 22 00:43:37 2005
New Revision: 17752
Modified:
wwwsearch/ClientForm/trunk/ClientForm.py
Log:
Get rid of choose_boundary wrapper function
Modified: wwwsearch/ClientForm/trunk/ClientForm.py
==============================================================================
--- wwwsearch/ClientForm/trunk/ClientForm.py (original)
+++ wwwsearch/ClientForm/trunk/ClientForm.py Thu Sep 22 00:43:37 2005
@@ -27,8 +27,6 @@
# XXXX
# _find_control &c. and ambiguous control labels
# SelectControl and labels -- backwards compat., multiple labels
-# choose_boundary .-replacement: merge with cut-n-pasted code from
-# mimetools!
# XXX
# Add some more functional tests
@@ -208,11 +206,11 @@
else: return True
-# XXX don't really want to drag this along (MimeWriter, _choose_boundary)
+# XXX don't really want to drag this along (MimeWriter, choose_boundary)
# --------------------------------------------------------------------
# grabbed from Python standard library mimetools module and tweaked to
-# avoid socket.gaierror
+# avoid socket.gaierror and to avoid dots ('.') in MIME boundaries
try:
import thread
_thread = thread; del thread
@@ -233,7 +231,7 @@
_prefix = None
-def _choose_boundary():
+def choose_boundary():
"""Return a string usable as a multipart boundary.
The string chosen is unique within a single program run, and
@@ -267,17 +265,12 @@
pid = repr(os.getpid())
except AttributeError:
pid = '1'
- _prefix = hostid + '.' + uid + '.' + pid
- return "%s.%.3f.%d" % (_prefix, time.time(), _get_next_counter())
+ _prefix = hostid + uid + pid
+ return "%s%d%d" % (_prefix, int(time.time()*100), _get_next_counter())
# end of code from mimetools module
# --------------------------------------------------------------------
-def choose_boundary():
- b = _choose_boundary()
- b = string.replace(b, ".", "")
- return b
-
# This cut-n-pasted MimeWriter from standard library is here so can add
# to HTTP headers rather than message body when appropriate. It also uses
# \r\n in place of \n. This is nasty.
More information about the wwwsearch-commits
mailing list