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 > > > wrote: > > thread locals have all the problems which are generally associated > with global variables. They might be overwritten by

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 :) >> >>>

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

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

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

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 > >

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

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

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

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 =