class Configure(webapp.RequestHandler): def get(self): # make the user log in if no user name is supplied if self.request.get('user'): account = users.User(self.request.get('user')) else: if not users.get_current_user(): self.redirect(users.create_login_url(self.request.uri)) account = users.get_current_user() self.response.out.write('Set up your sensornode names here:

') # find all the sensors up to #10 sensorset = [] for i in range(10): c = db.GqlQuery("SELECT * FROM Powerusage WHERE author = :1 and sensornum = :2", users.get_current_user(), i) if c.get(): sensorset.append(i) self.response.out.write('

') for sensor in sensorset: name = "" currnamequery = db.GqlQuery("SELECT * FROM Sensorname WHERE author = :1 AND sensornum = :2", users.get_current_user(), sensor) currname = currnamequery.get() # first see if we're setting it! if self.request.get('sensornum'+str(sensor)): name = self.request.get('sensornum'+str(sensor)) if not currname: currname = Sensorname() # create a new entry currname.sensornum = sensor currname.author = users.get_current_user() currname.sensorname = name currname.put() else: # we're not setting it so fetch current entry if currname: name = currname.sensorname self.response.out.write('Sensor #'+str(sensor)+':

') self.response.out.write("""

""")