Edgewall Software
Modify

Opened 12 years ago

Last modified 4 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:

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)

ISessionObserver_r6047.diff (2.2 KB ) - added by Morris 12 years ago.
patch to add ISessionObserver to trac/web/main.py (against 0.11 dev/trunk)

Download all attachments as: .zip

Change History (5)

by Morris, 12 years ago

Attachment: ISessionObserver_r6047.diff added

patch to add ISessionObserver to trac/web/main.py (against 0.11 dev/trunk)

comment:1 by Morris, 12 years ago

Cc: gt4329b@… added

comment:2 by osimons, 12 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 Ryan J Ollos, 4 years ago

Owner: Jonas Borgström removed

comment:4 by figaro, 4 years ago

Keywords: patch added

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.