python-etcd icon indicating copy to clipboard operation
python-etcd copied to clipboard

Read nodes as a tree.

Open pheaver opened this issue 10 years ago • 6 comments

EtcdResult has all of the children flattened, and sometimes I really want to traverse the result as a tree (the way that etcd provides them). Is this something you would consider?

pheaver avatar Apr 16 '15 21:04 pheaver

I encountered this too and made a fix in my fork. If it is ok, I can submit pull request.

lechat avatar Apr 22 '15 08:04 lechat

I would imagine it breaks backwards compatibility, but it seems like a necessary change. I'll take a look if I get a chance and see what you did.

pheaver avatar Apr 22 '15 15:04 pheaver

Oh, I see that you made it so that it doesn't return all that duplicate data in both the parents and the children. That's definitely an improvement. However, I was also hoping that the nodes would come back as a tree, and not flattened.

pheaver avatar Apr 22 '15 17:04 pheaver

I think that since raw data nodes will still be wrapped in EtcdResult class, there is no point to return whole data, but just return immediate leaves. It is fairly trivial to traverse through leaves.

lechat avatar Apr 23 '15 04:04 lechat

As for backwards compatibility, I thought about it and will try to make new method in EtcdResult for this feature once I get unit tests running on my machine and before I submit pull request.

lechat avatar Apr 23 '15 04:04 lechat

@lechat thanks a bunch! I think backwards compatibility is a must, so you're on the right path :)

lavagetto avatar Apr 23 '15 09:04 lavagetto