#754: Identity events
------------------------------+---------------------------------------------
Reporter: Claudio Martinez | Owner: anonymous
Type: enhancement | Status: new
Priority: low | Milestone:
Component: Identity | Version:
Severity: normal | Resolution:
Keywords: |
------------------------------+---------------------------------------------
Comment (by Claudio Martinez <[EMAIL PROTECTED]>):
Attached is a patch that adds some event handling to identity using a
generic event system. It's very, very simple, and other parts of
turbogears can add events too.
I'm using this right now and works for me. I want to share this with other
people that ran into the same limitations I did. There's no way of doing
this without modding identity.
Example:
{{{
import turbogears
def _on_logout(d):
# clear session data
turbogears.events['identity']['on_logout'].append(_on_logout)
def _on_success(d):
# setup some session data
turbogears.events['identity']['on_success'].append(_on_success)
def _on_failure(d):
# audit
turbogears.events['identity']['on_failure'].append(_on_failure)
def _before_validation(d):
# mangle username or password if you like
turbogears.events['identity']['before_validation'].append(_before_validation)
def _after_validation(d):
# audit
turbogears.events['identity']['after_validation'].append(_after_validation)
}}}
d has the keys 'user_name', 'pw', 'visit_key' and, depending if the login
was succesful, 'identity'.
In the patch I moved some stuff out of a try: except: block because it was
only there to catch some KeyError's from some pops and it was executing
the validation method inside it, complicating debugging.
Someone may want to open a separate ticket for this, anyone developing a
new identity provider will thank you :)
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/754>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" 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-tickets
-~----------~----~----~----~------~----~------~--~---