Directories in URLS should ALWAYS have / at the end. That prevents a lot of confusion as well as help the web/app server that analyzes the URL to determine the proper prefixes. For example, to match anything under /static directory, you need to use a prefix pattern "/static/" and not simply "/static" otherwise URLs such as /static1 will also match. The problem is that the URL /static will not match the pattern "/ static/", so that's why you always want your generated URLs to have a / after EACH directory in the URL. The only case you don't control is when the user goes to the root page of your domain (e.g. www.mysite.com) but luckily in that case the web server will treat this URLs path info as "/"
On Nov 19, 9:05 am, "Mike Orr" <[email protected]> wrote: > On Wed, Nov 19, 2008 at 7:28 AM, Raoul Snyman <[email protected]> wrote: > > > Hi all, > > > I'm attempting to upgrade my Pylons app to 0.9.7, but I can't seem to > > get past the "302 you will now be redirected" problem. > > > What I did was I created a totally new Pylons app, and then I started > > moving my controllers and models and things across. I'm not sure if > > this is the best way, but I figured it was most probably the easiest. > > I also read through the "What's new in 0.9.7" document and the > > "Upgrading" document on the wiki, and followed directions as much as I > > could. > > > I've left map.minimize on False, and I added the extra lines in my > > routes.py file as per the documentation. I also made sure that my > > middleware.py file had the necessary lines. I also modified base.py > > and the BaseController class, because my authentication system checks > > for a valid user in the __before__ function. > > > Now the problem comes in that when I hit the main page, my default > > controller sees that there's no user logged in and tries to redirect > > me to the login page. Except it just sits there saying "302 Found The > > resource was found athttp://localhost:5000/member/login/;you should > > be redirected automatically." and never redirects me. > > > routes.py:http://codepad.org/d4lpLxas > > middleware.py:http://codepad.org/kdnRbRpl > > base.py:http://codepad.org/qIvkBnxK > > > Any idea what am I doing wrong? > > I have a similar authentication system in a Pylons 0.9.7 app so I can > verify it works. > > Looking at your modules, I didn't know Routes had an .append_slash > option but that could be throwing it off. There's no reason to put > slashes at the end of URLs except to make it look like a directory to > the user, but even then it's not necessary (/messages and > /messages/1234 work fine). > > There's another redirect_to function in pylons.controllers.util which > you should be using instead, as routes.redirect_to is being phased > out. But they should both behave the same. > > You should be putting h.url_for() around all URLs, as that will adjust > the URL if it needs a prefix someday. Or you can use Pylons 0.9.7's > fancy url() object (pylons.url), which will be its replacement in > Pylons 1.0. > > You can turn on route debugging to see if it gives any clues. Add > this to development.ini: > > === > [logger_routes] > level = DEBUG > handlers = > qualname = routes.middleware > === > > And add 'routes' to the 'keys' option in [loggers]. > > If none of these help, I would check your app under Live HTTP Headers > to see what it's actually doing. The 302 response should have a > Location: header with the absolute URL to redirect to. > > -- > Mike Orr <[email protected]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
