Ankush Menat
4193a251a5
fix: Invalidate cache on rollback too
...
Steps:
- Document modified
- Document refetched from cache
- Transaction rolled back
- Cache now contains unmodified changes.
2023-06-03 22:53:10 +05:30
Ankush Menat
98b4693dcf
perf: finer cache eviction on db.set_value
...
Instead of nuking everything, just clear matching prefix
2023-06-03 22:53:10 +05:30
Ankush Menat
356a2587e2
refactor: Use plain keys instead of hashes for caching
...
- Hashes are supposed to be used for representing complex object, not
multiple documents of same DocType.
- Redis's auto cache clearing wont clear individual key from hashes even if they
are rarely used.
- Keys can have expiry.
2023-06-03 22:53:10 +05:30
Ankush Menat
106ff1f1ee
fix: move cache clearing away from document
...
Passing lambda function from inside document object would keep reference
to document alive. This means increasing memeory usage in bulk
processing.
Refer https://github.com/frappe/frappe/pull/17061 for example
This also extends it to db.set_value
2023-06-03 22:53:10 +05:30
Ankush Menat
be1da0dd00
chore: remove duplicate cache clearing
2023-06-03 22:53:10 +05:30
Ankush Menat
54ae0c4a21
refactor: move flush_realtime_log to realtime.py
...
This doesn't have anything to do with databases
2023-06-03 18:44:19 +05:30
Ankush Menat
680cf73cba
fix: link_count
...
This didn't work correctly, if link_count is present in cache it would
just read and dump it back in.
This has practically never worked correctly.
2023-06-03 18:44:19 +05:30
Ankush Menat
b3d370a0b1
refactor!: remove rollback_observers
...
use `frappe.db.after_rollback.add` instead
2023-06-03 18:44:19 +05:30
Ankush Menat
7e9ef00bea
refactor!: Remove frappe.db.add_before_commit
...
Not used anywhere, use `frappe.db.before_commit.add()` instead.
2023-06-03 18:44:19 +05:30
Ankush Menat
4a81d9f8e3
feat!: populate fields from kwargs in frappe.new_doc ( #21190 )
...
This makes it similar to `get_doc` API BUT still signifies intent that
it's a "NEW" document.
Minor Breaking Change: positional arguments are now forcefully keyword
arguments. Only seems to be used internally from what I can tell.
https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/frappe/.*+/frappe.new_doc%5C%28.*%3F%2C.*%3F%5C%29/+lang:python+&patternType=regexp&case=yes&sm=0&groupBy=repo
2023-05-31 12:29:31 +05:30
Raphael Krupinski
b66d8e8a40
chore(DX): add type hints to Document, BaseDocument and get_doc ( #21060 )
...
* chore: add type hints to Document, BaseDocument and get_doc
* refactor: better type hints
get_doc has multiple ways to use it, added all known ways
---------
Co-authored-by: Raphael Krupinski <10319569-mattesilver@users.noreply.gitlab.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-05-29 11:01:51 +05:30
Suraj Shetty
a84da0139a
Merge pull request #20810 from gavindsouza/fix-20689
2023-05-04 18:32:16 +05:30
Sagar Vora
53c9869ce3
style: use set.isdisjoint when comparing roles (+ minor refactor)
2023-04-27 17:39:33 +05:30
Gavin D'souza
7d2f9be609
refactor: Simplify only_has_select_perm
2023-04-21 17:40:00 +05:30
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
Daizy Modi
3db1c1aea0
fix: allowed only POST and PUT methods in rename_doc ( #20504 )
2023-04-03 15:04:46 +05:30
Suraj Shetty
3eff93ea6e
refactor: Only send email_read_tracker_url instead of method
2023-02-28 14:16:46 +05:30
Suraj Shetty
b397ec3858
feat: Track count of views on newsletter emails
2023-02-23 13:45:53 +05:30
Ankush Menat
3f1deeba67
fix: can't sign out due to missing roles ( #19905 )
2023-02-02 22:53:24 +05:30
Ritwik Puri
fb9ae0823e
Merge pull request #19716 from resilient-tech/simpler-doc-cache
...
chore!: remove special local cache for documents (and related `cache_locally` parameter)
2023-01-25 22:21:12 +05:30
Gavin D'souza
d357af1533
refactor: Add a maxsplit limit to string splits
2023-01-24 19:22:51 +05:30
Sagar Vora
23c9d8a42d
chore: remove old cache reference
2023-01-21 17:46:41 +05:30
Sagar Vora
30941c49f5
chore!: remove special local cache for documents
2023-01-21 17:28:42 +05:30
Ankush Menat
0449f851c7
fix: correct exit code on missing app failure ( #19676 )
2023-01-20 13:51:00 +05:30
Richard Case
e80c8ac862
fix: improved installed app fail feedback ( #19668 )
2023-01-20 13:02:09 +05:30
Ankush Menat
fa55793a52
Merge pull request #19405 from netchampfaris/refactor-qb-engine
...
refactor: qb.engine
2023-01-18 21:17:17 +05:30
Ankush Menat
4bb5b10c7f
fix(DX): better error msg for non-whitelisted methods ( #19616 )
...
[skip ci]
2023-01-17 12:06:39 +05:30
Ankush Menat
5e2bbf834f
refactor: filter out apps not installed on bench
2023-01-16 13:54:40 +05:30
Sagar Vora
f5cbcec103
fix: defer local.all_apps loading
2023-01-16 13:54:27 +05:30
Sagar Vora
d8b7bc18d7
refactor!: deprecate sorting based on apps.txt in get_installed_apps
2023-01-16 13:54:27 +05:30
jiangying
0898ac2a0e
docs: fix docstring for get_list filters ( #19569 )
...
* chore: fix doc in frappe/__init__.py
should be filter as a list of dicts
* Update __init__.py
* doc: remove `filter as a list of dicts`
2023-01-11 17:16:19 +05:30
Faris Ansari
be654eaa60
Merge branch 'develop' into refactor-qb-engine
2023-01-09 15:23:20 +05:30
Alfredo Altamirano
d0f880e5c5
fix: Improve JSON export format readability ( #19429 )
...
* Improve JSON export format readability
* fix: Enable ensure_ascii flag on export_json
* style: fmt
[skip ci]
Co-authored-by: Alfredo Altamirano <Ahuahuachi@users.noreply.github.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-01-04 12:33:45 +05:30
Faris Ansari
726fcfdb79
refactor: qb.engine
...
- simplify
- qb.engine.get_query -> qb.get_query
- qb.engine.build_conditions -> qb.get_query
2022-12-25 23:19:11 +05:30
barredterra
ab95cffae9
fix: re-introduce html param for attach_print
...
Fix error introced by d64836c1c4
2022-12-19 14:26:15 +01:00
Gavin D'souza
d66eed129c
refactor: validate_argument_types
...
* Rename API for ease of public use
* Add validation condition parameter
* Move function to utils module instead of frappe namespace
2022-12-19 15:07:03 +05:30
Gavin D'souza
4fe260e09e
refactor: transform_parameter_types
...
- Switch to Pydantic which is under continuous development and can
support more types
- Equivalent Pydantic API will try to transform data if possible
- The previous point makes it such that we don't need to explicitly try
to parse each stringified int in app code since Pydantic can do this
- Drop typeguard since it did not handle 3.10+ native typing definitions
2022-12-15 13:47:05 +05:30
Gavin D'souza
d78b967f8d
test: Run type validation checks in test mode for whitelisted APIs
2022-12-15 13:47:05 +05:30
Gavin D'souza
3fd74afa47
feat(whitelisted): Runtime typing hints validation
...
- Run type validations if annotations exist for whitelisted functions
- Run validations only on function calls in presense of frappe.local.request
In action:
```bash
> curl -H 'Content-Type: application/json' 'http://photos:8000/api/method/frappe.handler.download_file ' -d '{"file_url": ["!=", "gavin.jpg"]}'
```
Note: This ignores stringified or ForwardRef types. If you want types to
be validated make sure they are not imported under `if TYPE_CHECKING`
blocks
2022-12-15 13:47:05 +05:30
Gavin D'souza
ccbc833c6c
feat: runtime check via pydantic
...
handle localns stringified types
2022-12-15 13:47:05 +05:30
barredterra
22ea39a442
fix: remove unused html parameter
...
from `attach_print`and `get_print`
2022-12-14 14:37:56 +01:00
Ankush Menat
170b7c9b0f
chore: correct devel version
2022-12-13 14:20:55 +05:30
Alfredo Altamirano
ffe3ba140e
fix: TypeError when using frappe.throw() or frappe.msgprint() with lists ( #19255 )
...
Co-authored-by: Alfredo Altamirano <Ahuahuachi@users.noreply.github.com>
[skip ci]
2022-12-13 11:59:58 +05:30
Raffael Meyer
bb5b0e5e64
refactor!: remove compare util from frappe package ( #19234 )
...
Use `from frappe.utils import compare` instead of `frappe.compare`.
2022-12-11 23:20:21 +05:30
Ankush Menat
49437f53b4
feat: operation level locking for CLI commands ( #19162 )
...
This prevents mistakenly issuing same commands twice which can be
dangerous.
added global lock(s):
- [x] bench build
added site level lock(s):
- [x] bench new-site sitename
- [x] bench --site sitename migrate
- [x] bench install-app appname
- [x] bench build
- [x] bench restore (the code is just meh, needs some cleanup)
closes https://github.com/frappe/frappe/issues/13215
2022-12-08 13:24:43 +05:30
Raffael Meyer
73f0256aa8
feat: add param letterhead to frappe.get_print ( #18989 )
...
* feat: add param letterhead to frappe.get_print
2022-11-24 13:15:24 +05:30
Ankush Menat
c658d8cb1b
fix: ignore unpicklable hooks ( #18902 )
...
If any custom app use import statement in hooks.py everything breaks.
Hooks.py while being python file is still only supposed to be used for
configuring.
This PR ignores unpicklable members of hooks.py
2022-11-17 11:50:18 +05:30
Ankush Menat
f34f7030a3
refactor: remove txt param from generate_hash use
2022-11-10 11:56:48 +05:30
Ankush Menat
fcaa16bb21
perf: faster generate_hash
2022-11-10 11:36:40 +05:30
Sagar Vora
764370f3c6
fix: set proper cache key for singles when name is passed as None ( #18667 )
...
[skip ci]
2022-10-29 17:34:52 +05:30