python - CodeIgniter-like Routes in CherryPy -


i'm coming php frameworks, , 1 thing them routing sort of taken care of me: can drop of controllers in directory controllers , automatically call posts::delete(12) when user visits http://www.example.com/posts/delete/12. realize can use routes cherrypy, i'm kind of annoyed how limited documentation is— there's nothing on how should format class name (should call postscontroller()? care?), using routes.mapper.connect() vs routes.connect(), , happens when calls default route (/:controller/:action/:id).

i'd use python, don't want have define every single route. point me python web-framework newb tutorial on how use routes or explain how 1 goes structuring cherrypy web-app can have couple of routes laid out like

d = cherrypy.dispatch.routesdispatcher() d.mapper.connect('main', '/:controller/:action', controller='root', action='index') d.mapper.connect('main', '/:controller/:action/:id', controller='root', action='index') 

and handle me? thanks.

simple way use cherrypy.tree.mount mount controller object. structure of controller give basic routes.

for example:

import cherrypy  class approot:     def index(self):         return "app root's index"     index.exposed = true      controller1 = controller1class()     # controller2 = controller2class(), etc.  class controller1class:       def index(self):          return "controller 1's index"      index.exposed = true       def action1(self, id):          return "you passed %s controller1's action1" % id            action1.exposed = true       # def action2(self, id): etc...  # ... rest of config stuff ...  cherrypy.tree.mount(approot(), '/')    # ... rest of startup stuff.... 

calling following uris call following methods:

see also:


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -