コード例 #1
0
    def post(self):
        submit = self.request()

        submit["connector"] = session[USER_SESSION]["uid"]
        if not submit.__contains__("path"): submit["path"] = ""
        submit["create_time"]=datetime.now()
        submit["last_time"]=datetime.now()
        Supplier.add(submit)
        return self.succ()
コード例 #2
0
 def put(self, id):
     submit = self.request()
     submit["id"] = id
     Supplier.edit(submit)
     return self.succ()
コード例 #3
0
 def delete(self, id):
     Supplier.delete(id)
     return self.succ()
コード例 #4
0
 def get(self, id=0):
     if id: return self.succ(Supplier.get(id))
     return self.succ(Supplier.select(_orders=Supplier.id.desc()))
コード例 #5
0
class SupplierApi(BaseApi):
    route = ["/supplier", "/supplier/<int:id>"]

    def get(self, id=0):
        if id: return self.succ(Supplier.get(id))
        return self.succ(Supplier.select(_orders=Supplier.id.desc()))

    def post(self):
        submit = self.request()

        submit["connector"] = session[USER_SESSION]["uid"]
        if not submit.__contains__("path"): submit["path"] = ""
        submit["create_time"]=datetime.now()
        submit["last_time"]=datetime.now()
        Supplier.add(submit)
        return self.succ()

    def delete(self, id):
        Supplier.delete(id)
        return self.succ()

    def put(self, id):
        submit = self.request()
        submit["id"] = id
        Supplier.edit(submit)
        return self.succ()


if __name__ == "__main__":
    print Supplier.select(_orders=Supplier.id.desc())