On Monday November 17, 2008 16:18:14 drakkan wrote: > thanks for your hints, I'm jsonifing login however I would take > advantage of already implented tg handler and not recheck user and > pass against db table, how can I call login_hadler and intercept his > response? So I can give different json responses based on > login_handler output,
repoze.what internally configures repoze.who to use its RedirectingFormPlugin [1] challenger plugin. That's the component which returns the output you don't want. So, one solution is that you create your own repoze.who challenger plugin that returns the JSON-based output you want [2] (its challenge() method _must_ return None when the form should be displayed). As a consequence, you wouldn't be able to use part of TG2's repoze.what integration (no big deal, it gives you more flexibility) and therefore you will have to configure auth yourself as explained here: http://static.repoze.org/whatdocs/#using-authentication-and-authorization- without-the-quickstart Your add_auth() function may look like this (I have not tested it!): > def add_auth(app, config): > from repoze.who.plugins.form import RedirectingFormPlugin > from repoze.what.plugins.quickstart import setup_sql_auth > > from {yourpackage}.{whatever} import YourOwnJsonChallenger > from {yourpackage}.model import User, Group, Permission, BDSession > > TheDefaultForm = RedirectingFormPlugin('/login', '/login_handler', > '/logout_handler', > rememberer_name='cookie') > JsonChallenger = YourOwnJsonChallenger() > > app_with_auth = setup_sql_auth( > app, > config, > User, > Group, > Permission, > DBSession, > JsonChallenger, > False, > TheDefaultForm, > challengers=[TheDefaultForm] > ) > return app_with_auth In a nutshell, the function above simply uses an additional repoze.who challenger (yours, for JSON output) and gives a higher priority than the default challenger (RedirectingFormPlugin). You'll find more information in the following docs: http://static.repoze.org/whodocs/ http://static.repoze.org/whatdocs/ HTH. [1] http://static.repoze.org/whodocs/#repoze.who.plugins.form.RedirectingFormPlugin [2] http://static.repoze.org/whodocs/#writing-a-challenger-plugin -- Gustavo Narea. General Secretary. GNU/Linux Matters <http://gnulinuxmatters.org/>. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

