Skip to content

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

ArneGudermann
Copy link
Contributor

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 a db.Key if this is possible.

@ArneGudermann ArneGudermann added the feature New feature or request label Mar 25, 2025
@ArneGudermann ArneGudermann added this to the ViUR-core v3.8 milestone Mar 25, 2025
Copy link
Member

@phorward phorward left a 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.

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)
Copy link
Member

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.

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
Copy link
Member

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.

@phorward phorward changed the title feat: Allow db.Key in the index methode feat: Allow db.Key in the index-method Apr 3, 2025
@ArneGudermann ArneGudermann requested a review from phorward May 23, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants