def add_circuit(self): """A view that allows users to add an circuit to an """ params = self.request.params pin = params.get("pin") if len(pin) == 0: pin = Circuit.get_pin() account = Account( lang=params.get("lang"), phone=params.get("phone")) circuit = Circuit(meter=self.meter, account=account, ip_address=params.get("ip_address"), energy_max=int(params.get("energy_max")), power_max=int(params.get("power_max"))) self.session.add(account) self.session.add(circuit) self.session.flush() return Response(simplejson.dumps(circuit.id))
def add_circuit(self): params = self.request.params pin = params.get("pin") if len(pin) == 0: pin = Circuit.get_pin() account = Account( lang=params.get("lang"), phone=params.get("phone")) circuit = Circuit(meter=self.meter, account=account, pin=pin, ip_address=params.get("ip_address"), energy_max=int(params.get("energy_max")), power_max=int(params.get("power_max"))) self.session.add(account) self.session.add(circuit) self.session.flush() return HTTPFound(location="%s%s" % ( self.request.application_url, self.meter.getUrl()))