-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Allow db.Key
in the index
-method
#1445
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
base: develop
Are you sure you want to change the base?
feat: Allow db.Key
in the index
-method
#1445
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ArneGudermann, this is a breaking change, as the index-function now behaves differently than before. Anyway, as the SEO-stuff is being reworked, we can do it so. You should handle the commented stuff. I would like to discuss this in a viur-meeting.
src/viur/core/prototypes/list.py
Outdated
skel = self.viewSkel( | ||
allow_client_defined=utils.string.is_prefix(self.render.kind, "json"), | ||
_excludeFromAccessLog=True, | ||
) | ||
if isinstance(key, db.Key): | ||
assert key.kind == self.kindName | ||
skel.read(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will render an empty skeleton when the key is not found.
src/viur/core/prototypes/list.py
Outdated
skel = self.viewSkel( | ||
allow_client_defined=utils.string.is_prefix(self.render.kind, "json"), | ||
_excludeFromAccessLog=True, | ||
) | ||
if isinstance(key, db.Key): | ||
assert key.kind == self.kindName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will raise an error 500. I would like to use this as part of the previous condition.
db.Key
in the index
methodedb.Key
in the index
-method
With this now you can call the index Methode direct with a db.Key like:
/foo/agNmb29yCQsSA2Jhchh7DA
instead of
/foo/view/agNmb29yCQsSA2Jhchh7DA
Second if you have a Method like:
def index(self, key: db.Key | str | None = None)
the
key
is now parsed to adb.Key
if this is possible.