scottinthebooth
scottinthebooth

Reputation: 135

How to dynamically change CherryPy configuration

I'm using CherryPy to develop a local application. When the program starts I use the staticdir tools to setup the initial file location.

   self.conf [ '/images' ] = {
      'tools.staticdir.on': True,
      'tools.staticdir.dir': startDir
   }
   cherrypy.config.update ( self.conf )

This works and my files are served properly. Later the user can navigate through the folders and pick a different directory to work from. I update the config and pass it to update but the new directory is not served.

   self.conf [ '/images' ] = {
      'tools.staticdir.on': True,
      'tools.staticdir.dir': newDir
   }
   cherrypy.config.update ( self.conf )

This does not work.

I've also tried

cherrypy.lib.static.staticdir( section="images" , dir=self.path , debug=True )

which does not work.

How can I dynamically change which directory is being served?

Upvotes: 1

Views: 19

Answers (0)

Related Questions