rest-framework
rest-framework copied to clipboard
[IMP] Deprecate old API
At startup, output deprecation message for methods not explicitely declared with the new api decorator
To help adapt the code, the decorator to add to the method not declared with the new api decorator is printed into the log file.
2022-06-15 15:02:07,093 535175 WARNING odoo-14-test odoo.addons.base_rest.models.rest_service_registration: "Deprecated REST API implicit method "session_expired" in service "exception.service"
The support for implicit rest method will be removed in 16.0
You should consider to explicitly declare your method as a rest method by adding the following decorator
@restapi.method(
[('/session_expired', 'POST')],
input_param=restapi.CerberusValidator(schema='_validator_session_expired'),
output_param=restapi.CerberusValidator(schema='_validator_return_session_expired')
)
def session_expired(...):
ping @simahawk @sbidoul
@sbidoul @simahawk The deprecation message is logged as warning. This makes runboat build fails. Do I change the level to info?
That's not the reason for the build failure. I was connected to the template1 db to show something to Pierrick. Please retry.
@simahawk I'm not sure that logging the details at debug level is a good idea. Personally, I only activate the debug level for some specific addons in some specific cases when we encounter unexpected behavior in production. Moreover, developers will never think about activating the debug level to get the details that will help them to adapt their code. If you are annoyed by the warnings, it's easy to fix your code with the details into the log message to get rid of them.
@simahawk I'm not sure that logging the details at debug level is a good idea. Personally, I only activate the debug level for some specific addons in some specific cases when we encounter unexpected behavior in production. Moreover, developers will never think about activating the debug level to get the details that will help them to adapt their code. If you are annoyed by the warnings, it's easy to fix your code with the details into the log message to get rid of them.
I'm not saying you shouldn't see anything. I'm saying log the deprecation w/out the detail in INFO mode and mention that more details can be seen w/ DEBUG mode. Eg:
""" Deprecated REST API implicit method "session_expired" in service "exception.service". The support for implicit rest method will be removed in 16.0. For full details please enable DEBUG level """ IMO logging the same thing hundreds time won't help devs more.
@simahawk And once you enable the debug log level the information you're looking for is lost in a tons of useless log entries....
done
2022-06-16 08:56:30,589 574334 WARNING odoo-14-test odoo.addons.base_rest.models.rest_service_registration: Deprecated REST API implicit method "get" in service "partner_image.service". The support for implicit rest method will be removed in 16.0. For full details on how to adapt your code, please enable DEBUG level
2022-06-16 08:56:30,590 574334 DEBUG odoo-14-test odoo.addons.base_rest.models.rest_service_registration: Add the following decorator to fix this issue:
@restapi.method(
[(['/<int:id>/get', '/<int:id>'], 'GET')],
input_param=restapi.CerberusValidator(schema='_validator_get')
)
def get(...):
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.
@simahawk Can you update your review PLZ? Thank you
/ocabot merge patch
This PR looks fantastic, let's merge it! Prepared branch 14.0-ocabot-merge-pr-270-by-lmignon-bump-patch, awaiting test results.
Congratulations, your PR was merged at 90e695559e61186501645e63d09c620abce6f803. Thanks a lot for contributing to OCA. ❤️