mikeywaites / kim

Kim: A JSON Serialization and Marshaling framework
http://kim.readthedocs.org/en/latest/
Other
317 stars 17 forks source link

Allow nested serializers to be specified as strings to avoid circular import issues #35

Closed mikeywaites closed 9 years ago

mikeywaites commented 9 years ago

@krak3n reported this issue

Take a serializer definition such as

class SchedulableEntitySerializer(SQASerializer):
    id = Field(t.String, read_only=True)

    name = Field(t.String)
    description = Field(t.String, required=False)

    company_relationship = Field(
        NestedForeignKeyStr(CompanyRelationshipSerializer)
    )

Allowing Nested* to accept a python import path as a string would help to solve some circular dependancy issues.

class SchedulableEntitySerializer(SQASerializer):
    id = Field(t.String, read_only=True)

    name = Field(t.String)
    description = Field(t.String, required=False)

    company_relationship = Field(
        NestedForeignKeyStr('path.to.CompanyRelationshipSerializer',)
    )