Commit graph

191 commits

Author SHA1 Message Date
Ankush Menat
1e9ede40fa
fix: stale frappe.local (#20695)
* fix: stale `frappe.local`

Co-Authored-By: Aditya Hase <aditya@adityahase.com>

* fix: force re-init in request

To ensure that any one bad request can not completely cause recurring
loop of broken requests due to bad locals, we just force-init locals on
every request.

---------

Co-authored-by: Aditya Hase <aditya@adityahase.com>
2023-04-14 14:19:01 +05:30
Gavin D'souza
9e87596cf1 fix: Run after_hooks only if site is initialized 2023-03-01 16:52:58 +05:30
Gavin D'souza
5d0bd512e1 fix(after_hook): Don't pass exception object to hook
* it can fetch most relevant details via response object
* Exceptions not supported by Frappe's WSGI (unsupported HTTP methods) may not be accessible to the after_request hooks - but the lack of active response may be an indicator / and peeking in the request
2023-02-17 11:24:01 +05:30
Gavin D'souza
fe26c542b7 refactor: Move before/after tasks as hooks
Moved before/after tasks in Requests as hooks for:
- monitor
- rate_limiter
- recorder

Moved before/after tasks in Jobs as hooks for:
- monitor
- releasing document locks
2023-02-15 15:30:02 +05:30
Gavin D'souza
6d70b5e934 fix(app): Move after_request hook inside finally block
Also, rename after_request fn to sync_database to better match functionality
2023-02-15 14:52:08 +05:30
Gavin D'souza
825f1d32f1 Merge branch 'develop' into request-job-hooks 2023-02-15 12:57:14 +05:30
Gavin D'souza
18eabf5153 fix(dx): Don't reload web workers if tests are changed in dev server 2023-02-10 14:39:39 +05:30
Gavin D'souza
d6a41cd272 feat: Before/After Request Hooks 2023-02-09 15:49:47 +05:30
Ankush Menat
4f162da728 fix: rollback if not commiting 2022-11-28 11:43:41 +05:30
Ankush Menat
4cc367f6c1 fix: apply rollback to all HTTP methods that can write 2022-11-28 11:34:46 +05:30
Ankush Menat
7504c1bc73 refactor: simpler commit after_request 2022-11-28 11:31:24 +05:30
Ankush Menat
1f6f31fc97 refactor: int > cint 2022-11-17 11:35:24 +05:30
Athul Cyriac Ajay
190e01a5f3 fix: Force integer type in request.max_content_length 2022-11-17 11:35:24 +05:30
Ankush Menat
9fc330ea6c
Revert "fix: remove middleware to clear frappe.local (#18874)" (#18886)
This reverts commit 2971abe517.
2022-11-15 18:45:51 +05:30
Sagar Vora
2971abe517
fix: remove middleware to clear frappe.local (#18874) 2022-11-15 11:07:18 +05:30
Ankush Menat
db1ed206f3 fix: only release db if it exists
ref https://github.com/frappe/frappe/pull/18772

[skip ci]
2022-11-06 18:54:18 +05:30
Sagar Vora
cd1bbccdc3
fix: dont release frappe.local twice (#18772) 2022-11-05 21:35:37 +05:30
Sagar Vora
f20fa69282
fix!: remove relaxations for Cordova (#18728) 2022-11-04 17:24:26 +05:30
Sagar Vora
709c9305ae
chore: remove unused RequestContext class (#18152) 2022-09-15 23:22:14 +05:30
Ankush Menat
d19790e03d fix: error handling without user set 2022-09-10 12:45:25 +05:30
Ankush Menat
98b57f6a1a fix: ensure deferred insert are flushed during update 2022-09-09 17:34:46 +05:30
Ankush Menat
5beccd8802 feat: allow reads during maintenance_mode
To reduce downtime reading from main db server during maintenance_mode
can be allowed. This lets users browse desk, static sites or any other
pages while ensuring that no writes happen to DB.

refactor: use read replica if available
2022-09-08 18:22:03 +05:30
Ankush Menat
022df94711
fix: respect Accept headers during maintenance mode #18057 2022-09-08 14:35:55 +05:30
Sagar Vora
48196915f6 fix: set Vary header to tell browser that response differs based on origin 2022-09-05 15:42:08 +05:30
Sagar Vora
51a39bd693 fix: only set allowed headers if required 2022-09-05 02:10:58 +05:30
Sagar Vora
23e8924a05 refactor: improved CORS support and caching 2022-09-04 20:20:08 +00:00
Ankush Menat
f5b8e5f015
perf: short-circuit guest connection and basic perf tests (#17988)
* perf: reorder condition to avoid redis call

* test: basic perf tests
2022-08-30 16:30:25 +05:30
Sagar Vora
eea2616aac style: use middleware decorator to keep function definition intact 2022-07-19 22:28:14 +05:30
Ankush Menat
e9a9496ebc fix: duplicate tracebacks in console 2022-07-04 11:25:47 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
56d97da32e fix: commit after processing request of "unsafe" http method
ref: https://developer.mozilla.org/en-US/docs/Glossary/safe
2022-06-08 12:03:38 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Sagar Vora
951ad3f844 chore(deps): bump werkzeug to latest version 2022-02-08 20:02:49 +05:30
Faris Ansari
b632cc558b fix: remove unnecessary array transformation in request args
`key: ['value', 'value2']` is turned into `key: 'value'` for no reason
2022-01-28 18:47:57 +05:30
Suraj Shetty
fba15b3874 fix: Combine request args and form data
- To accept argument via both way in a single request
2021-12-14 13:55:24 +05:30
Mitul David
648d24eca5 refactor: Limit file size of uploads by setting max_content_length 2021-11-17 16:26:00 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Suraj Shetty
2d8c6c1710 Merge branch 'develop' of https://github.com/frappe/frappe into refactor-website 2021-06-03 11:43:28 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Suraj Shetty
9a3d280484 Merge branch 'develop' of https://github.com/frappe/frappe into refactor-website 2021-05-13 14:23:20 +05:30
Suraj Shetty
b39b5effbf Merge branch 'develop' of https://github.com/frappe/frappe into refactor-website 2021-05-11 10:38:04 +05:30
Gavin D'souza
b1d2e24892 refactor(minor): Move logging code in seperate function 2021-05-06 19:18:23 +05:30
Leela vadlamudi
3875004d7e
Merge pull request #13057 from leela/email-refactoring
refactor: Email Module - 1
2021-05-05 11:45:04 +05:30
Sagar Vora
e288b781bf fix: add docstring 2021-05-03 18:00:37 +05:30
Sagar Vora
b214a993da fix: disable reloading files in __pycache__ directory 2021-05-03 17:54:13 +05:30
leela
a8f74d9471 refactor: Move finding email accounts code to EmailAccount doctype 2021-05-03 06:22:35 +05:30
Gavin D'souza
fcf63622bc fix: Respond to /api requests as JSON by default
If header 'Accept: application/json' isn't set, the failure
responses to /api endpoints is HTML. Success responses are of type JSON.
2021-04-29 11:27:15 +05:30
Suraj Shetty
87fa672250 style: Resolve code correctness warning 2021-04-28 15:03:14 +05:30
Suraj Shetty
e18a43e11d fix: Replace render() with get_response 2021-04-28 12:51:36 +05:30
Suraj Shetty
f50cb61888 Merge branch 'develop' of https://github.com/frappe/frappe into refactor-website 2021-04-26 12:52:23 +05:30