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

[IMP] fastapi: Makes the save_session configurable #7

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion fastapi/models/fastapi_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ class FastapiEndpoint(models.Model):
readonly=False,
domain="[('user_ids', 'in', user_id)]",
)
save_http_session = fields.Boolean(
string="Save HTTP Session",
help="Whether session should be saved into the session store. This is "
"required if for example you use the Odoo's authentication mechanism. "
"Oherwise chance are high that you don't need it and could turn off "
"this behaviour. Additionaly turning off this option will prevent useless "
"IO operation when storing and reading the session on the disk and prevent "
"unexpecteed disk space consumption.",
default=True,
)

@api.depends("root_path")
def _compute_root_path(self):
Expand Down Expand Up @@ -178,7 +188,7 @@ def _get_routing_info(self):
f"{self.root_path}/",
f"{self.root_path}/<path:application_path>",
],
"save_session": False,
"save_session": self.save_http_session,
# csrf ?????
}

Expand Down
1 change: 1 addition & 0 deletions fastapi/readme/newsfragments/442.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* A new parameter is now available on the endpoint model to let you disable the creation and the store of session files used by Odoo for calls to your application endpoint. This is usefull to prevent disk space consumption and IO operations if your application doesn't need to use this sessions files which are mainly used by Odoo by to store the session info of logged in users.
2 changes: 1 addition & 1 deletion fastapi/views/fastapi_endpoint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<field name="user_id" />
<field name="company_id" />
<field name="description" />
</group>
<field name="save_http_session" /> </group>
<group name="resoures">
<field name="docs_url" widget="url" />
<field name="redoc_url" widget="url" />
Expand Down
Loading