Edgewall Software
Modify

Ticket #6118 (new enhancement)

Opened 4 years ago

Last modified 4 years ago

[patch] Add extension point for Session modification

Reported by: Morris Owned by: jonas
Priority: low Milestone: next-major-0.1X
Component: general Version: devel
Severity: normal Keywords: session extension
Cc: gt4329b@…
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

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

Download all attachments as: .zip

Change History

Changed 4 years ago by Morris

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

comment:1 Changed 4 years ago by Morris

  • Cc gt4329b@… added

comment:2 Changed 4 years ago by osimons

  • Milestone set to 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.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from jonas. Next status will be 'new'
The owner will be changed from jonas to anonymous. Next status will be 'assigned'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.