title: creating a firebase event listener using REST
body: <p>I am trying to implement a Firebase Server using <a href="http://ozgur.github.io/python-firebase/" rel="nofollow">this Python library</a>, and am having trouble understanding <a href="https://www.firebase.com/docs/rest/guide/retrieving-data.html#section-rest-streaming" rel="nofollow">Firebase's REST streaming API</a>, which seems to be what I need to use for my server. The only examples I can find are <a href="https://github.com/firebase/EventSource-Examples/tree/master/python" rel="nofollow">here</a>, and either I can't decipher it or it does not explain how to use the code in the way that I need. </p>
  
  <p>What I am trying to do is create an event listener which will listen for any changes to or new children of a branch of my Firebase database, and make changes to a separate branch accordingly. This is how I have the same functionality implemented in JavaScript:</p>
  
  <pre><code>var sumVal = new Firebase("myProject.firebaseio.com/sum");
  users.on("child_changed", function(snapshot) {
      var user = snapshot.val();
      var dataVal = user.data;
      var uid = snapshot.key();
      var url = "myProject.firebaseio.com/users/" + uid;
      var userID = new Firebase(url);
      var newSum = 0;
      for (i = 0; i &lt; dataVal.length; i++) { 
          newSum = newSum + dataVal[i];
      }
  
      if(uid){
          sumVal.update({
              sum: newSum
              });
      }
  
  });
  </code></pre>
  
  <p>It would be extremely helpful if someone could provide a brief example on how this kind of system would be implemented in Python, as I could then get a much better understanding of how the two languages "translate" to one another. </p>
  
  <p>NOTE: Please do not just link me to resources I have already listed, as I have spent the past 2 days trying to figure them out and simply being told to look at them again will not help.</p>
  
  <p>Update: If this can be done with polling instead of streaming, then I would be willing to use that instead.</p>