Re: using request.POST as keyword args

2008-10-10 Thread bruno desthuilliers
On 9 oct, 20:53, Taylor <[EMAIL PROTECTED]> wrote: > Dave, that is the problem. I need to be able to call perform > elsewhere in the code (not necessarily from a view), and it would be > difficult to build the datadict to do that Why so ??? Using keywords, your call would like this: ab.per

Re: using request.POST as keyword args

2008-10-09 Thread Malcolm Tredinnick
On Thu, 2008-10-09 at 06:56 -0700, Taylor wrote: [...] > My question is: is there any way to do this without wasting the time > of a loop that just writes the values and keys into a new dict that I > actually can pass as a keyword argument? This doesn't seem like a > crazy request. I have my dat

Re: using request.POST as keyword args

2008-10-09 Thread Taylor
Dave, that is the problem. I need to be able to call perform elsewhere in the code (not necessarily from a view), and it would be difficult to build the datadict to do that. I like your solution, though. For now I'm using this loop: data = {} for key in request.POST.keys(): data[str(key

Re: using request.POST as keyword args

2008-10-09 Thread David Durham, Jr.
> I do not understand why you want to do this. Why not just pass request.POST > without the **, and declare your function to take a single argument which > you expect to be a dictionary-like object (as request.POST, a QueryDict, > is)?. That is: > > result = ab.perform(request.POST) > where: > d

Re: using request.POST as keyword args

2008-10-09 Thread Karen Tracey
On Thu, Oct 9, 2008 at 9:56 AM, Taylor <[EMAIL PROTECTED]> wrote: > > I want to be able to do this: > > result = ab.perform(**request.POST) > > where: > def perform(self, **kwargs): > > Of course, this doesn't work, and I get the error "keywords must be > strings". After some searching, I suppose

using request.POST as keyword args

2008-10-09 Thread Taylor
I want to be able to do this: result = ab.perform(**request.POST) where: def perform(self, **kwargs): Of course, this doesn't work, and I get the error "keywords must be strings". After some searching, I suppose this is because the POST dict uses unicode, but Python expects strings or somethin