Closed jean closed 8 years ago
@plish I agree they should be two methods .. I've got a fancy singledispatch-based implementation here: https://github.com/plish/Trolly/pull/36/files It's conflicted now, but I can update if you like the approach.
@jean never seen that before, but it is definitely a lot cleaner. Think that is the better approach.
@plish I'm at a C# shop now, so I was getting envious of them using multiple-dispatch all over the place. And turns out at least single-dispatch in Python is easy :-)
I'm depending on singledispatch
from PyPI for 2.7 compatibility. For 3.4+ it's part of functools. I wouldn't mind if Trolly went 3.4.
The only thing that bothers me about the approach in #36 is that the different implementations return different things: the original (/labels
) API returns JSON for the new label, and the new (/idLabels
) returns (logically) a list of label ids.
I don't think that this is a problem, since in the new case you already have the label object with all its properties.
POST to /labels/ if creating a label by name. POST to /idLabels/ if assigning a label (pass Label instance).