-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Skeleton.patch()
for transactional read/write
#1267
Merged
phorward
merged 27 commits into
viur-framework:develop
from
phorward:feat-Skeleton.update
Oct 15, 2024
Merged
feat: Skeleton.patch()
for transactional read/write
#1267
phorward
merged 27 commits into
viur-framework:develop
from
phorward:feat-Skeleton.update
Oct 15, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It either now returns the skeleton or None on error. The truthy test works the same way as before.
Will use `skel["key"]` instead.
The key parameter allows to provide a different key for the given operation. This might safe one more line of assignment code required before. Also refactors Skeleton.delete() with its double db.Get()
This is a "hackish", but working way to stay backward compatible with legacy code and still integrate existing fromDB/toDB-functionality into the new read/write-API.
Drafting new `Skeleton.update()` function based on `viur.toolkit.db.set_status()`. This function replaces the existing Skeleton.update() which should provide a dict-like behavior. For this case, the `|`- and `|=`-operators should be used. Because Skelton/SkeletonInstance is not a dict, it should provide correct CRUD functinality. This pull request is part of viur-framework#630 and a follow-up on viur-framework#1264, which should be merged first.
phorward
added
feature
New feature or request
Priority: High
After critical issues are fixed, these should be dealt with before any further issues.
viur-meeting
Issues to discuss in the next ViUR meeting
breaking-changes
This PR causes breaking changes
labels
Sep 24, 2024
phorward
changed the title
Feat skeleton.update
feat: Sep 24, 2024
Skeleton.update()
transactional read/write
... and reset previous implementration of SkeletonInstance.update(). This pull request makes the pull request fully backward-compatible again.
phorward
changed the title
feat:
feat: Oct 2, 2024
Skeleton.update()
transactional read/writeSkeleton.edit()
for transactional read/write
sveneberth
requested changes
Oct 8, 2024
Co-authored-by: Sven Eberth <[email protected]>
sveneberth
added a commit
to sveneberth/viur-core
that referenced
this pull request
Oct 9, 2024
phorward
pushed a commit
that referenced
this pull request
Oct 9, 2024
sveneberth
requested changes
Oct 9, 2024
phorward
pushed a commit
that referenced
this pull request
Oct 10, 2024
The language value needs to be a `list` as default value, not `None`. A simple add failed already on unserialize: ```py skel = ExampleSkel() skel.write() ``` ```py [2024-10-10 02:06:18,911] viur/core/skeleton.py:1208 [ERROR] Failed to serialize Test_Bone_select_multi_lang <viur.core.bones.select.SelectBone object at 0x7fd69253ee40> {'de': None, 'en': None} [2024-10-10 02:06:18,947] viur/core/request.py:331 [ERROR] ViUR has caught an unhandled exception! [2024-10-10 02:06:18,947] viur/core/request.py:332 [ERROR] 'NoneType' object is not iterable Traceback (most recent call last): File "/.../deploy/viur/core/request.py", line 306, in _process self._route(path) File "/.../deploy/viur/core/request.py", line 565, in _route res = caller(*self.args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../deploy/viur/core/module.py", line 301, in __call__ return self._func(self._instance, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../deploy/modules/example.py", line 208, in test_add1 assert skel.write() ^^^^^^^^^^^^ File "/.../deploy/viur/core/skeleton.py", line 1400, in write key, skel, change_list, is_add = db.RunInTransaction(__txn_write, skel) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "src/viur/datastore/transport.pyx", line 819, in viur.datastore.transport.RunInTransaction File "src/viur/datastore/transport.pyx", line 816, in viur.datastore.transport.RunInTransaction File "/.../deploy/viur/core/skeleton.py", line 1206, in __txn_write bone.serialize(skel, bone_name, True) File "/.../deploy/viur/core/bones/base.py", line 776, in serialize for singleValue in newVal[language]: ~~~~~~^^^^^^^^^^ TypeError: 'NoneType' object is not iterable ``` Discovered during testing #1267
phorward
commented
Oct 14, 2024
Co-authored-by: Sven Eberth <[email protected]>
phorward
commented
Oct 14, 2024
phorward
changed the title
feat:
feat: Oct 14, 2024
Skeleton.edit()
for transactional read/writeSkeleton.patch()
for transactional read/write
ArneGudermann
requested changes
Oct 15, 2024
Co-authored-by: agudermann <[email protected]>
sveneberth
approved these changes
Oct 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature
New feature or request
Priority: High
After critical issues are fixed, these should be dealt with before any further issues.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Provides a
Skeleton.patch()
function based onviur.toolkit.db.set_status()
.This improves the Skeleton API to a better and more integrated CRUD-API (Create-Read-Update-Delete). It also introduces a ReadFromClientException that can be raised internally for client parsing error reporting.
This pull request is part of #630 and a follow-up on #1264, which
should bewas merged first.This is also an alternative replacement on #991.