Opened 17 years ago
Last modified 9 years ago
#6118 new enhancement
[patch] Add extension point for Session modification
Reported by: | Morris | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | next-major-releases |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | patch session extension |
Cc: | gt4329b@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I realize that the IUserdirectory functionality currently scheduled for 0.12 will (and should) in all likelihood supercede this …but I need it now.
This patch adds a new extension point in trac/web/main.py
called ISessionObserver. Calls to _get_session (performed as part of every request dispatch) will call pass_user_fields(username, email, name) on every component that implements ISessionObserver; the required return is a tuple of the form (newemail, newname). If the returned values are non-None and different from the original values, the main Session dict is updated before being returned.
What is this good for? If you've ever wanted to autopopulate-at-login your user's display names and/or email addresses, then here you go. Apply this patch, then write a plugin that implements ISessionObserver and does your user data lookup in the pass_user_fields method. If this means hitting a DB, I'd strongly recommend adding some simple caching to your plugin to reduce the flurry of DB hits that this feature would cause :)
NOTE: you'll probably only want to implement ISessionObserver in one plugin — having multiple ISessionObserver components will behave in undefined ways since there's no way (to my knowledge) to guarantee the order in which they'll be called.
Attachments (1)
Change History (5)
by , 17 years ago
Attachment: | ISessionObserver_r6047.diff added |
---|
comment:1 by , 17 years ago
Cc: | added |
---|
comment:2 by , 17 years ago
Milestone: | → 0.12 |
---|
I'm just setting this to 0.12 to get it on the radar along with the other user-related feature requests that may be handled there.
comment:3 by , 10 years ago
Owner: | removed |
---|
comment:4 by , 9 years ago
Keywords: | patch added |
---|
patch to add ISessionObserver to trac/web/main.py (against 0.11 dev/trunk)