Skip to content

Allowed Field to specify their own metadata. #4022

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

Closed
wants to merge 2 commits into from

Conversation

charettes
Copy link
Contributor

Description

The first commit adds regression tests for the existing metadata generation through SimpleMetadata.

The second one adds a get_metadata() method to the Field class in order to allow fields to specify their own metadata. Backward compatibility is maintained and the SimpleMetadata's API is unchanged, it simply delegates to Field.get_metadata().

This is a change required in order to offer a backward compatible deprecation path for #4021.

@tomchristie
Copy link
Member

The footprint for this is defiantly too large in comparison to the small benefit it'd give us.

@charettes
Copy link
Contributor Author

Do you think it might be worth merging the regression tests at least?

@xordoquy
Copy link
Collaborator

I find the idea -the original proposal- pretty interesting.
@tomchristie what about keeping things as they currently are and add a call to the field's metadata if it exists ?

Something such as metadata.py:

def get_field_info(self, field):
    if hasattr(field, 'get_metadata'):
        return field.get_metadata()
    else:
        # keep the current code

Therefore we'll have a hook to customize the metadata easily on a per field basis while keeping the footprint reasonable.

@xordoquy
Copy link
Collaborator

@charettes will try to take some time to dig that topic - keeping the tests.

@tomchristie
Copy link
Member

@tomchristie what about keeping things as they currently are and add a call to the field's metadata if it exists?

I think I'd still consider that API-creep. In this area I'd prefer us to keep the API surface area low. If there's complexity, let's force that to be in the metadata class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy