kazoo icon indicating copy to clipboard operation
kazoo copied to clipboard

Single watch for multiple nodes can't detect node path

Open AlexanderplUs opened this issue 11 years ago • 2 comments

When I create a single watch for multiple nodes

input_items = zk.get_children( inputNode )
for item_id in input_items :
    @zk.ChildrenWatch( '{}/{}'.format( inputNode, item_id ) )
    def watch_item_children( items):
        print items

my watch callback can't detect for which node it has been called. As I can see from sources of ChildrenWatch class there is path property but it isn't sent to watch callback as a parameter. I try to use send_event=True and get path from event param but it is set to None at first call So it will be great if you add additional flag for ChildrenWatch (send_path for example) to send path for watch callback

AlexanderplUs avatar Aug 05 '14 08:08 AlexanderplUs

If proposed change to API is acceptable I can make push request with my patch for this solution

AlexanderplUs avatar Aug 05 '14 08:08 AlexanderplUs

If the send_event is broken on first call, I'd prefer to fix that so it works properly, maybe that means we set the path there. That would be more consistent than adding more options. So rather than sending None as the event, we will make an Event object and send it in with the path.

bbangert avatar Sep 23 '14 17:09 bbangert