[Checkins] SVN: zope.publisher/branches/py3-attempt2/src/zope/publisher/ More deprecation and other warnings fixed
Andrey Lebedev
cvs-admin at zope.org
Thu Feb 21 13:22:45 UTC 2013
Log message for revision 129563:
More deprecation and other warnings fixed
Changed:
U zope.publisher/branches/py3-attempt2/src/zope/publisher/http.py
U zope.publisher/branches/py3-attempt2/src/zope/publisher/httpresults.txt
U zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_http.py
-=-
Modified: zope.publisher/branches/py3-attempt2/src/zope/publisher/http.py
===================================================================
--- zope.publisher/branches/py3-attempt2/src/zope/publisher/http.py 2013-02-21 13:02:45 UTC (rev 129562)
+++ zope.publisher/branches/py3-attempt2/src/zope/publisher/http.py 2013-02-21 13:22:44 UTC (rev 129563)
@@ -33,7 +33,6 @@
from zope.publisher.interfaces.http import IResult
from zope.publisher.interfaces.logginginfo import ILoggingInfo
from zope.publisher.skinnable import setDefaultSkin
-import cgi
import logging
import tempfile
import types
@@ -48,9 +47,11 @@
import Cookie as cookies
from urllib import splitport, quote
from urlparse import urlsplit
+ from cgi import escape
else:
import http.cookies as cookies
from urllib.parse import splitport, quote, urlsplit
+ from html import escape
unicode = str
basestring = (str, bytes)
@@ -416,7 +417,7 @@
try:
c = cookies.SimpleCookie(text)
except cookies.CookieError as e:
- eventlog.warn(e)
+ eventlog.warning(e)
return result
for k,v in c.items():
@@ -873,7 +874,7 @@
self.setStatus(500, u"The engines can't take any more, Jim!")
def _html(self, title, content):
- t = cgi.escape(title)
+ t = escape(title)
return (
u"<html><head><title>%s</title></head>\n"
u"<body><h2>%s</h2>\n"
@@ -921,7 +922,7 @@
try:
c = cookies.SimpleCookie()
except cookies.CookieError as e:
- eventlog.warn(e)
+ eventlog.warning(e)
return []
for name, attrs in self._cookies.items():
name = str(name)
Modified: zope.publisher/branches/py3-attempt2/src/zope/publisher/httpresults.txt
===================================================================
--- zope.publisher/branches/py3-attempt2/src/zope/publisher/httpresults.txt 2013-02-21 13:02:45 UTC (rev 129562)
+++ zope.publisher/branches/py3-attempt2/src/zope/publisher/httpresults.txt 2013-02-21 13:22:44 UTC (rev 129563)
@@ -78,13 +78,16 @@
>>> import zope.component
>>> from zope.publisher.browser import TestRequest
>>> from zope.publisher.interfaces.http import IResult, IHTTPRequest
- >>> import cgi
+ >>> try:
+ ... from html import escape
+ ... except ImportError:
+ ... from cgi import escape
>>> @zope.interface.implementer(IResult)
... @zope.component.adapter(unicode, IHTTPRequest)
... def do_something_silly_to_unicode_results(val, request):
... request.response.setHeader('X-Silly', 'Yes')
... return (u'<html>\n<head>\n<title>raw</title>\n</head>\n<body>\n' +
- ... cgi.escape(val) + '\n</body>\n</html>')
+ ... escape(val) + '\n</body>\n</html>')
...
>>> zope.component.provideAdapter(do_something_silly_to_unicode_results)
Modified: zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_http.py
===================================================================
--- zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_http.py 2013-02-21 13:02:45 UTC (rev 129562)
+++ zope.publisher/branches/py3-attempt2/src/zope/publisher/tests/test_http.py 2013-02-21 13:22:44 UTC (rev 129563)
@@ -131,24 +131,24 @@
# definitely over that).
# HTTPInputStream understands both CONTENT_LENGTH...
- stream = HTTPInputStream(BytesIO(data), {'CONTENT_LENGTH': '100000'})
- self.assertTrue(isinstance(stream.getCacheStream(), TempFileType))
+ stream1 = HTTPInputStream(BytesIO(data), {'CONTENT_LENGTH': '100000'})
+ self.assertTrue(isinstance(stream1.getCacheStream(), TempFileType))
# ... and HTTP_CONTENT_LENGTH.
- stream = HTTPInputStream(BytesIO(data), {'HTTP_CONTENT_LENGTH':
+ stream2 = HTTPInputStream(BytesIO(data), {'HTTP_CONTENT_LENGTH':
'100000'})
- self.assertTrue(isinstance(stream.getCacheStream(), TempFileType))
+ self.assertTrue(isinstance(stream2.getCacheStream(), TempFileType))
# If CONTENT_LENGTH is absent or empty, it takes the value
# given in HTTP_CONTENT_LENGTH:
- stream = HTTPInputStream(BytesIO(data),
+ stream3 = HTTPInputStream(BytesIO(data),
{'CONTENT_LENGTH': '',
'HTTP_CONTENT_LENGTH': '100000'})
- self.assertTrue(isinstance(stream.getCacheStream(), TempFileType))
+ self.assertTrue(isinstance(stream3.getCacheStream(), TempFileType))
# In fact, HTTPInputStream can be instantiated with both an
# empty CONTENT_LENGTH and an empty HTTP_CONTENT_LENGTH:
- stream = HTTPInputStream(BytesIO(data),
+ stream4 = HTTPInputStream(BytesIO(data),
{'CONTENT_LENGTH': '',
'HTTP_CONTENT_LENGTH': ''})
More information about the checkins
mailing list