示例#1
0
  def get(self, key = None):

    if self.request.get('class') != None and key is not None:
	#Check for cached rendered content in memory
	data = memcache.get('results_'+key+'_'+self.request.get('class'))
#	if data is not None:
		#self.response.out.write(data)
		#return
		
    renderer = PlainRenderer()
    data = renderer.renderResultList(key,self.request.get('class'))
    self.response.out.write(data)
示例#2
0
  def get(self, key = None):
    self.response.headers['Content-Type'] = 'text/xml'
    comp = db.get(key)

    if comp == None:
    	self.response.out.write('<response status="ERR" message="WRONG PASSWORD"/>')
    else:
	if comp.password == self.request.get('password'):
		q = db.GqlQuery('SELECT * from Class WHERE competitionid = :1 and name = :2',comp.key(),self.request.get('name'))

		controlnames = self.request.get('controlnames').split(',')
		scontrolids = self.request.get('controlids').split(',')
		
		controlids = []
		if scontrolids != None and len(scontrolids) > 0:
			for i in scontrolids:
				if i != None and i != '':
					controlids.append(int(i))
    		
    		cl = q.get()
    		if cl:
			logging.debug("updating class " + self.request.get('name'))
       			cl.ident = urllib.quote_plus(self.request.get('name').encode('utf-8'))
			cl.ControlNames = controlnames
			cl.ControlCodes = controlids
       			cl.put()       
    		else:
			logging.debug("creating class " + self.request.get('name'))
       			cl = Class(name = self.request.get('name'))
       			cl.ident = urllib.quote_plus(self.request.get('name').encode('utf-8'))
       			cl.competitionid = comp.key()
			cl.ControlNames = controlnames
			cl.ControlCodes = controlids
       			cl.put()
  
		logging.debug("cleaning memcache")
		#Update Memcache!  
		memcache.delete(key+"_classes")
		memcache.delete(key + "_class_" + self.request.get('name'))
		rend = PlainRenderer()
		rend.renderResultList(key,self.request.get('name'))

    		self.response.out.write('<response status="OK"/>')
	else:
		self.response.out.write('<response status="ERR" message="WRONG PASSWORD"/>')
示例#3
0
  def get(self, key = None):
    self.response.headers['Content-Type'] = 'text/xml'
    comp = memcache.get(key)
    if comp is None:
    	comp = db.get(key)
	memcache.set(key,comp,3600)

    if comp == None:
    	self.response.out.write('<response status="ERR" message="WRONG PASSWORD"/>')
    else:
	if comp.password == self.request.get('password'):
		cl = memcache.get(key + "_class_" + self.request.get('classname'))
		if cl is None:
			q = db.GqlQuery('SELECT * from Class WHERE competitionid = :1 and name = :2',comp.key(),self.request.get('classname'))
    			cl = q.get()
			memcache.set(key + "_class_" + self.request.get('classname'), cl, 3600)

		q = db.GqlQuery('SELECT * from Runner WHERE runnerClass = :1 and id = :2',cl,int(self.request.get('id')))
		runner = q.get()

		scontroltimes = self.request.get('splittimes').rsplit(',')
		scontrols = self.request.get('splitcontrols').rsplit(',')
		
		controlids = []
                controltimes = []
		if scontrols != None and len(scontrols) > 0:
			for i in scontrols:
				if i != None and i != '':
					controlids.append(int(i))

		if scontroltimes != None:
			for i in scontroltimes:
				if i != None and i != '':
					controltimes.append(int(i))

    		logging.debug("parsed splitcontrols")
		logging.debug(controlids)

    		if runner != None:
			runner.firstname = self.request.get('firstname')
			runner.lastname = self.request.get('lastname')
			runner.clubname = self.request.get('clubname')
			runner.totaltime = int(self.request.get('totaltime'))
			runner.status = int(self.request.get('status'))
			runner.changetime = datetime.now()
			runner.SplitControls = controlids
			runner.SplitTimes = controltimes
       			runner.put()
    		else:
			runner = Runner(firstname = self.request.get('firstname'), lastname = self.request.get('lastname'),
				clubname = self.request.get('clubname'),
				totaltime = int(self.request.get('totaltime')),
				status = int(self.request.get('status')),
				runnerClass = cl,
				SplitControls = controlids,
				SplitTimes = controltimes,
				changetime = datetime.now(),
				id = int(self.request.get('id')))
       			runner.put()

		#Update Memcache!  
		upd = memcache.get(key + "_" + self.request.get('classname') +"_lastrender")
		if upd == None:
			logging.debug("rerendering: " + self.request.get('classname'))
			rend = PlainRenderer()
			rend.renderResultList(key,self.request.get('classname'))

    		self.response.out.write('<response status="OK"/>')
	else:
		self.response.out.write('<response status="ERR" message="WRONG PASSWORD"/>')