Skip to content

Improve API for Accessing Underlying Resources Contained in ResourceFields #1

@kylieCat

Description

@kylieCat

Currently to update the value on an underlying Resource you need:

# using a blog post that has an author
post.author_resource_field.value.author_resource.some_field.value = "..."

This will be very unwieldy with deeply nested resources . The desired syntax would be:

post.author.update("some_field", "...")

Perhaps for deeply nested resources a dot syntax could be used:

# using a blog post that has an author that has a profile
# current
post.author_resource_field.value.author_resource.profile_resource_field.value.email_field.value = "..."

# proposed
post.author.update("profile.email", "new.email@foo.com")

The same goes for labels. To fetch data form JSON returned from a server the following can be used:

data[post.title.label]

However if the key in the response that is needed is a label on a deeply nested field:

data[post.author.label][post.author.value.email.value]

Proposed:

data[post.get_label("author")][post.get_label("author.email")]

It should also be possible to iterate labels:

foo = {label, data.get(label) for label in post.labels() if bar(label)}

or

foo = {label, data.get(label) for label in post.labels("author") if bar(label)}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions