Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 443

Show
Ignore:
Timestamp:
07/10/05 10:19:22
Author:
mikerobi
Message:

Fixed bug where builtin filters would not be reinitialized if the server is restarted. Improvments to the sessionfilter test program

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cputil.py

    r408 r443  
    211211    _cpDefaultInputFilterList  = [] 
    212212    _cpDefaultOutputFilterList = [] 
    213  
     213    _cpDefaultFilterInstances = {} 
     214     
    214215    for filterName in __cpDefaultInputFilters: 
    215216        filterClass = _cpDefaultFilterClasses[filterName] 
    216         filterInstance = _cpDefaultFilterInstances.setdefault(filterName, filterClass()
     217        filterInstance = _cpDefaultFilterInstances[filterName] = filterClass(
    217218        _cpDefaultInputFilterList.append(filterInstance) 
    218219     
  • trunk/cherrypy/test/test_session_filter.py

    r442 r443  
    7878    anydb.exposed = True 
    7979 
     80 
     81import threading 
     82 
    8083cherrypy.root = TestSite() 
    8184cherrypy.config.update(server_conf.copy()) 
    8285 
    83 import threading 
     86def reloadCP(): 
     87    reload(cherrypy) 
     88    cherrypy.config.update(server_conf.copy()) 
     89    cherrypy.server.start(initOnly = True) 
    8490 
    8591class SessionFilterTest(unittest.TestCase): 
    8692 
    87     persistantCookies = [] 
    88  
    89     def __testStorageType(self, storageType, startCount = 1, iterations = 4): 
     93    def __testStorageType(self, storageType, startCount = 1, iterations = 5, persistant=False): 
    9094        #cherrypy.config.update({"sessionFilter.storageType": storageType}) 
    9195         
     
    97101        # this loop will be used to test thread safety 
    98102        for n in xrange(startCount+1, startCount + iterations + 1): 
     103            if persistant: 
     104                cherrypy.server.stop() 
     105                cherrypy.server.start(initOnly = True) 
    99106            helper.request('/' + storageType, [('Cookie', cookie)]) 
    100107            self.assertEqual(cherrypy.response.body, str(n)) 
    101          
     108 
     109    def __testCleanUp(self, storageType): 
     110        pass 
     111 
     112    def __testCacheCleanUp(self, storageType): 
     113        pass 
     114     
    102115    def testRamSessions(self): 
    103         self.__testStorageType('ram'
     116        self.__testStorageType('ram', persistant=False
    104117     
    105118    def testFileSessions(self): 
    106         self.__testStorageType('file'
     119        self.__testStorageType('file', persistant=True
    107120     
    108121    def testAnydbSessions(self): 
    109         self.__testStorageType('anydb'
     122        self.__testStorageType('anydb', persistant=True
    110123    
    111     def testThreadSafety(self, storageType = 'ram'): 
    112         for z in range(3): 
    113             try: 
    114                 threading.Thread(target = self.__testStorageType, args = ('ram', 1, 4)).start() 
    115             except: 
    116                 pass 
    117      
     124    def __testThreadSafety(self, storageType = 'ram'): 
     125        for z in range(30): 
     126            threading.Thread(target = self.__testStorageType, args = ('ram', 1, 4)).start() 
     127 
    118128    ''' 
    119129    def testSqlObjectSession(self): 
     
    126136    except OSError: 
    127137        pass 
    128      
    129     cherrypy.server.start(initOnly=True) 
    130     try: 
    131         unittest.main() 
    132     except SystemExit: 
    133         pass 
    134         #shutil.rmtree(tmpFolder) 
    135         #os.rmdir(tmpFolder) 
     138    
     139    cherrypy.server.start(initOnly = True) 
     140    unittest.main() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets