Friday, November 28, 2008


So far I am happy I choose Pylons for the TomsGiftList project but a lack of documentation is slowing things down. So far I have a simulated login page which is not very much at all. I had trouble with login failure. The problem was how to display the login page with an error message. I first tried a redirect but that was never going to work since there was no way to pass data to the redirect. I found a better way to do it.

Pylons allows any URL to be mapped to any controller and action. You configure this in the file. You can also set specific conditions for the mapping like this:
map.connect('login', controller='login', action='check',\
This maps URL /login POST requests to the check method of the login controller. The path is still /login so no redirect is required. It is much more elegant but I only discovered it by accident in the Pylons tutorials. Who knows, there may be a better solution.

No comments:

Post a Comment