Skip to content

Resource Meta classes don't support inheritance #1

Open

Description

@dharvey-consbio

It's because the Meta classes are processed at class-definition time, and removed afterwards. By the time an inheriting class definition is processed, the Meta class has been removed from the parent.

For example, the following results in this error:

AttributeError: type object 'BaseResource' has no attribute 'Meta'

from restle.resources import Resource

class BaseResource(Resource):
    class Meta:
        case_sensitive_fields = False
        match_fuzzy_keys = True

class ArcGISResource(BaseResource):
    class Meta(BaseResource.Meta):
        get_parameters = {"f": "json"}

Activity

  1. dharvey-consbio commented on Jul 8, 2021

    @dharvey-consbio
    ContributorAuthor

    Another closely related improvement would be to make ResourceOptions supported by the Meta class overridable in inheriting classes:

    from restle.resources import Resource
    
    class BaseResource(Resource):
        class Meta:
            case_sensitive_fields = False
            match_fuzzy_keys = True
            custom_meta_prop = "custom_val"

    Currently the way restle.resource.ResourceBase handles restle.options.ResourceOptions prevents this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions