Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDEA] new json controller type #31516

Open
hmrodrigues opened this Issue Feb 28, 2019 · 9 comments

Comments

Projects
None yet
3 participants
@hmrodrigues
Copy link
Contributor

hmrodrigues commented Feb 28, 2019

Hello,

I've an idea for a new json controller type. This new type works the same way as the current one, but it doesn't inject the Odoo jsonrpc data.

Why do this you may ask, well if we want create a JSON API controller, the json controller will inject the jsonrpc data and to remove it we would need to patch (or monkey patch) Odoo.

What do you think about this? If you think that is a good idea, I can create a PR with the changes.

Best Regards,
Hugo Rodrigues

@pedrobaeza pedrobaeza added the Wishlist label Mar 1, 2019

@pedrobaeza

This comment has been minimized.

Copy link
Contributor

pedrobaeza commented Mar 1, 2019

What is the aim of this?

@hmrodrigues

This comment has been minimized.

Copy link
Contributor Author

hmrodrigues commented Mar 1, 2019

What is the aim of this?

For example, if you want a JSON endpoint to be used by a external program. Sometimes you can't force the external program to not pass the Content-Type header, so using a http controller doesn't work since Odoo forces a json controller when the header is set.

I know that there's a OCA module to create REST endpoints, but it would be nice to have the same controller logic with these raw json controllers

@pedrobaeza

This comment has been minimized.

Copy link
Contributor

pedrobaeza commented Mar 2, 2019

I personally don't see this useful. If you need it for a very special case, then you can add a module doing it, but not something for the core.

@Yenthe666

This comment has been minimized.

Copy link
Contributor

Yenthe666 commented Mar 3, 2019

To me it seems rather specific & custom development too honestly. @JKE-be can I ask you to make the decision for this idea please?

@hmrodrigues

This comment has been minimized.

Copy link
Contributor Author

hmrodrigues commented Mar 15, 2019

To me it seems rather specific & custom development too honestly. @JKE-be can I ask you to make the decision for this idea please?

Yes, this idea came from a custom development of two (independent) modules. Since I needed the same feature for two different things, I thought maybe other people also had the same requirement, so I posted the idea to check if people actually need the feature or not.

@pedrobaeza

This comment has been minimized.

Copy link
Contributor

pedrobaeza commented Mar 15, 2019

Isn't better to add a community module with that feature?

@hmrodrigues

This comment has been minimized.

Copy link
Contributor Author

hmrodrigues commented Mar 15, 2019

Isn't better to add a community module with that feature?

The problem is the controller type validation on http.py. To bypass that the module would need to monkey patch Odoo and reimplement the method. That way any fix/improvement in Odoo will be ignored

Same thing on the response builder. A monkey patch is needed to chance the response in case of a raw json controller

@pedrobaeza

This comment has been minimized.

Copy link
Contributor

pedrobaeza commented Mar 15, 2019

You have post_load and register_patch for these things AFAIK.

@hmrodrigues

This comment has been minimized.

Copy link
Contributor Author

hmrodrigues commented Mar 16, 2019

You have post_load and register_patch for these things AFAIK.

Hmm, I didn't know about those, but that doesn't avoid the need for the monkey patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.