- 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
- 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
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
* refactor: rename poorly named functions
* refactor: getting translation from apps
- use generator
- use sane name for cache key
- avoid manual handling of frappe.local state just use cache() interface
This is not required anymore since we store full doc anyway. Also since
they share same cache key calling get_cached_value and get_cached_doc
can end up doing duplicate / double work.
This was added in last DB refactor but it does nothing, it was probably
supposed to do something with the connection pool but to best of my
knowledge "read only" is not a property of a connection.
It can be achieved with users who only have read access, that however
isn't implemented anywhere.
Removing this for now.
Deferred:
- Error log
- view log
- web page view
Disable:
- "_seen" tracking used on list view to highlight unseen docs.
- "seen" on error log.
- dashboard chart last ts caching
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
We parse entire response to find preload headers, instead just use
include_style and include_script to include assets directly into preload
headers. This shaves off ~13% overhead in response.