-
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
Refactor Skeleton
interface
#630
Labels
bootcamp
Mausbrand Bootcamp Topic
refactoring
Pull requests that refactor code but do not change its behavior.
Comments
phorward
added
the
refactoring
Pull requests that refactor code but do not change its behavior.
label
Jan 24, 2023
This was referenced Mar 26, 2024
phorward
added a commit
to phorward/viur-core
that referenced
this issue
Sep 24, 2024
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 a commit
that referenced
this issue
Oct 1, 2024
- [x] Rename `Skeleton.toDB()` into `Skeleton.write()` - [x] Rename `Skeleton.fromDB()` into `Skeleton.read()` - [x] Rename any `skelValues` variable into `skel` - [x] Clean-up `Skeleton.delete()` - [x] Improve `Skeleton.read()`, `Skeleton.write()` and `Skeleton.delete()` to accept key-parameter - [x] Deprecation handling - [x] Added support for legacy fromDB/toDB definitions in project-specific Skeletons This pull request is a first, backward-compatible milestone on #630.
phorward
added a commit
that referenced
this issue
Oct 15, 2024
Provides a `Skeleton.patch()` function based on `viur.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 be~ was merged first. This is also an alternative replacement on #991. --------- Co-authored-by: agudermann <[email protected]> Co-authored-by: Sven Eberth <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bootcamp
Mausbrand Bootcamp Topic
refactoring
Pull requests that refactor code but do not change its behavior.
Ok, this will become a huger and recently updated issue relating to several things in VIURs current
Skeleton
interface. The reason for this issue is, that the current interface is uneven, messy and misleading in several ways.CRUD-functions
It's called CRUD: Create, Read, Update, Delete.
Current state
For Skeletons, this is:
toDB()
withskel["key"]
set toNone
fromDB()
toDB()
with askel["key"]
setdelete()
Okay - why is it fromDB(), toDB() but not... deleteDB()? This is uneven and messy.
Proposed state
write()
withskel["key"]
set toNone
read()
write()
with askel["key"]
setdelete()
Hooks
In many situations, it is necessary to do some pre- or post-processing of data before it is written, read or deleted.
Current state
toDB()
:preProcessSerializedData()
- Do something on the already serializeddb.Entity
without using the bones anymore (mostly useless!)preProcessBlobLocks()
- Use is only relevant to blobs?postSavedHandler()
oh nice, I can do something after the skeleton has been saved. Why isn't it calledpostToDBHandler()
?toDB()
, do your preparation and afterwards make a super call. This is the current way to go.fromDB()
: No chance to do something here, except overridingfromDB()
. Wow.delete()
:postDeletedHandler()
is a hook on aSkeletonInstance
which has been previously deleted.Proposed state
It should be equivalent to module's hooks functionalities and naming:
write()
:on_write()
- do something before saving with the skeletonserialize()
- do something before saving with thedb.Entity
default/super should be a
Skeleton.serialize()
, which doesn't exist as well!read()
:unserialize()
- do something after reading with thedb.Entity
Skeleton.unserialize()
doesn't exist anymore, as bones are unserialized on-demand. Anyway, the hook should exist for override.on_read()
- do something after reading with the skeletondelete()
:on_delete()
- do something after deleting the dataset. This is mostly equal topostDeletedHandler()
, except the signature.Shortcut functions
The following shortcut functions should be made available for fast skeleton CRD (create-read-delete).
Skeleton.get()
It's should be possible to just load a skeleton by a given key immediately.
Something like
This could be achieved by a staticmethod
db.Key
or an encoded key, or a name or an int. Latter one will only be used whenkind
is set. On kind mismatch, an exception is raised.db.Key
or the encoded-str, otherwise the kind is mandatory.The function shall return None in case the given key wasn't found.
Skeleton.new()
tbd
Skeleton.del()
tbd
The text was updated successfully, but these errors were encountered: