Re: Current user in model.save() context

2009-07-21 Thread Bartłomiej Górny
Joshua Russo wrote: > On Mon, Jul 20, 2009 at 9:23 AM, Matthias Kestenholz > mailto:matthias.kestenh...@gmail.com>> > wrote: > > thread locals have all the problems which are generally associated > with global variables. They might be overwritten by other code, they > make testing e

Re: Current user in model.save() context

2009-07-21 Thread Bartłomiej Górny
Matthias Kestenholz wrote: > On Mon, Jul 20, 2009 at 9:26 AM, Bartłomiej Górny wrote: >> [...] >>> there is a cookbook recipe for achieving this sort of thing: >>> >>> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser >> Yep, that's exactly what I did :) >> >>> That's deep in the cate

Re: Current user in model.save() context

2009-07-20 Thread Joshua Russo
On Mon, Jul 20, 2009 at 9:23 AM, Matthias Kestenholz < matthias.kestenh...@gmail.com> wrote: > thread locals have all the problems which are generally associated > with global variables. They might be overwritten by other code, they > make testing extremely difficult because the behavior of method

Re: Current user in model.save() context

2009-07-20 Thread Matthias Kestenholz
On Mon, Jul 20, 2009 at 9:26 AM, Bartłomiej Górny wrote: > [...] >> there is a cookbook recipe for achieving this sort of thing: >> >> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > Yep, that's exactly what I did :) > >> >> That's deep in the category of 'give them rope to hang

Re: Current user in model.save() context

2009-07-20 Thread Bartłomiej Górny
Matthias Kestenholz wrote: > On Fri, Jul 17, 2009 at 4:24 PM, Bartłomiej Górny wrote: >> Phil wrote: >>> Hi Josh, >>> >>> unfortunately it seems that there is no way to do so. As you've >>> noticed that correctly you can use request (request.user) in any place >>> but model save. >> Yes, I bumped

Re: Current user in model.save() context

2009-07-18 Thread Joshua Russo
On Sat, Jul 18, 2009 at 8:06 AM, Matthias Kestenholz < matthias.kestenh...@gmail.com> wrote: > If you really need to do that (or if you are just extremely lazy) > there is a cookbook recipe for achieving this sort of thing: > > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > Tha

Re: Current user in model.save() context

2009-07-18 Thread Matthias Kestenholz
On Fri, Jul 17, 2009 at 4:24 PM, Bartłomiej Górny wrote: > > Phil wrote: >> Hi Josh, >> >> unfortunately it seems that there is no way to do so. As you've >> noticed that correctly you can use request (request.user) in any place >> but model save. > > Yes, I bumped into the same problem and came t

Re: Current user in model.save() context

2009-07-17 Thread Shawn Milochik
I think you still have to pass the user, but you can tell if the item is modified or new by whether its id has a value. If it's brand new and has never been saved, then it won't have one. --~--~-~--~~~---~--~~ You received this message because you are subscribe

Re: Current user in model.save() context

2009-07-17 Thread Bartłomiej Górny
Phil wrote: > Hi Josh, > > unfortunately it seems that there is no way to do so. As you've > noticed that correctly you can use request (request.user) in any place > but model save. Yes, I bumped into the same problem and came to the same conclusion. No way. Unless you hack out something along t

Re: Current user in model.save() context

2009-07-16 Thread Phil
Hi Josh, unfortunately it seems that there is no way to do so. As you've noticed that correctly you can use request (request.user) in any place but model save. most likely that will be view: --- if form.is_valid(): newObj = form.save(commit=False) newObj.user = request.u

Current user in model.save() context

2009-07-16 Thread Joshua Russo
I think I might be overlooking something simple here. I have a set of 4 fields in almost every table (user create & modified and date create & modified). The date (datetime) is easy with auto_now and auto_now_add options. The user has been much trickier. I can't figure out how (if possible) to ge