Skip to content

PrimaryKeyCreator, no parameter are passed to the create_pk method #133

Open
@LeMoussel

Description

@LeMoussel

I want to make an MurmurHash class to create a primary key for a new model instance.
I did this class that adheres to the PrimaryKeyCreator protocol:

# https://github.com/hajimes/mmh3
import mmh3

class Mmh3PrimaryKey:
    """
    A client-side generated primary key that follows the MurmurHash (MurmurHash3) spec.
    https://en.wikipedia.org/wiki/MurmurHash
    """

    @staticmethod
    def create_pk(self, *args, **kwargs) -> str:
        return str('some argument in args / kwargs')

and set Meta primary_key_creator_cls like this:

class ErrorServer(HashModel):
    local_hostname: str
    class Meta:
        primary_key_creator_cls = Mmh3PrimaryKey

But when I instantiate ErrorServerclass, no parameter (len of *args, **kwargs == 0) are passed to create_pk

es = ErrorServer(local_hostname='my_hostname', param2='Test')

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions