Exemple #1
0
 def log(self, action, data):
     parent = self.get_version() or None
     #mongo.db.history.remove(); parent = None
     prev = self.replay()
     data = self.get_delta(prev, data)
     if not data:
         return
     delta = {
         'uri': self.target,
         'action': action,
         'data': data,
         'parent': ObjectId(parent) if parent else None,
         'utc': dt.utcnow()
     }
     mongo.db.history.insert( delta )
     redis.set("history:version:%s" % self.target, str( delta['_id'] ))
     print delta
     redis.publish('history', to_json(delta))
Exemple #2
0
 def post(self, path):
     self.value = dict( request.form.items() )
     redis.set(self.uri, to_json(self.value))
     self.history.log('update', self.value)
     return self