コード例 #1
0
ファイル: measure.py プロジェクト: ibolmo/cametrics
  def post(self,key,path,format):  
    
    self.campaign = Campaign.all(keys_only = True).filter('__key__ = ', db.Key(key)).get()
    if (not self.campaign):
      logging.warning('No campaign (%s) found.' % key)
      return self.error(404)
      
    logging.debug("%s, %s, %s" % (key, path, format))
    
    for value in self.request.POST:
			logging.info(value+": " + self.request.get(value))
    
    models = []
    error = False
    if 'bulk' in self.request.get('type'):
      data = simplejson.loads(self.request.get('data') or '[]')  #todo remove need for loads
      for datum in data:
        ns = datum.get('namespace')
        if ns:
          models.append(create_datum(self.campaign, ns, datum))
    elif path:
        models.append(create_datum(self.campaign, path, self.request))
    
    models += _Stats.values() + stat._Hists.values()
    send_to_datastore(models)
    self.response.set_status(error and 304 or 200)
コード例 #2
0
ファイル: measure.py プロジェクト: ibolmo/cametrics
 def get(self, key, path, format):
   if (not key):
     return self.error(500)
   
   self.campaign = Campaign.all(keys_only = True).filter('__key__ = ', db.Key(key)).get()
   if (not self.campaign):
     logging.warning('No campaign (%s) found.' % key)
     return self.error(404)
   
   self.format = format or self.request.get('format', 'json')
   self.namespace, self.path = util.getParts((path or '').strip('/').replace('/', '.'))
 
   logging.debug("%s, %s, %s; %s" % (key, self.namespace, self.path, self.format))
   helper = renderer.get(self.format)
   if self.path.startswith('values'): # this could be automated
     self.path = self.path.lstrip('values').strip('.')
     return helper.render_values(self)
   elif self.path.startswith('stats'):
     self.path = self.path.lstrip('stats').strip('.')
     return helper.render_stats(self)
   helper.render(self)