[Zope-Checkins] CVS: Zope/lib/python/ZServer - WebDAVSrcHandler.py:1.8.58.1
Fred L. Drake, Jr.
fred@zope.com
Thu, 6 Mar 2003 15:11:05 -0500
Update of /cvs-repository/Zope/lib/python/ZServer
In directory cvs.zope.org:/tmp/cvs-serv9826
Modified Files:
Tag: new-install-branch
WebDAVSrcHandler.py
Log Message:
- wrap a long line
- fix docstring style
- normalize whitespace
=== Zope/lib/python/ZServer/WebDAVSrcHandler.py 1.8 => 1.8.58.1 ===
--- Zope/lib/python/ZServer/WebDAVSrcHandler.py:1.8 Wed Aug 14 17:16:50 2002
+++ Zope/lib/python/ZServer/WebDAVSrcHandler.py Thu Mar 6 15:11:03 2003
@@ -7,29 +7,29 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
+# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""HTTP handler which forces GET requests to return the document source.
+
+Works around current WebDAV clients' failure to implement the
+'source-link' feature of the specification. Uses manage_FTPget().
"""
- Special HTTP handler which forces GET requests to return the "source"
- of documents (uses 'manage_FTPget'). Works around current WebDAV
- clients' failure to implement the "source-link" feature of the spec.
-"""
+
+import os
+import posixpath
+
+from ZServer.HTTPServer import zhttp_handler
__version__ = "1.0"
-from HTTPServer import zhttp_handler
-import os
-class WebDAVSrcHandler( zhttp_handler ):
- """
- """
- def get_environment( self, request ):
- """
- Munge the request to ensure that we call manage_FTPGet.
- """
- env = zhttp_handler.get_environment( self, request )
+class WebDAVSrcHandler(zhttp_handler):
+
+ def get_environment(self, request):
+ """Munge the request to ensure that we call manage_FTPGet."""
+ env = zhttp_handler.get_environment(self, request)
# Set a flag to indicate this request came through the WebDAV source
# port server.
@@ -37,23 +37,23 @@
if env['REQUEST_METHOD'] == 'GET':
path_info = env['PATH_INFO']
- path_info = os.path.join( path_info, 'manage_FTPget' )
- path_info = os.path.normpath( path_info )
if os.sep != '/':
- path_info = path_info.replace( os.sep, '/' )
+ path_info = path_info.replace(os.sep, '/')
+ path_info = posixpath.join(path_info, 'manage_FTPget')
+ path_info = posixpath.normpath(path_info)
env['PATH_INFO'] = path_info
-
# Workaround for lousy WebDAV implementation of M$ Office 2K.
# Requests for "index_html" are *sometimes* send as "index_html."
# We check the user-agent and remove a trailing dot for PATH_INFO
# and PATH_TRANSLATED
- if env.get("HTTP_USER_AGENT","").find("Microsoft Data Access Internet Publishing Provider")>-1:
- if env["PATH_INFO"][-1]=='.':
+ if env.get("HTTP_USER_AGENT", "").find(
+ "Microsoft Data Access Internet Publishing Provider") > -1:
+ if env["PATH_INFO"][-1] == '.':
env["PATH_INFO"] = env["PATH_INFO"][:-1]
- if env["PATH_TRANSLATED"][-1]=='.':
+ if env["PATH_TRANSLATED"][-1] == '.':
env["PATH_TRANSLATED"] = env["PATH_TRANSLATED"][:-1]
return env