Quantcast

How to get the "section" argument in a custom HandlerTool

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to get the "section" argument in a custom HandlerTool

cherrypy-users mailing list
Hi there!

I'm trying to implement a static handler which serves files from a zip.

So I started with writing my own "staticdir()" and I've registered it via 

cherrypy.tools.zip_staticdir = cherrypy._cptools.HandlerTool(staticdir)



First of all I'm wondering while:
cherrypy.tools.zip_staticdir = cherrypy.HandlerTool(staticdir)

does not work, but
cherrypy.tools.zip_staticdir = cherrypy.Tool(staticdir)

does.


So anyway, the biggest issue is that I need to get the section argument like the default staticdir function is called because my setup looks somehow like this:
 conf = {
   
'/images': {
     
'tools.zip_staticdir.on': True,
     
'tools.zip_staticdir.zobj': self._core.ZipFile,
     
'tools.zip_staticdir.dir': os.path.join(...)
   
},
   
'/js': {
     
'tools.zip_staticdir.on': True,
     
'tools.zip_staticdir.zobj': self._core.ZipFile,
     
'tools.zip_staticdir.dir': os.path.join(...)
   
},
   
'/css': {
     
'tools.zip_staticdir.on': True,
     
'tools.zip_staticdir.zobj': self._core.ZipFile,
     
'tools.zip_staticdir.dir': os.path.join(...)
   
},
 
'/fonts': {
     
'tools.zip_staticdir.on': True,
     
'tools.zip_staticdir.zobj': self._core.ZipFile,
     
'tools.zip_staticdir.dir': os.path.join(...)
   
}
 
}

cherrypy.tree.mount(self.internalApp, '/_/', config=conf)


def staticdir(*args,**kwargs):
 
print(args,kwargs)




Thanks a lot for any helpful hints!

Regards,
Alex

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Loading...