Skip to content

Commit

Permalink
[IMP] fastapi: Makes the save_session configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Oct 3, 2024
1 parent d6fbe47 commit 6607300
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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

0 comments on commit 6607300

Please sign in to comment.