def post(self): if not self.form.validate(): self.add_message("The form did not validate.", 'error') return self.get() # load values out of the form name = self.form.name.data.strip() description = self.form.description.data.strip() vpus = self.form.vpus.data memory = self.form.memory.data disk = self.form.disk.data network = self.form.network.data rate = self.form.rate.data # save the flavor in our database flavor = Flavor( name=name, description=description, vpus=vpus, memory=memory, disk=disk, network=network, rate=rate, # current market rate launches=0, # number of total launches hot=2 # suggest minimum two instance addresses hot ) flavor.put() # log to alert self.add_message(('Flavor %s successfully created!' % name), 'success') # give it a few seconds to update db, then redirect time.sleep(1) return self.redirect_to('admin-flavors')
def post(self): # get current flavors flavors = Flavor().get_all() # build parameter list params = { 'flavors': flavors } # return images via template self.response.headers['Content-Type'] = 'application/json' return self.render_template('api/flavors.json', **params)