Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#1268 closed enhancement (wontfix)

[magic-removal] [patch] Allow access to the current user outside of a request

Reported by: jkocherhans Owned by: adrian
Component: Core (Other) Version: magic-removal
Severity: normal Keywords:
Cc: upadhyay@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

A common request is for modified_by and added_by fields. It's not currently possible to do these automatically in django beacuse the model/manipulator is decoupled from the request object, and the request is the only place that has access to the current user. A couple of attempts to address this issue have been made in #1132 and #1164. These were generally rejected. A common solution for this problem is to store the current user in a thread local. This ticket uses that approach.

Attachments (1)

current_user.diff (7.8 KB) - added by jkocherhans 8 years ago.
initial attempt

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by jkocherhans

initial attempt

comment:1 Changed 8 years ago by anonymous

  • Cc upadhyay@… added

comment:2 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

Thread locals seem too heavyweight for this situation; marking wontfix.

comment:3 Changed 8 years ago by Gacha

I applyed the patch, but how can I use it?

comment:4 Changed 8 years ago by jkocherhans

The django-users list is a more appropriate venue for this question. I wouldn't use this patch, it's certain to break as Django progresses. Another hack (but one that only works with the magic-removal branch) can be found here: http://lukeplant.me.uk/blog.php?id=1107301634

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


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

 
Note: See TracTickets for help on using tickets.