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 this is because the POST > dict uses unicode, but Python expects strings or something like that. > The only thing I found about this was in the django IRC archives and > the person's solution was "don't do that... check the newforms docs" > > But, shouldn't I be able to send post data that isn't from a form? > And, shouldn't I be able to access request.POST like a dict? I want my > views to be generic and I don't know what my keywords are. > > 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 data in nice keyword/value pairs, why should > I have to loop through them just to pass them to a function?
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: def perform(self, datadict): What could you do with 'kwargs' in your syntax that you cannot do with 'datadict' in this alternative? Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---