Update of /cvsroot/webware/Webware/WebKit
In directory usw-pr-cvs1:/tmp/cvs-serv21231/WebKit
Modified Files:
Application.py
Log Message:
checking in Tavis's implementation of Application.config settings ExtensionsToServe, UseExtensionCascading, ExtensionCascadeOrder, FilesToHide, and FilesToServe
Index: Application.py
===================================================================
RCS file: /cvsroot/webware/Webware/WebKit/Application.py,v
retrieving revision 1.124
retrieving revision 1.125
diff -C2 -d -r1.124 -r1.125
*** Application.py 2001/11/16 17:26:14 1.124
--- Application.py 2001/12/19 13:38:09 1.125
***************
*** 15,18 ****
--- 15,20 ----
from threading import Lock, Thread, Event
from time import *
+ from fnmatch import fnmatch
+
from WebKit.Cookie import Cookie
***************
*** 248,251 ****
--- 250,261 ----
'DirectoryFile': ['index', 'Main'],
'ExtensionsToIgnore': ['.pyc', '.pyo', '.py~', '.bak'],
+ 'ExtensionsToServe': None,
+ 'UseCascadingExtensions':1,
+ 'ExtensionCascadeOrder':['.psp','.py','.html',],
+
+
+ 'FilesToHide': ['.*','*~', '*bak', '*.tmpl', '*.config' ],
+ 'FilesToServe': None,
+
'LogActivity': 1,
'ActivityLogFilename': 'Logs/Activity.csv',
***************
*** 346,351 ****
self.handleMissingPathSession(transaction)
else:
! self.handleGoodURL(transaction)
if request.value('_captureOut_', 0):
response.write('''<br><p><table><tr><td bgcolor=#EEEEEE>
--- 356,376 ----
self.handleMissingPathSession(transaction)
else:
! validFile = 1
! baseName = os.path.split(ssPath)[1]
! for patternToHide in self.setting('FilesToHide'):
! if fnmatch(baseName, patternToHide):
! validFile = 0
+ patternsToServe = self.setting('FilesToServe')
+ if patternsToServe:
+ validFile = 0
+ for patternToServe in self.setting('FilesToServe'):
+ if fnmatch(baseName, patternToServe):
+ validFile = 1
+ if not validFile:
+ self.handleBadURL(transaction)
+ else:
+ self.handleGoodURL(transaction)
+
if request.value('_captureOut_', 0):
response.write('''<br><p><table><tr><td bgcolor=#EEEEEE>
***************
*** 938,951 ****
def filenamesForBaseName(self, baseName):
! '''
! Returns a list of all filenames with extensions existing for baseName, but not including extension found in the setting ExtensionsToIgnore. This utility method is used by serverSideInfoForRequest().
! Example: '/a/b/c' could yield ['/a/b/c.py', '/a/b/c.html'], but will never yield a '/a/b/c.pyc' filename since .pyc files are ignored.
! '''
! filenames = glob(baseName+'.*')
ignoreExts = self.setting('ExtensionsToIgnore')
! for i in range(len(filenames)):
! if os.path.splitext(filenames[i])[1] in ignoreExts: # @@ 2000-06-22 ce: linear search
! filenames[i] = None
! filenames = filter(None, filenames)
if debug:
print '>> filenamesForBaseName(%s) returning %s' % (
--- 963,989 ----
def filenamesForBaseName(self, baseName):
!
! """Returns a list of all filenames with extensions existing for
! baseName, but not including extension found in the setting
! ExtensionsToIgnore. This utility method is used by
! serverSideInfoForRequest(). Example: '/a/b/c' could yield
! ['/a/b/c.py', '/a/b/c.html'], but will never yield a
! '/a/b/c.pyc' filename since .pyc files are ignored."""
!
! filenames = []
ignoreExts = self.setting('ExtensionsToIgnore')
! for filename in glob(baseName+'.*'):
! if os.path.splitext(filename)[1] not in ignoreExts:
! # @@ 2000-06-22 ce: linear search
! filenames.append(filename)
!
! extensionsToServe = self.setting('ExtensionsToServe')
! if extensionsToServe:
! filteredFilenames = []
! for filename in filenames:
! if os.path.splitext(filename)[1] in extensionsToServe:
! filteredFilenames.append(filename)
! filenames = filteredFilenames
!
if debug:
print '>> filenamesForBaseName(%s) returning %s' % (
***************
*** 1102,1108 ****
ssPath = filenames[0]
if debug: print '>> discovered extension, file = %s' % repr(ssPath)
else:
! print 'WARNING: For %s, did not get precisely 1 filename: %s' % (urlPath, filenames)
return None, None, None
elif not os.path.exists(ssPath):
return None, None, None
--- 1140,1160 ----
ssPath = filenames[0]
if debug: print '>> discovered extension, file = %s' % repr(ssPath)
+ elif len(filenames) > 1:
+ foundMatch = 0
+ if self.setting('UseCascadingExtensions'):
+ for ext in self.setting('ExtensionCascadeOrder'):
+ if (ssPath + ext) in filenames:
+ fullPath = ssPath + ext
+ foundMatch = 1
+ break
+ if not foundMatch:
+ print 'WARNING: For %s, did not get precisely 1 filename: %s' %\
+ (urlPath, filenames)
+ return None, None, None
else:
! print 'WARNING: For %s, did not get precisely 1 filename: %s' % \
! (urlPath, filenames)
return None, None, None
+
elif not os.path.exists(ssPath):
return None, None, None
|