Exemplo n.º 1
0
 def delete(self, argument):
     try:
         noautoflushsession.query(Product).filter(
             Product.ProductID == int(argument)).delete()
         noautoflushsession.commit()
         noautoflushsession.close()
         self.write_json("success", code=1)
     except Exception, e:
         print e
         self.write_json("failed", code=0)
Exemplo n.º 2
0
 def get(self):
     ret = noautoflushsession.query(Product)
     for i, x in enumerate(ret):
         # 根据ProductTypeID查询每个类型的名称【有个坑,需要关闭sqlalchemy自动刷新】
         q_name = ""
         q_name = noautoflushsession.query(ProductType).filter_by(
             ProductTypeID=x.ProductType).first()
         if q_name:
             q_name = q_name.ProductTypeName
         ret[i].ProductType = q_name
     noautoflushsession.close()
     self.render('admin_product.html', Product_list=ret)