On 11/3/06, Beies <[EMAIL PROTECTED]> wrote: > Ben Bangert schreef: > > > On Nov 2, 2006, at 2:47 PM, Beies wrote: > > > > > Can someone give me a clear example of > > > how to use h.redirect_to in myghty template? It works in a controller > > > but not in a template > > > > Out of curiosity, why are you changing page flow in a template? I'd > > consider it pretty bad MVC separation to have templates deciding not > > to render themselves and redirecting when your controller > > specifically asked to have a template returned to the user. This is > > also likely to have bad effects later as a template might include > > another that causes a redirect which gives you odd bugs later. > > you're completely right. I was just pushed in the 'myghty' direction > because of a few Myghty examples in which a login-template was used to > protect the login-required part of the website > e.g. > /rootdir with autohandler > /login-required-dir with autohandler > /protected-content/mycontent.myt > > render_response(/login-required-dir/protected-content/mycontent.myt) > always passes the login-required-dir autohandler which tests for a > valid session (or does a redirect). > But I'll use controller now... > > > > > Sessions work rather easily, did you see http://pylonshq.com/docs/ > > 0.9.3/getting_started.html#using-sessions? The specific configuration > > commands are the same as Myghty's, thus the reference. I'd really > > like to make the docs better, so more specific criticism would be > > much appreciated. > > session: the commands are not completely the same as Myghty's command. > Take for example the basic usage example of myghty (which is referred > to in the getting_started guide): > <%python scope="init"> > # get the session > session = m.get_session() > > m = deprecated, get_session() doesn't work (I thought this was > needed...), it fails with a strange error msg: NotImplementedYet or > something. When you know you only have to use the session global it > becomes all very easy of course (after two hours of trying to find out > that m is not supported and that get_session is not needed). > > SQLAlchemy: this was also quite confusing (like the implicit/explicit > discussion of how to set up the connections and sessions) but I think I > managed to get a good setup. But you have to read a lot of mails to get > it working. > > I think I would safe a lot of frustration if there would be a > not-so-straightforward, working example that shows the best practices > of sqlalchemy, logins, sessions, etc. in pylons. > > For the rest: I think it's a great framework! > Thx, Beies
As for SQLAlchemy, I was trying to be helpful in that regard when I wrote <http://pylonshq.com/project/pylonshq/wiki/SqlAlchemyWithPylons>. Logins are something I built myself using my own experience doing it in the past. I think a few Web application frameworks have some stuff baked in, but I don't think Pylons is there yet in that regard. As for sessions, it's important not to confuse SQLAlchemy sessions with normal Web application sessions. I was confused when I read your email. My SQLAlchemy doc above shows how I did it. I think my doc differs from the Wiki tutorial because I explicitly needed access to the database so in order to autoload the schema. Happy Hacking! -jj -- http://jjinux.blogspot.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 -~----------~----~----~----~------~----~------~--~---
