I have written a Routes like helper class for use in my app and it i would like to to share it where should i put it?
I love web.py but i wanted controllers ala pylons (needed to route requests to a class methods based on the url) but still keep the separation between get and post requests. For example; say i have a url like "http://localhost/family/father/ codemonkey" normally we would need the following; urls = ( "/family/(.*)/(.*)", "family" ) and a class family defined as follows class family: GET(self, p1, p2): print 'my ', p1 , ' is a ', p2 POST(self): "save data" with my Controller class the code becomes urls = ( "/family(.*)", "family" ) class family(Controller): index(self, param, reqtype): print 'my ', param[0], ' is a ', param[1] you could also write the family class this way (to demo method routing) class family(Controller): father(self, param, reqtype): print 'my father ', ' is a ', param[0] father__POST(self, param, reqtype): "save data" or to be even more verbose you write do it this way too... class family(Controller): father__GET(self, param, reqtype): print 'my father ', ' is a ', param[0] father__POST(self, param, reqtype): "save data" Notes: 1. The reqtype parameter == self.GET or self.POST 2. The post methods were included for completeness (as they have no relevance in this example) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
