index with "optional parts"

11 views
Skip to first unread message

León Domingo

unread,
Apr 14, 2012, 3:19:18 AM4/14/12
to turbo...@googlegroups.com
Hi,
How do I have to build an "index" controller of this type. I would like to "control" these two requests in one single controller:

   http://mydomain.com/foo
   http://mydomain.com/foo/123

I'm using this now but it's not working anymore with TG 2.1.5 and TG 2.2beta, so I would like to fix it. I've never been confident about this implementation. I think it's probably wrong.

class FooController(BaseController):
    @expose(....)
    def default(self, *args):
        return dict()

Thanks in advance

Moritz Schlarb

unread,
Apr 14, 2012, 4:56:39 AM4/14/12
to turbo...@googlegroups.com
Hello Leon,

if I do:

class FooController(BaseController):

    @expose()
    def default(self, *args, **kwargs):
        return str(args) + str(kwargs)

and go to 
I get 
    ('123',){}

So I can't see that it wouldn't work here.

But depending in your use case, you propably would have more fun with the _lookup method of returning another Controller.

Regards,
Moritz

León Domingo

unread,
Apr 14, 2012, 9:09:06 AM4/14/12
to turbo...@googlegroups.com
Thanks, Moritz

León Domingo

Ender - Factoría de Software
leon.d...@ender.es
Avda. Cerro del Águila, 7. S23 - 2ª Planta
28703 S.S. de los Reyes (MADRID)
Tlf. 902 01 44 01

   


--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/D8T8Q9fivUQJ.
To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

Reply all
Reply to author
Forward
0 new messages