Skip to content

Stacking to_object and from_object decorators. #5

@boris317

Description

@boris317

This kind of bothers me

@to_object()
@from_object()
class Foo(object):
    pass

The decorators are separate because each accepts arguments that modify the encode/decode behavior of the object. Stil, there is something about the above code I dislike. So how about something like this

@jsonable
class Foo(object):
    pass

jsonable accepts no arguments. If you want to pass arguments then you must still use from_object and to_object. Essentially jsonable becomes a short cut for the first example. Its implementation being quite simple

def jsonable(cls):
    to_object()(cls)
    from_object()(cls)

Is this use case common enough to warrant the additional of jsonable?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions