Author: chrisz
Date: Thu Apr 12 14:39:36 2007
New Revision: 6459
Modified:
Webware/trunk/KidKit/Examples/KidExamplePage.py
Webware/trunk/PSP/Examples/PSPExamplePage.py
Webware/trunk/WebKit/Adapters/CGIPlus/CgiPlusMakeAppWorkDir.py
Webware/trunk/WebKit/Admin/PlugIns.py
Webware/trunk/WebKit/Application.py
Webware/trunk/WebKit/Examples/ExamplePage.py
Webware/trunk/WebKit/Examples/Welcome.py
Webware/trunk/WebKit/HTTPExceptions.py
Webware/trunk/WebKit/HTTPRequest.py
Webware/trunk/WebKit/HTTPServer.py
Webware/trunk/WebKit/SidebarPage.py
Webware/trunk/WebKit/Testing/DebugPage.py
Webware/trunk/WebKit/Testing/IncludeURLTest.py
Webware/trunk/WebKit/Testing/Main.py
Webware/trunk/WebKit/Testing/TestIMS.py
Webware/trunk/WebKit/ThreadedAppServer.py
Webware/trunk/WebKit/URLParser.py
Webware/trunk/WebUtils/Funcs.py
Webware/trunk/bin/MakeAppWorkDir.py
Log:
So far, servletPath and adapterName were both equivalent to SCRIPT_NAME. Both did not reflect webserver URL rewriting. Therefore wrong URLs were constructed in several places if URL rewriting was used.
This behavior was changed consequently: servletPath does now reflect rewriting, while adapterName does not. They are still the same when no URL rewriting is used. URLs should always be constructed using the servletPath, while the adapterName can be usually ignored.
Modified: Webware/trunk/KidKit/Examples/KidExamplePage.py
==============================================================================
--- Webware/trunk/KidKit/Examples/KidExamplePage.py (original)
+++ Webware/trunk/KidKit/Examples/KidExamplePage.py Thu Apr 12 14:39:36 2007
@@ -38,4 +38,4 @@
filename = 'Documentation/WebKit.html'
if os.path.exists(filename):
self.menuItem('Local WebKit docs',
- self.request().adapterName() + '/' + filename)
+ self.request().servletPath() + '/' + filename)
Modified: Webware/trunk/PSP/Examples/PSPExamplePage.py
==============================================================================
--- Webware/trunk/PSP/Examples/PSPExamplePage.py (original)
+++ Webware/trunk/PSP/Examples/PSPExamplePage.py Thu Apr 12 14:39:36 2007
@@ -29,4 +29,4 @@
if self.application().hasContext('Documentation'):
filename = 'Documentation/WebKit.html'
if os.path.exists(filename):
- self.menuItem('Local WebKit docs', self.request().adapterName() + '/' + filename)
+ self.menuItem('Local WebKit docs', self.request().servletPath() + '/' + filename)
Modified: Webware/trunk/WebKit/Adapters/CGIPlus/CgiPlusMakeAppWorkDir.py
==============================================================================
--- Webware/trunk/WebKit/Adapters/CGIPlus/CgiPlusMakeAppWorkDir.py (original)
+++ Webware/trunk/WebKit/Adapters/CGIPlus/CgiPlusMakeAppWorkDir.py Thu Apr 12 14:39:36 2007
@@ -354,15 +354,15 @@
which you can get to from here:</p>
<ul>
''')
- adapterName = self.request().adapterName()
+ servletPath = self.request().servletPath()
contextName = self.request().contextName()
ctxs = self.application().contexts().keys()
ctxs.sort()
for ctx in ctxs:
- if ctx in ('default', contextName) or ctx.find('/') >= 0:
+ if ctx in ('default', contextName) or '/' in ctx:
continue
self.writeln('<li><a href="%s/%s/">%s</a></li>'
- % (adapterName, ctx, ctx))
+ % (servletPath, ctx, ctx))
self.writeln('</ul>')
"""
Modified: Webware/trunk/WebKit/Admin/PlugIns.py
==============================================================================
--- Webware/trunk/WebKit/Admin/PlugIns.py (original)
+++ Webware/trunk/WebKit/Admin/PlugIns.py Thu Apr 12 14:39:36 2007
@@ -13,7 +13,7 @@
if plugIns:
wr('<h4 style="text-align:center">'
'The following Plug-ins were found:</h4>')
- adapter = self.request().adapterName()
+ path = self.request().servletPath()
wr('<table cellspacing="2" cellpadding="2" align="center"'
' style="margin-left:auto;margin-right:auto">')
wr('<tr style="background-color:#555;color:white">'
@@ -24,7 +24,7 @@
name, dir, ver = plugIn.name(), plugIn.directory(), \
plugIn.properties()['versionString']
wr('<tr style="background-color:#EEE;text-align:left">'
- '<td><a href="%(adapter)s/%(name)s/Docs/index.html">'
+ '<td><a href="%(path)s/%(name)s/Docs/index.html">'
'%(name)s</a></td>'
'<td style="text-align:center">%(ver)s</td>'
'<td>%(dir)s</td></tr>' % locals())
Modified: Webware/trunk/WebKit/Application.py
==============================================================================
--- Webware/trunk/WebKit/Application.py (original)
+++ Webware/trunk/WebKit/Application.py Thu Apr 12 14:39:36 2007
@@ -449,11 +449,11 @@
def sessionCookiePath(self, trans):
"""Get the cookie path for this transaction.
- The adapter name is used for security reasons, see:
+ The servlet path is used for security reasons, see:
http://www.net-security.org/dl/articles/cookie_path.pdf
"""
- return trans.request().adapterName() + '/'
+ return trans.request().servletPath() + '/'
## Misc Access ##
@@ -951,7 +951,7 @@
"""
newSid = trans.session().identifier()
request = trans.request()
- url = '%s/%s=%s%s%s%s' % (request.adapterName(),
+ url = '%s/%s=%s%s%s%s' % (request.servletPath(),
self.sessionName(trans), newSid,
request.pathInfo(), request.extraURLPath() or '',
request.queryString() and '?' + request.queryString() or '')
@@ -970,7 +970,7 @@
"""
request = trans.request()
- url = '%s%s%s%s' % (request.adapterName(),
+ url = '%s%s%s%s' % (request.servletPath(),
request.pathInfo(), request.extraURLPath() or '',
request.queryString() and '?' + request.queryString() or '')
if self.setting('Debug')['Sessions']:
Modified: Webware/trunk/WebKit/Examples/ExamplePage.py
==============================================================================
--- Webware/trunk/WebKit/Examples/ExamplePage.py (original)
+++ Webware/trunk/WebKit/Examples/ExamplePage.py Thu Apr 12 14:39:36 2007
@@ -68,11 +68,11 @@
self.writeWebKitSidebarSections()
def writeExamplesMenu(self):
- adapterName = self.request().adapterName()
+ servletPath = self.request().servletPath()
self.menuHeading('Examples')
# WebKit
- self.menuItem('WebKit', '%s/Examples/' % adapterName)
+ self.menuItem('WebKit', '%s/Examples/' % servletPath)
if self.request().contextName()=='Examples':
self.writeExamplePagesItems()
@@ -80,7 +80,7 @@
for plugIn in self.application().server().plugIns():
if plugIn.hasExamplePages():
title = plugIn.name()
- link = '%s/%s/' % (adapterName, plugIn.examplePagesContext())
+ link = '%s/%s/' % (servletPath, plugIn.examplePagesContext())
self.menuItem(title, link)
if plugIn.name()==self.request().contextName()[:-8]:
self.writeExamplePagesItems()
@@ -100,7 +100,7 @@
filename = 'Documentation/WebKit.html'
if os.path.exists(filename):
self.menuItem('Local WebKit docs',
- self.request().adapterName() + '/' + filename)
+ self.request().servletPath() + '/' + filename)
def title(self):
return self.request().contextName()
Modified: Webware/trunk/WebKit/Examples/Welcome.py
==============================================================================
--- Webware/trunk/WebKit/Examples/Welcome.py (original)
+++ Webware/trunk/WebKit/Examples/Welcome.py Thu Apr 12 14:39:36 2007
@@ -6,7 +6,7 @@
def writeContent(self):
wr = self.writeln
wr('<h2>Welcome to WebKit %s!</h2>' % self.application().webKitVersionString())
- adapter = self.request().adapterName()
+ path = self.request().servletPath()
wr('''\
<p> Along the side of this page you will see various links that will take you to:</p>
<ul>
@@ -17,13 +17,13 @@
usually given a descriptive name.</li>
<li>External sites, such as the Webware home page.</li>
</ul>
- <p>The <a href="%(adapter)s/Admin/">Admin</a> context is particularly interesting because
+ <p>The <a href="%(path)s/Admin/">Admin</a> context is particularly interesting because
it takes you to the administrative pages for the WebKit application server where
you can review logs, configuration, plug-ins, etc.</p>
- <p>The <a href="%(adapter)s/Docs/">Docs</a> contexts allow you to browse
- the documentation of <a href="%(adapter)s/WebKit/Docs/">WebKit</a>
- and <a href="%(adapter)s/Docs/ComponentIndex.html">all other components</a>
- of <a href="%(adapter)s/Docs/">Webware for Python</a>.</p>''' % locals())
+ <p>The <a href="%(path)s/Docs/">Docs</a> contexts allow you to browse
+ the documentation of <a href="%(path)s/WebKit/Docs/">WebKit</a>
+ and <a href="%(path)s/Docs/ComponentIndex.html">all other components</a>
+ of <a href="%(path)s/Docs/">Webware for Python</a>.</p>''' % locals())
from os.path import join
wr('<p>The location of the documentation on the server:</p>')
wr('<ul>')
Modified: Webware/trunk/WebKit/HTTPExceptions.py
==============================================================================
--- Webware/trunk/WebKit/HTTPExceptions.py (original)
+++ Webware/trunk/WebKit/HTTPExceptions.py Thu Apr 12 14:39:36 2007
@@ -153,7 +153,7 @@
def location(self):
"""The location that we will be redirecting to."""
if self._webkitLocation:
- location = self._transaction.request()._adapterName
+ location = self._transaction.request().servletPath()
if not self._webkitLocation.startswith('/'):
location += '/'
location += self._webkitLocation
Modified: Webware/trunk/WebKit/HTTPRequest.py
==============================================================================
--- Webware/trunk/WebKit/HTTPRequest.py (original)
+++ Webware/trunk/WebKit/HTTPRequest.py Thu Apr 12 14:39:36 2007
@@ -2,7 +2,6 @@
from types import ListType
from Common import *
-from WebUtils.Funcs import requestURI
from WebUtils import FieldStorage
from WebKit.Cookie import CookieEngine
Cookie = CookieEngine.SimpleCookie
@@ -14,15 +13,7 @@
class HTTPRequest(Request):
- """A type of Message for HTTP requests.
-
- FUTURE
- * How about some documentation?
- * The "Information" section is a bit screwed up.
- Because the WebKit server adapter is a CGI script,
- these values are oriented towards that rather than the servlet.
-
- """
+ """A type of Message for HTTP requests."""
## Initialization ##
@@ -58,32 +49,50 @@
self._fields = cgi.FieldStorage(keep_blank_values=True)
self._cookies = Cookie()
+ env = self._environ
+
# Debugging
if debug:
f = open('env.text', 'a')
save = sys.stdout
sys.stdout = f
print '>> env for request:'
- keys = self._environ.keys()
+ keys = env.keys()
keys.sort()
for key in keys:
- print '%s: %s' % (repr(key), repr(self._environ[key]))
+ print '%s: %s' % (repr(key), repr(env[key]))
print
sys.stdout = save
f.close()
- # Fix up environ if it doesn't look right.
-
- # Fix #1: No PATH_INFO
- # This can happen when there is no extra path info past the adapter.
- # e.g., http://localhost/WebKit.cgi
- if not self._environ.has_key('PATH_INFO'):
- self._environ['PATH_INFO'] = ''
- # Fix #2: No REQUEST_URI
- # REQUEST_URI isn't actually part of the CGI standard and some
- # web servers like IIS don't set it (as of 8/22/2000).
- if not self._environ.has_key('REQUEST_URI'):
- self._environ['REQUEST_URI'] = requestURI(self._environ)
+ # Get adapter, servlet path and query string
+ self._servletPath = env.get('SCRIPT_NAME', '')
+ self._pathInfo = env.get('PATH_INFO', '')
+ self._queryString = env.get('QUERY_STRING', '')
+ if env.has_key('REQUEST_URI'):
+ self._uri = env['REQUEST_URI']
+ # correct servletPath if there was a redirection
+ if not self._uri.startswith(self._servletPath + '/'):
+ i = self._uri.find(self._pathInfo)
+ if i >= 0:
+ self._servletPath = self._uri[:i]
+ else:
+ # REQUEST_URI isn't actually part of the CGI standard and some
+ # web servers like IIS don't set it (as of 8/22/2000).
+ if env.has_key('SCRIPT_URL'):
+ self._uri = self._environ['SCRIPT_URL']
+ # correct servletPath if there was a redirection
+ if not self._uri.startswith(self._servletPath + '/'):
+ i = self._uri.find(self._pathInfo)
+ if i >= 0:
+ self._servletPath = self._uri[:i]
+ else:
+ self._uri = self._servletPath + self._pathInfo
+ if self._queryString:
+ self._uri += '?' + self._queryString
+ self._absolutepath = env.has_key('WK_ABSOLUTE') # set by adapter
+ if self._absolutepath:
+ self._fsPath = self.fsPath()
# We use the cgi module to get the fields,
# but then change them into an ordinary dictionary of values:
@@ -124,10 +133,6 @@
self._serverRootPath = self._extraURLPath = ''
self._sessionExpired = False
- self._absolutepath = self._environ.has_key('WK_ABSOLUTE') # set by the adapter
- if self._absolutepath:
- self._fsPath = self.fsPath()
- self._adapterName = self.servletPath()
self._pathInfo = self.pathInfo()
if debug:
@@ -315,8 +320,10 @@
if self._absolutepath:
self._fsPath = path
else:
- self._pathInfo = self._environ['PATH_INFO'] = path
- self._environ['REQUEST_URI'] = self._adapterName + path
+ self._pathInfo = path
+ self._uri = self._servletPath + path
+ if self._queryString:
+ self._uri += '?' + self._queryString
def serverSidePath(self, path=None):
"""Return the absolute server-side path of the request.
@@ -375,6 +382,7 @@
return p
def uriWebKitRoot(self):
+ """Return relative URL path of the WebKit root location."""
if not self._serverRootPath:
self._serverRootPath = ''
loc = self.urlPath()
@@ -388,7 +396,7 @@
def fsPath(self):
"""The filesystem path of the request according to the webserver."""
- fspath = self.servletFilePath()
+ fspath = self.adapterFileName()
if not fspath:
fspath = self.servletPath()
docroot = self._environ['DOCUMENT_ROOT']
@@ -398,21 +406,21 @@
def serverURL(self):
"""Return the full internet path to this request.
- This is the URL that was actually received by the
- webserver before any rewriting took place.
+ This is the URL that was actually received by the webserver
+ before any rewriting took place.
The path is returned without any extra path info or query strings,
i.e. http://www.my.own.host.com:8080/WebKit/TestPage.py
"""
- url = self._environ.get('SCRIPT_URI', None)
- if not url:
+ if self._environ.has_key('SCRIPT_URI'):
+ return self._environ['SCRIPT_URI']
+ else:
scheme = 'http'
if self._environ.get('HTTPS', '').lower() == 'on':
scheme += 's'
host = self._environ['HTTP_HOST'] # includes port
- url = scheme + '://' + host + self.serverPath()
- return url
+ return scheme + '://' + host + self.serverPath()
def serverURLDir(self):
"""Return the directory of the URL in full internet form.
@@ -428,16 +436,16 @@
def serverPath(self):
"""Return the webserver URL path of this request.
- This is the URL that was actually received by the
- webserver before any rewriting took place.
+ This is the URL that was actually received by the webserver
+ before any rewriting took place.
Same as serverURL, but without scheme and host.
"""
- url = self._environ.get('SCRIPT_URL', None)
- if not url:
- url = self._adapterName + self._pathInfo
- return url
+ if self._environ.has_key('SCRIPT_URL'):
+ return self._environ['SCRIPT_URL']
+ else:
+ return self._servletPath + self._pathInfo
def serverPathDir(self):
"""Return the directory of the webserver URL path.
@@ -528,12 +536,20 @@
def adapterName(self):
"""Return the name of the adapter as it appears in the URL.
- Example: '/WebKit.cgi'
- This is useful in special cases when you are constructing URLs.
- See Testing/Main.py for an example use.
+ Example: '/WK' or '/WebKit.cgi'
+ Does not reflect redirection by the webserver.
+ Equivalent to the CGI variable SCRIPT_NAME.
+
+ """
+ return self._environ.get('SCRIPT_NAME', '')
+
+ def adapterFileName(self):
+ """Return the filesystem path of the adapter.
+
+ Equivalent to the CGI variable SCRIPT_FILENAME.
"""
- return self._adapterName
+ return self._environ.get('SCRIPT_FILENAME', '')
def rawRequest(self):
"""Return the raw request used to initialize this request object."""
@@ -545,8 +561,7 @@
def push(self, servlet, url=None):
"""Push servlet and URL path on a stack, setting a new URL."""
- urlPath, uri = self.urlPath(), self.uri()
- self._stack.append((servlet, urlPath, uri, self._contextName,
+ self._stack.append((servlet, self.urlPath(), self._contextName,
self._serverSidePath, self._serverSideContextPath,
self._serverRootPath, self._extraURLPath))
if url is not None:
@@ -555,11 +570,11 @@
def pop(self):
"""Pop URL path and servlet from the stack, returning the servlet."""
if self._stack:
- (servlet, urlPath, uri, self._contextName,
+ (servlet, url, self._contextName,
self._serverSidePath, self._serverSideContextPath,
self._serverRootPath, self._extraURLPath) = self._stack.pop()
- if urlPath is not None:
- self.setURLPath(urlPath)
+ if url is not None:
+ self.setURLPath(url)
return servlet
def servlet(self):
@@ -653,15 +668,17 @@
## Information ##
- # @@ 2000-05-10: See FUTURE section of class doc string
-
def servletPath(self):
- """Return the URI of the script, sans host."""
- return self._environ.get('SCRIPT_NAME', '')
+ """Return the base URL for the servlets, sans host.
- def servletFilePath(self):
- """Return the filesystem path of the script."""
- return self._environ.get('SCRIPT_FILENAME', '')
+ This is useful in cases when you are constructing URLs.
+ See Testing/Main.py for an example use.
+
+ Roughly equivalent to the CGI variable SCRIPT_NAME,
+ but reflects redirection by the webserver.
+
+ """
+ return self._servletPath
def contextPath(self):
"""Return the portion of the URI that is the context of the request."""
@@ -671,16 +688,16 @@
"""Return any extra path information as sent by the client.
This is anything after the servlet name but before the query string.
- Equivalent to CGI variable PATH_INFO.
+ Equivalent to the CGI variable PATH_INFO.
"""
- return self._environ.get('PATH_INFO', '')
+ return self._pathInfo
def pathTranslated(self):
"""Return extra path information translated as file system path.
This is the same as pathInfo() but translated to the file system.
- Equivalent to CGI variable PATH_TRANSLATED.
+ Equivalent to the CGI variable PATH_TRANSLATED.
"""
return self._environ.get('PATH_TRANSLATED', '')
@@ -688,19 +705,20 @@
def queryString(self):
"""Return the query string portion of the URL for this request.
- Taken from the CGI variable QUERY_STRING.
+ Equivalent to the CGI variable QUERY_STRING.
"""
- return self._environ.get('QUERY_STRING', '')
+ return self._queryString
def uri(self):
"""Return the URI for this request (everything after the host name).
- Taken from the CGI variable REQUEST_URI. If not available,
- constructed from SCRIPT_NAME, PATH_INFO and QUERY_STRING.
+ This is the URL that was actually received by the webserver
+ before any rewriting took place, including the query string.
+ Equivalent to the CGI variable REQUEST_URI.
"""
- return requestURI(self._environ)
+ return self._uri
def method(self):
"""Return the HTTP request method (in all uppercase).
@@ -804,8 +822,9 @@
return ''.join(res)
exceptionReportAttrNames = Request.exceptionReportAttrNames + (
- 'uri servletPath serverSidePath pathInfo pathTranslated queryString'
- ' method sessionId previousURLPaths fields cookies environ'.split())
+ 'uri adapterName servletPath serverSidePath'
+ ' pathInfo pathTranslated queryString method'
+ ' sessionId previousURLPaths fields cookies environ'.split())
## Deprecated ##
@@ -835,10 +854,22 @@
self.deprecated(self.relativePath)
return os.path.join(self.serverSideDir(), joinPath)
+ def servletFilePath(self):
+ """deprecated: HTTPRequest.servletFilePath() on 04/12/07 in 0.9.3.
+
+ Use adapterFileName() instead.@
+
+ Equivalent to the CGI variable SCRIPT_FILENAME.
+
+ """
+ self.deprecated(self.servletFilePath)
+ return self.adapterFileName(file)
+
## Info Structure ##
_infoMethods = (
+ HTTPRequest.adapterName,
HTTPRequest.servletPath,
HTTPRequest.contextPath,
HTTPRequest.pathInfo,
Modified: Webware/trunk/WebKit/HTTPServer.py
==============================================================================
--- Webware/trunk/WebKit/HTTPServer.py (original)
+++ Webware/trunk/WebKit/HTTPServer.py Thu Apr 12 14:39:36 2007
@@ -3,8 +3,8 @@
from ThreadedAppServer import Handler
from ASStreamOut import ASStreamOut
-from WebUtils import Funcs
from MiscUtils.Funcs import timestamp
+from WebUtils.Funcs import requestURI
class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
@@ -55,17 +55,17 @@
env['SERVER_PROTOCOL'] = self.protocol_version
env['GATEWAY_INTERFACE'] = 'CGI/1.1'
if self._server._verbose:
- requestURI = Funcs.requestURI(env)
+ uri = requestURI(env)
startTime = time.time()
- sys.stdout.write('%5i %s %s\n' % (self._requestID,
- timestamp()['pretty'], requestURI))
+ sys.stdout.write('%5i %s %s\n'
+ % (self._requestID, timestamp()['pretty'], uri))
self.doTransaction(env, self.rfile)
if self._server._verbose:
duration = ('%0.2f secs' % (time.time() - startTime)).ljust(19)
- sys.stdout.write('%5i %s %s\n\n' % (self._requestID,
- duration, requestURI))
+ sys.stdout.write('%5i %s %s\n\n'
+ % (self._requestID, duration, uri))
do_GET = do_POST = do_HEAD = handleRequest
# These methods are used in WebDAV requests:
Modified: Webware/trunk/WebKit/SidebarPage.py
==============================================================================
--- Webware/trunk/WebKit/SidebarPage.py (original)
+++ Webware/trunk/WebKit/SidebarPage.py Thu Apr 12 14:39:36 2007
@@ -156,12 +156,12 @@
def writeContextsMenu(self):
self.menuHeading('Contexts')
- adapterName = self.request().adapterName()
+ servletPath = self.request().servletPath()
ctxs = self.application().contexts().keys()
- ctxs = filter(lambda ctx: ctx!='default' and ctx.find('/')<0, ctxs)
+ ctxs = filter(lambda ctx: ctx != 'default' and not '/' in ctx, ctxs)
ctxs.sort()
for ctx in ctxs:
- self.menuItem(ctx, '%s/%s/' % (adapterName, ctx))
+ self.menuItem(ctx, '%s/%s/' % (servletPath, ctx))
def writeWebwareEmailMenu(self):
self.menuHeading('E-mail')
Modified: Webware/trunk/WebKit/Testing/DebugPage.py
==============================================================================
--- Webware/trunk/WebKit/Testing/DebugPage.py (original)
+++ Webware/trunk/WebKit/Testing/DebugPage.py Thu Apr 12 14:39:36 2007
@@ -5,7 +5,7 @@
def state(self):
_evars = ('PATH_INFO', 'REQUEST_URI', 'SCRIPT_NAME')
_pvars = ('urlPath', 'previousURLPaths',
- 'adapterName', 'contextName',
+ 'adapterName', 'servletPath', 'contextName',
'serverSidePath', 'serverSideContextPath',
'extraURLPath')
req = self.request()
Modified: Webware/trunk/WebKit/Testing/IncludeURLTest.py
==============================================================================
--- Webware/trunk/WebKit/Testing/IncludeURLTest.py (original)
+++ Webware/trunk/WebKit/Testing/IncludeURLTest.py Thu Apr 12 14:39:36 2007
@@ -78,12 +78,13 @@
env = req._environ
self.writeln("<pre>")
w("serverSidePath(): %s" % req.serverSidePath())
+ w("adapterName(): %s" % req.adapterName())
+ w("servletPath(): %s" % req.servletPath())
w("contextName(): %s" % req.contextName())
w("serverSideContextPath(): %s" % req.serverSideContextPath())
w("extraURLPath(): %s" % req.extraURLPath())
w("urlPath(): %s" % req.urlPath())
w("previousURLPaths(): %s" % ', '.join(req.previousURLPaths()))
- w("adapterName(): %s" % req.adapterName())
w("Environment:" )
w("REQUEST_URI: %s" % env.get('REQUEST_URI', ''))
w("PATH_INFO: %s" % env.get('PATH_INFO', ''))
Modified: Webware/trunk/WebKit/Testing/Main.py
==============================================================================
--- Webware/trunk/WebKit/Testing/Main.py (original)
+++ Webware/trunk/WebKit/Testing/Main.py Thu Apr 12 14:39:36 2007
@@ -25,7 +25,7 @@
def writeTestCases(self):
wr = self.writeln
req = self.request()
- adapterName = req.adapterName()
+ servletPath = req.servletPath()
filename = self.serverSidePath('TestCases.data')
self._cases = self.readFileNamed(filename)
wr('<table align="center" style="margin-left:auto;margin-right:auto"'
@@ -37,13 +37,13 @@
# For each URL, fix it up and make a name. Put in urls list.
urls = []
for url in case['URLs']:
- url = adapterName + url
+ url = servletPath + url
if url:
urlName = self.htmlEncode(url)
urls.append((url, urlName))
if not urls:
continue
- expectation = case['Expectation'] #self.htmlEncode(case['Expectation'])
+ expectation = case['Expectation'] # self.htmlEncode(case['Expectation'])
bgcolor = ['EEE', 'DDD'][caseNum % 2]
wr('<tr style="background-color:#%s">'
'<td>%d.</td><td>' % (bgcolor, caseNum))
Modified: Webware/trunk/WebKit/Testing/TestIMS.py
==============================================================================
--- Webware/trunk/WebKit/Testing/TestIMS.py (original)
+++ Webware/trunk/WebKit/Testing/TestIMS.py Thu Apr 12 14:39:36 2007
@@ -25,10 +25,10 @@
self._host = sd['HTTP_HOST'] # includes the port
self._httpconnection = sd.get('HTTPS', '').lower() == 'on' \
and httplib.HTTPSConnection or httplib.HTTPConnection
- adapter = self.request().adapterName()
+ servletPath = self.request().servletPath()
self.write('<h2>Test If-Modified-Since support in Webware</h2>')
# pick a static file which is served up by Webwares UnknownFileHandler
- self.runTest('%s/PSPExamples/psplogo.png' % adapter)
+ self.runTest('%s/PSPExamples/psplogo.png' % servletPath)
def runTest(self, path):
import time
Modified: Webware/trunk/WebKit/ThreadedAppServer.py
==============================================================================
--- Webware/trunk/WebKit/ThreadedAppServer.py (original)
+++ Webware/trunk/WebKit/ThreadedAppServer.py Thu Apr 12 14:39:36 2007
@@ -29,7 +29,7 @@
from AutoReloadingAppServer import AutoReloadingAppServer as AppServer
from ASStreamOut import ASStreamOut, ConnectionAbortedError
from MiscUtils.Funcs import timestamp
-from WebUtils import Funcs
+from WebUtils.Funcs import requestURI
debug = False
@@ -804,10 +804,10 @@
return
if verbose:
- requestURI = requestDict.has_key('environ') \
- and Funcs.requestURI(requestDict['environ']) or '-'
- sys.stdout.write('%5i %s %s\n' % (self._requestID,
- timestamp()['pretty'], requestURI))
+ uri = requestDict.has_key('environ') \
+ and requestURI(requestDict['environ']) or '-'
+ sys.stdout.write('%5i %s %s\n'
+ % (self._requestID, timestamp()['pretty'], uri))
requestDict['input'] = self.makeInput()
requestDict['requestID'] = self._requestID
@@ -828,8 +828,8 @@
if verbose:
duration = ('%0.2f secs' % (time.time() - self._startTime)).ljust(19)
- sys.stdout.write('%5i %s %s\n\n' % (self._requestID,
- duration, aborted and '*connection aborted*' or requestURI))
+ sys.stdout.write('%5i %s %s\n\n' % (self._requestID, duration,
+ aborted and '*connection aborted*' or uri))
transaction._application = None
transaction.die()
Modified: Webware/trunk/WebKit/URLParser.py
==============================================================================
--- Webware/trunk/WebKit/URLParser.py (original)
+++ Webware/trunk/WebKit/URLParser.py Thu Apr 12 14:39:36 2007
@@ -271,7 +271,7 @@
# If there is no path, redirect to the root path:
req = trans.request()
if not requestPath:
- p = req.adapterName() + '/'
+ p = req.servletPath() + '/'
q = req.queryString()
if q:
p += "?" + q
Modified: Webware/trunk/WebUtils/Funcs.py
==============================================================================
--- Webware/trunk/WebUtils/Funcs.py (original)
+++ Webware/trunk/WebUtils/Funcs.py Thu Apr 12 14:39:36 2007
@@ -132,17 +132,19 @@
html.append('</table>')
return ''.join(html)
-def requestURI(dict):
+def requestURI(env):
"""Return the request URI for a given CGI-style dictionary.
Uses REQUEST_URI if available, otherwise constructs and returns it
- from SCRIPT_NAME, PATH_INFO and QUERY_STRING.
+ from SCRIPT_URL, SCRIPT_NAME, PATH_INFO and QUERY_STRING.
"""
- uri = dict.get('REQUEST_URI', None)
+ uri = env.get('REQUEST_URI', None)
if uri is None:
- uri = dict.get('SCRIPT_NAME', '') + dict.get('PATH_INFO', '')
- query = dict.get('QUERY_STRING', '')
+ uri = env.get('SCRIPT_URL', None)
+ if uri is None:
+ uri = env.get('SCRIPT_NAME', '') + env.get('PATH_INFO', '')
+ query = env.get('QUERY_STRING', '')
if query != '':
uri += '?' + query
return uri
Modified: Webware/trunk/bin/MakeAppWorkDir.py
==============================================================================
--- Webware/trunk/bin/MakeAppWorkDir.py (original)
+++ Webware/trunk/bin/MakeAppWorkDir.py Thu Apr 12 14:39:36 2007
@@ -479,15 +479,15 @@
which you can get to from here:</p>
<ul>
''')
- adapterName = self.request().adapterName()
+ servletPath = self.request().servletPath()
contextName = self.request().contextName()
ctxs = self.application().contexts().keys()
ctxs.sort()
for ctx in ctxs:
- if ctx in ('default', contextName) or ctx.find('/') >= 0:
+ if ctx in ('default', contextName) or '/' in ctx:
continue
self.writeln('<li><a href="%s/%s/">%s</a></li>'
- % (adapterName, ctx, ctx))
+ % (servletPath, ctx, ctx))
self.writeln('</ul>')
"""
|