Skip to content

add enum support #14

@lamenezes

Description

@lamenezes

not sure how this would look, but I can see people that already use enums for "status handling" (or similar stuff) wanting the features status map provides.

we might tackle this with a enum-like interface:

from status_map.enum import StatusEnum  # this should be compatible with std lib's enum.Enum


class TaskEnum(StatusEnum):
    TODO = 0  # there might be a better way to do this in the std lib
    DOING = 1
    DONE = 2

The issue here is: how do we handle the transitions having an interface like that?

We might appeal to a django-like Meta class (I'm not really a fan of it though):

class TaskEnum(StatusEnum):
    TODO = 0
    DOING = 1
    DONE = 2

    class Meta:
        transitions = {'TODO': ['DOING'], 'DOING': ['TODO', 'DONE'], 'DONE': []}

Another possibility is to bet on a more of a "freestyle" method:

class TaskEnum(StatusEnum):
    TODO = 0, 'task waiting for someone work on it', ['DOING']
    DOING = 1, 'task in progess', ['TODO', 'DONE"]
    DONE = 2, 'task ready!', []  # adding the possibility to the user describe what each status means

It's not very intuitive but at the same time not complicated. With this approach I think we save a lot of code and can even add some meaning to all this. And it's not too difficult to implement if we use the aenum [1] lib.

Those two were the best alternatives I could think of, but there might be better ideas.

[1] https://bitbucket.org/stoneleaf/aenum/

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