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

Changeset 1698

Show
Ignore:
Timestamp:
07/20/07 16:00:08
Author:
fumanchu
Message:

Test and fix for correct order of application of Handler tool args.

Files:

Legend:

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

    r1668 r1698  
    6666     
    6767    def _merged_args(self, d=None): 
     68        if d: 
     69            conf = d.copy() 
     70        else: 
     71            conf = {} 
     72         
    6873        tm = cherrypy.request.toolmaps[self.namespace] 
    6974        if self._name in tm: 
    70             conf = tm[self._name].copy() 
    71         else: 
    72             conf = {} 
    73         if d: 
    74             conf.update(d) 
     75            conf.update(tm[self._name]) 
     76         
    7577        if "on" in conf: 
    7678            del conf["on"] 
     79         
    7780        return conf 
    7881     
  • trunk/cherrypy/test/test_config.py

    r1688 r1698  
    55 
    66import os, sys 
     7localDir = os.path.join(os.getcwd(), os.path.dirname(__file__)) 
    78import StringIO 
     9 
    810import cherrypy 
    911 
     
    3537            return self.db 
    3638        dbscheme.exposed = True 
     39         
     40        favicon_ico = cherrypy.tools.staticfile.handler( 
     41                        filename=os.path.join(localDir, '../favicon.ico')) 
    3742     
    3843    class Foo: 
     
    8691neg: -1234 
    8792filename: os.path.join(sys.prefix, "hello.py") 
    88 """) 
     93 
     94[/favicon.ico] 
     95tools.staticfile.filename = %r 
     96""" % os.path.join(localDir, 'static/dirback.jpg')) 
    8997     
    9098    root = Root() 
     
    160168        self.getPage("/dbscheme") 
    161169        self.assertBody(r"sqlite///memory") 
     170     
     171    def testHandlerToolConfigOverride(self): 
     172        # Assert that config overrides tool constructor args. Above, we set 
     173        # the favicon in the page handler to be '../favicon.ico', 
     174        # but then overrode it in config to be './static/dirback.jpg'. 
     175        self.getPage("/favicon.ico") 
     176        self.assertBody(open(os.path.join(localDir, "static/dirback.jpg"), 
     177                             "rb").read()) 
    162178 
    163179 

Hosted by WebFaction

Log in as guest/cpguest to create tickets