Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to get post data in original order?

By
Robin Chatfield
on 10/20/15, 1:42 PM 1,066 views

I'm writing a controller function that accepts post requests. I need to get the data from the post in the order it was sent to me. It seems like this is possible in werkzeug, by changing the class that the request object uses to store post data, but I can't get it to work in Odoo. I've tried something along these lines:


request.httprequest.parameter_storage_class = werkzeug.datastructures.ImmutableOrderedMultiDict

_logger.warn('form data: %s' % request.httprequest.form)


This outputs the post data, but it's still in the form of an ImmutableMultiDict, not the ordered one.

It seems like the stream is empty. The werkzeug documentation suggests that this can be because the form data has already been parsed (which I suppose it has in Odoo).

Robin Chatfield
on 10/22/15, 2:17 AM
0

Axel Mendoza

--Axel Mendoza--
10205
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/20/15, 4:56 PM

You could access to the POST data from the request stream like:

post_data = simplejson.load(request.httprequest.stream)

In this case I parsed into a dict using simplejson, you could read the stream using what best fit your needs since it's a file-like object. Read more at:

http://werkzeug.pocoo.org/docs/0.10/request_data/

I done that in OpenERP v7, but that not change a lot, try to do a request.httprequest.stream.seek(0) if it's already parsed, you should be able to parsed again, it's a file -like object. Otherwise debug at that line to inspect request.httprequest to see where it holds the post data according to werkzeug docs

Axel Mendoza
on 10/21/15, 5:06 AM

solved?

Axel Mendoza
on 12/23/15, 2:00 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 10/20/15, 1:42 PM
Seen: 1066 times
Last updated: 10/22/15, 2:18 AM