예제 #1
0
            # id for this but we don't know the purchase id until we've written
            # to the database.

            attachments = [models.Attachment(filename=f)
                           for f in attachment_names]
            purchase = models.Purchase(name=form.purchase_name.data,
                                       date=datetime.datetime.now(),
                                       buyer_name='danielsank',
                                       attachments=attachment_names,
                                       line_items=line_items)
            session = Session()
            session.add(purchase)
            session.commit()
            # Store to database
            """
        else:
            print("FORM INVALID")
            print form.errors


class Error(wa2.RequestHandler):
    def get(self):
        raise Exception("If you see this you're not in production mode")


application = wa2.WSGIApplication([
    ('/users', Users),
    ('/purchases/add', AddPurchase),
    ('/error', Error)
], debug=not util.in_production_mode())