viewvc-4intranet/lib/sapi.py

446 lines
13 KiB
Python
Raw Normal View History

# -*-python-*-
#
# Copyright (C) 1999-2013 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewVC
# distribution or at http://viewvc.org/license-1.html.
#
# For more information, visit http://viewvc.org/
#
# -----------------------------------------------------------------------
#
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
# generic server api - currently supports normal cgi, mod_python, and
# active server pages
#
# -----------------------------------------------------------------------
import types
import os
import sys
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
import re
import cgi
# global server object. It will be either a CgiServer, a WsgiServer,
# or a proxy to an AspServer or ModPythonServer object.
server = None
# Simple HTML string escaping. Note that we always escape the
# double-quote character -- ViewVC shouldn't ever need to preserve
# that character as-is, and sometimes needs to embed escaped values
# into HTML attributes.
def escape(s):
try: s = s.encode('utf8')
except: pass
s = str(s)
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
s = s.replace('&', '&')
s = s.replace('>', '>')
s = s.replace('<', '&lt;')
s = s.replace('"', "&quot;")
return s
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
class Server:
def __init__(self):
self.pageGlobals = {}
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def self(self):
return self
def escape(self, s):
return escape(s)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def close(self):
pass
class ThreadedServer(Server):
def __init__(self):
Server.__init__(self)
self.inheritableOut = 0
global server
if not isinstance(server, ThreadedServerProxy):
server = ThreadedServerProxy()
if not isinstance(sys.stdout, File):
sys.stdout = File(server)
server.registerThread(self)
def file(self):
return File(self)
def close(self):
server.unregisterThread()
class ThreadedServerProxy:
"""In a multithreaded server environment, ThreadedServerProxy stores the
different server objects being used to display pages and transparently
forwards access to them based on the current thread id."""
def __init__(self):
self.__dict__['servers'] = { }
global thread
import thread
def registerThread(self, server):
self.__dict__['servers'][thread.get_ident()] = server
def unregisterThread(self):
del self.__dict__['servers'][thread.get_ident()]
def self(self):
"""This function bypasses the getattr and setattr trickery and returns
the actual server object."""
return self.__dict__['servers'][thread.get_ident()]
def __getattr__(self, key):
return getattr(self.self(), key)
def __setattr__(self, key, value):
setattr(self.self(), key, value)
def __delattr__(self, key):
delattr(self.self(), key)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
class File:
def __init__(self, server):
self.closed = 0
self.mode = 'w'
self.name = "<AspFile file>"
self.softspace = 0
self.server = server
def write(self, s):
self.server.write(s)
def writelines(self, list):
for s in list:
self.server.write(s)
def flush(self):
self.server.flush()
def truncate(self, size):
pass
def close(self):
pass
class CgiServer(Server):
def __init__(self, inheritableOut = 1):
Server.__init__(self)
self.headerSent = 0
self.headers = []
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
self.inheritableOut = inheritableOut
self.iis = os.environ.get('SERVER_SOFTWARE', '')[:13] == 'Microsoft-IIS'
if sys.platform == "win32" and inheritableOut:
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
global server
server = self
def addheader(self, name, value):
self.headers.append((name, value))
def header(self, content_type='text/html; charset=UTF-8', status=None):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
if not self.headerSent:
self.headerSent = 1
extraheaders = ''
for (name, value) in self.headers:
extraheaders = extraheaders + '%s: %s\r\n' % (name, value)
Work on issue 168, s/ViewCVS/ViewVC. This patch changes references to ViewCVS in comments, strings, and documentation. References to ViewCVS in filenames and urls still need to be fixed. Also, logo.png (the blimp) needs to be updated or replaced. This patch is by Gerard Gerritsen (sigcafe), the only change I've made is to restore a reference to ViewCVS in a comment about backwards compatibility. * windows/README * viewcvs-install * README * templates/include/footer.ezt * templates/include/header.ezt * templates/error.ezt * templates/query.ezt * templates/docroot/help.css * templates/docroot/help_query.html * templates/docroot/help_dirview.html * templates/docroot/help_rootview.html * templates/docroot/styles.css * templates/docroot/help_log.html * templates/diff.ezt * tools/make-release * lib/sapi.py * lib/dbi.py * lib/accept.py * lib/cvsdb.py * lib/config.py * lib/query.py * lib/vclib/bincvs/__init__.py * lib/vclib/svn/__init__.py * lib/vclib/__init__.py * lib/vclib/svn_ra/__init__.py * lib/vclib/ccvs/rcsparse/common.py * lib/vclib/ccvs/rcsparse/__init__.py * lib/vclib/ccvs/rcsparse/default.py * lib/vclib/ccvs/rcsparse/texttools.py * lib/vclib/ccvs/rcsparse/debug.py * lib/vclib/ccvs/__init__.py * lib/vclib/ccvs/blame.py * lib/blame.py * lib/popen.py * lib/compat.py * lib/viewcvs.py * lib/debug.py * INSTALL * bin/standalone.py * bin/make-database * bin/mod_python/query.py * bin/mod_python/viewcvs.py * bin/cgi/query.cgi * bin/cgi/viewcvs.cgi * bin/asp/query.asp * bin/asp/viewcvs.asp * bin/svndbadmin * bin/loginfo-handler * bin/cvsdbadmin * viewcvs.conf.dist git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1200 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-17 20:19:28 +03:00
# The only way ViewVC pages and error messages are visible under
# IIS is if a 200 error code is returned. Otherwise IIS instead
# sends the static error page corresponding to the code number.
if status is None or (status[:3] != '304' and self.iis):
status = ''
else:
status = 'Status: %s\r\n' % status
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
sys.stdout.write('%sContent-Type: %s\r\n%s\r\n'
% (status, content_type, extraheaders))
def redirect(self, url):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
if self.iis: url = fix_iis_url(self, url)
self.addheader('Location', url)
self.header(status='301 Moved')
sys.stdout.write('This document is located <a href="%s">here</a>.\n' % url)
def getenv(self, name, value=None):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
ret = os.environ.get(name, value)
if self.iis and name == 'PATH_INFO' and ret:
ret = fix_iis_path_info(self, ret)
return ret
def params(self):
return cgi.parse()
def FieldStorage(fp=None, headers=None, outerboundary="",
environ=os.environ, keep_blank_values=0, strict_parsing=0):
return cgi.FieldStorage(fp, headers, outerboundary, environ,
keep_blank_values, strict_parsing)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def write(self, s):
sys.stdout.write(s)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def flush(self):
sys.stdout.flush()
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def file(self):
return sys.stdout
class WsgiServer(Server):
def __init__(self, environ, start_response):
Server.__init__(self)
self._environ = environ
self._start_response = start_response;
self._headers = []
self._wsgi_write = None
self.headerSent = False
global server
server = self
def addheader(self, name, value):
self._headers.append((name, value))
def header(self, content_type='text/html; charset=UTF-8', status=None):
if not status:
status = "200 OK"
if not self.headerSent:
self.headerSent = True
self._headers.insert(0, ("Content-Type", content_type),)
self._wsgi_write = self._start_response("%s" % status, self._headers)
def redirect(self, url):
"""Redirect client to url. This discards any data that has been queued
to be sent to the user. But there should never by any anyway.
"""
self.addheader('Location', url)
self.header(status='301 Moved')
self._wsgi_write('This document is located <a href="%s">here</a>.' % url)
def getenv(self, name, value=None):
return self._environ.get(name, value)
def params(self):
return cgi.parse(environ=self._environ, fp=self._environ["wsgi.input"])
def FieldStorage(self, fp=None, headers=None, outerboundary="",
environ=os.environ, keep_blank_values=0, strict_parsing=0):
return cgi.FieldStorage(self._environ["wsgi.input"], headers,
outerboundary, self._environ, keep_blank_values,
strict_parsing)
def write(self, s):
self._wsgi_write(s)
def flush(self):
pass
def file(self):
return File(self)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
class AspServer(ThreadedServer):
def __init__(self, Server, Request, Response, Application):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
ThreadedServer.__init__(self)
self.headerSent = 0
self.server = Server
self.request = Request
self.response = Response
self.application = Application
def addheader(self, name, value):
self.response.AddHeader(name, value)
def header(self, content_type=None, status=None):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
# Normally, setting self.response.ContentType after headers have already
# been sent simply results in an AttributeError exception, but sometimes
# it leads to a fatal ASP error. For this reason I'm keeping the
# self.headerSent member and only checking for the exception as a
# secondary measure
if not self.headerSent:
try:
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
self.headerSent = 1
if content_type is None:
self.response.ContentType = 'text/html; charset=UTF-8'
else:
self.response.ContentType = content_type
if status is not None: self.response.Status = status
except AttributeError:
pass
def redirect(self, url):
self.response.Redirect(url)
def getenv(self, name, value = None):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
ret = self.request.ServerVariables(name)()
if not type(ret) is types.UnicodeType:
return value
ret = str(ret)
if name == 'PATH_INFO':
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
ret = fix_iis_path_info(self, ret)
return ret
def params(self):
p = {}
for i in self.request.Form:
p[str(i)] = map(str, self.request.Form[i])
for i in self.request.QueryString:
p[str(i)] = map(str, self.request.QueryString[i])
return p
def FieldStorage(self, fp=None, headers=None, outerboundary="",
environ=os.environ, keep_blank_values=0, strict_parsing=0):
# Code based on a very helpful usenet post by "Max M" (maxm@mxm.dk)
# Subject "Re: Help! IIS and Python"
# http://groups.google.com/groups?selm=3C7C0AB6.2090307%40mxm.dk
from StringIO import StringIO
from cgi import FieldStorage
environ = {}
for i in self.request.ServerVariables:
environ[str(i)] = str(self.request.ServerVariables(i)())
# this would be bad for uploaded files, could use a lot of memory
binaryContent, size = self.request.BinaryRead(int(environ['CONTENT_LENGTH']))
fp = StringIO(str(binaryContent))
fs = FieldStorage(fp, None, "", environ, keep_blank_values, strict_parsing)
fp.close()
return fs
def write(self, s):
t = type(s)
if t is types.StringType:
s = buffer(s)
elif not t is types.BufferType:
s = buffer(str(s))
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
self.response.BinaryWrite(s)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def flush(self):
self.response.Flush()
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
_re_status = re.compile("\\d+")
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
class ModPythonServer(ThreadedServer):
def __init__(self, request):
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
ThreadedServer.__init__(self)
self.request = request
self.headerSent = 0
def addheader(self, name, value):
self.request.headers_out.add(name, value)
def header(self, content_type=None, status=None):
if content_type is None:
self.request.content_type = 'text/html; charset=UTF-8'
else:
self.request.content_type = content_type
self.headerSent = 1
if status is not None:
m = _re_status.match(status)
if not m is None:
self.request.status = int(m.group())
def redirect(self, url):
import mod_python.apache
self.request.headers_out['Location'] = url
self.request.status = mod_python.apache.HTTP_MOVED_TEMPORARILY
self.request.write("You are being redirected to <a href=\"%s\">%s</a>"
% (url, url))
def getenv(self, name, value = None):
try:
return self.request.subprocess_env[name]
except KeyError:
return value
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def params(self):
import mod_python.util
if self.request.args is None:
return {}
else:
return mod_python.util.parse_qs(self.request.args)
def FieldStorage(self, fp=None, headers=None, outerboundary="",
environ=os.environ, keep_blank_values=0, strict_parsing=0):
import mod_python.util
return mod_python.util.FieldStorage(self.request, keep_blank_values, strict_parsing)
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def write(self, s):
self.request.write(s)
def flush(self):
pass
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def fix_iis_url(server, url):
"""When a CGI application under IIS outputs a "Location" header with a url
beginning with a forward slash, IIS tries to optimise the redirect by not
returning any output from the original CGI script at all and instead just
returning the new page in its place. Because of this, the browser does
not know it is getting a different page than it requested. As a result,
The address bar that appears in the browser window shows the wrong location
and if the new page is in a different folder than the old one, any relative
links on it will be broken.
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
This function can be used to circumvent the IIS "optimization" of local
redirects. If it is passed a location that begins with a forward slash it
will return a URL constructed with the information in CGI environment.
If it is passed a URL or any location that doens't begin with a forward slash
it will return just argument unaltered.
"""
if url[0] == '/':
if server.getenv('HTTPS') == 'on':
dport = "443"
prefix = "https://"
else:
dport = "80"
prefix = "http://"
prefix = prefix + server.getenv('HTTP_HOST')
if server.getenv('SERVER_PORT') != dport:
prefix = prefix + ":" + server.getenv('SERVER_PORT')
return prefix + url
return url
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
def fix_iis_path_info(server, path_info):
"""Fix the PATH_INFO value in IIS"""
# If the viewvc cgi's are in the /viewvc/ folder on the web server and a
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
# request looks like
#
# /viewvc/viewvc.cgi/myproject/?someoption
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
#
# The CGI environment variables on IIS will look like this:
#
# SCRIPT_NAME = /viewvc/viewvc.cgi
# PATH_INFO = /viewvc/viewvc.cgi/myproject/
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
#
# Whereas on Apache they look like:
#
# SCRIPT_NAME = /viewvc/viewvc.cgi
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
# PATH_INFO = /myproject/
#
# This function converts the IIS PATH_INFO into the nonredundant form
# expected by ViewVC
* lib/sapi.py - Filled in ModPythonServer and AspServer header() methods to make use of the new http 'status' parameter. Also, changed CgiServer's header() method to ignore the status parameter under IIS to prevent the server from discarding the ViewCVS output and instead sending a static error page. - ModPythonFile and AspFile classes have been eliminated and replaced with a more generic File class. All server classes have new write() and flush() methods. - Common code from AspServer and ModPythonServer has been moved into a base class called ThreadedServer. AspProxy is renamed to ThreadedServerProxy. - All server classes now inherit from a new base class called Server which contains the small amount of code common to all of them. - added fix_iis_path_info() function, renamed IIS_FixURL() to fix_iis_url() - renamed getFile() methods to file() * lib/viewcvs.py - Eliminated global server variable. Changed some scattered server.escape() calls into cgi.escape() calls. Got around other uses of the variable by adding a server member to the Request class. - Deleted gstein's strongly worded comment about the quality of the sapi hack :) - Page-global 'g_name_printed' is now passed as a normal parameter called 'name_printed' to the augment_entry() function - Got rid of some confusing string manipulation in human_readable_diff() - added 'server' parameter to viewcvs.main() to avoid relying on the sapi.server global variable * cgi/viewcvs.cgi, windows/viewcvs.py, windows/viewcvs.asp - Added 'server' parameter to viewcvs.main() calls * standalone.py: - Changed StandaloneServer.header() method to accept http status code - Added 'server' parameter to viewcvs.main() call * lib/query.py - added 'server' parameter to query.main() to avoid relying on the sapi.server global variable - got rid of global 'server' variable and page-global 'viewcvs_link' variable, instead those values are passed as function parameters * cgi/query.cgi, windows/query.py, windows/query.asp - Added 'server' parameter to query.main() calls * lib/debug.py - Changed PrintStackTrace(), PrintException(), and DumpChildren() not to rely on global sapi.server variable and to use new server.write() method * lib/popen.py - changed server.getFile() calls to server.file() git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@642 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-03-13 02:08:09 +03:00
return path_info[len(server.getenv('SCRIPT_NAME', '')):]