Hi Anand Thanks. I get it.
Best regards, Fang Zhou(æšč) On 2012-8-23, at ä¸å12:13, Anand Chitipothu <anandol...@gmail.com> wrote: > On Wed, Aug 22, 2012 at 8:31 PM, Fang Zhou <rothc...@gmail.com> wrote: >> Hi all, >> >> I have many controller like >> >> GameController >> CardController >> PlayerController >> >> and I want to build a dynamic url pattern like >> >> ("/%s/*", "%sController") >> >> Does Web.py provide this kind of url pattern? Or I need to write a central >> controller to dispatch the actions by myself? > > I think you need to write one your self. It is not that hard. > > urls = ("/(.*)/(.*)", "dispatch") > > class dispatch: > def GET(self, name, path): > cls = globals().get(name + "Controller") > method = web.ctx.method.upper() > return getattr(cls(), method)(path) > POST = GET > > You may have to take care of handling AttributeException and raising > NoMethod etc. > > Anand > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To post to this group, send email to webpy@googlegroups.com. > To unsubscribe from this group, send email to > webpy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/webpy?hl=en. > -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to webpy@googlegroups.com. To unsubscribe from this group, send email to webpy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.