Commit graph

123 commits

Author SHA1 Message Date
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
David Arnold
a4014ab1c4
fix(json-serialization): prioritize explicit __json__ before iterable (#28597) 2024-11-27 13:11:53 +00:00
David Arnold
2abba7b51b
fix: don't force values into the string type (#28185) 2024-10-19 19:00:25 +00:00
David Arnold
75b58802ad
fix(docref): json serialization (#28182) 2024-10-19 14:11:51 +00:00
David
7d5b63a267
fix: improve serializer 2024-09-12 21:06:10 +02:00
Akhil Narang
3f524be635
fix(json_handler): handle uuid.UUID
Resolves #25242

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-03-13 17:27:30 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Ankush Menat
718b5b8bee
fix: Private images in PDFs from background jobs (#24980)
* refactor: Private images rendering in PDFs

Private images currently render fine if PDF is generated during a
request as we pass the cookiejar to WKHTML.

Background jobs however fail completeley because they can't retrieve
private images without cookiejar.

This PR converts all image types to base64 encoded sources in HTML
itself, so wkhtmltopdf doesn't have to a fire a request.

* test: private images in pdf
2024-02-21 10:38:02 +00:00
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
dedadbb0d9 perf: optional faster perm check for files 2024-01-31 10:49:18 +05:30
Ankush Menat
d838da51dd fix: short circuit private files perm check
For guest users there's no point in checking permissions, they'll eventually fail... instead just fail immediately.
2024-01-30 20:31:28 +05:30
Ankush Menat
ee6743c26b
fix: avoid mutating list while iterating over it (#24438) 2024-01-18 05:44:30 +00:00
Akhil Narang
5c90e151ab
Merge pull request #24246 from akhilnarang/fix-file-download
fix(response): fixup non-ASCII character filenames
2024-01-11 16:15:23 +05:30
Ankush Menat
0a38fb0813 fix: skip exc without exc id 2024-01-11 13:09:43 +05:30
Akhil Narang
e622198bab
fix(response): fixup non-ASCII character filenames
This was previously only handled for binary files

Werkzeug crashes otherwise:

17:54:40 web.1         | Traceback (most recent call last):
17:54:40 web.1         |   File "/home/akhil/frappe/frappe-bench/env/lib/python3.11/site-packages/werkzeug/serving.py", line 362, in run_wsgi
17:54:40 web.1         |     execute(self.server.app)
17:54:40 web.1         |   File "/home/akhil/frappe/frappe-bench/env/lib/python3.11/site-packages/werkzeug/serving.py", line 326, in execute
17:54:40 web.1         |     write(data)
17:54:40 web.1         |   File "/home/akhil/frappe/frappe-bench/env/lib/python3.11/site-packages/werkzeug/serving.py", line 266, in write
17:54:40 web.1         |     self.send_header(key, value)
17:54:40 web.1         |   File "/usr/lib/python3.11/http/server.py", line 526, in send_header
17:54:40 web.1         |     ("%s: %s\r\n" % (keyword, value)).encode('latin-1', 'strict'))
17:54:40 web.1         | UnicodeEncodeError: 'latin-1' codec can't encode characters in position 43-52: ordinal not in range(256)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-10 18:44:51 +05:30
Revant Nandgaonkar
37803a00d4
fix: strip exc from json response if traceback not allowed (#23989)
* fix: strip exc from json response if traceback not allowed

* fix: use pop instead of del to avoid key error

* fix: Avoid showing exc when traceback is disabled

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-12-28 10:45:06 +05:30
Shariq Ansari
4c9dea8d62 fix: use encoded filename for arabic (latin) language while exporting 2023-12-07 12:46:27 +05:30
Akhil Narang
eb45da3913
feat: Allow usage of print() within safe_exec() (#23084)
* feat(safe_exec): allow usage of `print()`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* refactor(system_console): update description to mention `print()` instead of `log()`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* feat: unconditionally add debug logs to response if present

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* chore(safe_exec): add in a test for running `print()` within safe_exec

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* fix(safe_exec): ignore warning

RestrictedPython warns us if we call `print()` don't use their `printed` variable

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* feat: store debug logs from scheduled jobs

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* fix: avoid ignoring warnings, disabled in prod anyway

* chore: remove unnecessary logging

This can be moved to level 2 when required

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-11-20 12:45:41 +05:30
Ankush Menat
e2714c3e1c feat: v2 error and debug log structure 2023-10-16 18:13:50 +05:30
Ankush Menat
018ed845bd refactor: defer unnecessary json-dumping of messages
Also avoid accessing locals where interface is present like for popping last message.
2023-10-16 18:13:50 +05:30
Ankush Menat
411819ef81 feat: v2 for message response strucutre 2023-10-16 18:13:50 +05:30
Ankush Menat
3cc2ca8fc7 test: old API messages 2023-10-16 18:13:50 +05:30
Ankush Menat
909457de3d
fix: PDF and raw response (#22402) 2023-09-13 16:42:49 +00:00
Ankush Menat
0eb509aac3
refactor: Correct Content-Disposition headers (#22383) 2023-09-13 12:57:14 +05:30
ViralKansodiya
b0bb9a55d5
fix: error while export a doctype report in excel (#22376)
* fix: error while export a doctype report in excel

* Update frappe/utils/response.py

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2023-09-13 12:13:31 +05:30
barredterra
b553ed98d8 refactor: inline immediately returned variable
Inline a variable to a return in the case when the
variable being declared is immediately returned
2023-08-08 18:09:49 +02:00
Ankush Menat
6e94cd2eb9
fix: Guess most likely exception source (#21827) 2023-07-27 17:30:04 +05:30
Sagar Vora
5f0707c856 chore: remove unused variable 2023-07-23 15:10:37 +05:30
Ankush Menat
3f142c1dce fix: respect system setting for tracebacks
closes https://github.com/frappe/frappe/issues/19826
2023-07-16 19:18:16 +05:30
Ankush Menat
8485ac5d62 build(deps): bump many dependencies
test: change code to adapt to new werkzeug client

fix: avoid setting charset

utf8 is default and assumed now by werkzeug, setting this manually is
deprecated.

fix: use string instead of bytes for setting headers

DeprecationWarning: Passing bytes as a header value is deprecated and will not be supported in Werkzeug 3.0.
12:23:34 web.1         |   response.headers["X-Page-Name"] = path.encode("ascii", errors="xmlcharrefreplace")
2023-06-10 20:47:27 +05:30
Sagar Vora
9cf7f2b311 perf: get all file data at once when downloading private file 2023-04-27 16:12:02 +05:30
Gavin D'souza
ef82ef944e fix: build_response for re.Match 2022-12-27 14:17:09 +05:30
Ankush Menat
6d264b149a fix: serialize function objects to their repr 2022-09-12 11:49:25 +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
013c2543bd refactor: frappe.utils.response.download_private_file 2022-04-18 12:54:10 +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
Gavin D'souza
8037866dc1 fix: Handle parsing and formatting timedeltas
* Added utils parse_timedelta, format_timedelta
* Added to json_handler for de-serializing timedelta objects
2022-01-28 18:33:03 +05:30
Conor
40ba1ac9ba fix: Postgres Compatibility
* Handle inconsistencies in type handling in DatabaseQuery & Database
  APIs
* Update incompatible queries with frappe.qb notation
* Fixed use cases discovered by failing ERPNext CI tests

fix: db independent syntax for user_type

fix: handle postgres datetime values

feat: add ability to auto commit on db inserts

feat: add ability to escape underscore in postgres

fix: handle missing data in test runner bootstrapping

fix: db independent syntax for queries

fix: refactor to use qb

fix: update cache for language

fix: use pluck in email_queue

Co-authored-by: gavin <gavin18d@gmail.com>

fix: don't auto insert on tests for make_property_setter

fix: remove auto_commit in custom_field insertion

fix: remove auto_commit functionality

fix: review comments

fix: revert link validation

fix: style suggestion for readability

Co-authored-by: gavin <gavin18d@gmail.com>

fix: revert .lower() in link validation

fix: add rollback for setup_wizard

Revert "fix: add rollback for setup_wizard"

This reverts commit 83b3b0913db17718ccd5edae01858cff15603829.

Revert "feat: add ability to escape underscore in postgres"

This reverts commit 8ed9c2aa3306438e94bb813f60e65b416d0b947b.

fix: more concise representation of order fields

Co-authored-by: gavin <gavin18d@gmail.com>
2022-01-07 10:44:57 +05:30
Ankush Menat
ecca7f287e
chore: better message for system updates (#15154)
closes https://github.com/frappe/frappe/issues/10997

[skip ci]
2021-12-02 11:09:33 +05:30
Gavin D'souza
125233315f fix: errprint only if traceback? 2021-10-26 17:33:03 +05:30
Saqib Ansari
4f288db878 refactor: handle exception messages on client side 2021-10-19 20:00:35 +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
56ee6e449c refactor: Remove render method
- also, move clear cache to utils.py
2021-05-14 14:17:52 +05:30
Suraj Shetty
e18a43e11d fix: Replace render() with get_response 2021-04-28 12:51:36 +05:30
Aditya Hase
09b87f8a2d
perf: Remove frappe.website.render from import tree 2021-02-21 09:47:05 +05:30
Faris Ansari
6fa38a325d fix: Fallback value for allow_traceback when no db 2021-02-16 21:45:26 +05:30
Karthikeyan Singaravelan
0d4f116b3e fix: Import ABC from collections.abc for Python 3.9 compatibility. 2020-11-26 13:17:12 +00:00