Le 10/07/2011 13:08, Stéphane Klein a écrit :
Hi,

I've some difficulty with config.add_route :

* I would like to match : "/edit.html" and "/.*/edit.html

Actually, I do that :

config.add_route(
"edit_page", "{traverse}/edit.html",
traverse="{traverse}"
)
config.add_view(
edit_page_view,
route_name="edit_page",
context=Resource,
renderer="edit_page.tmpl"
)
config.add_route(
"root_edit_page", "/edit.html",
traverse="/"
)
config.add_view(
root_edit_page_view,
route_name="root_edit_page",
context=Resource,
renderer="edit_page.tmpl"
)

This work but I think it's not clean.

I would like to do that :

config.add_route(
"edit_page", "{traverse:.*}/edit.html",
traverse="{traverse}"
)
config.add_view(
edit_page_view,
route_name="edit_page",
context=Resource,
renderer="edit_page.tmpl"
)

But {traverse:.*} don't match empty string.

How can I fix it ?

I found the solution to fix all my issues :

    config.add_route(
        "edit_page", "{traverse:.*}edit.html",
        traverse="*traverse"
    )
    config.add_view(
        edit_page_view,
        route_name="edit_page",
        context=Resource,
        renderer="edit_page.tmpl"
    )

I think that document need to have « traverse="*traverse" » example.
It's difficult to found this tips without example. I've needed to launch debug in pyramid source code to understand how this mechanism work.

Regards,
Stephane
--
Stéphane Klein <[email protected]>
blog: http://stephane-klein.info
Twitter: http://twitter.com/klein_stephane
pro: http://www.is-webdesign.com

--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to