本文整理汇总了Python中app.model.DBSession.filter方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.filter方法的具体用法?Python DBSession.filter怎么用?Python DBSession.filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.model.DBSession
的用法示例。
在下文中一共展示了DBSession.filter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gridData
# 需要导入模块: from app.model import DBSession [as 别名]
# 或者: from app.model.DBSession import filter [as 别名]
def gridData(self):
columns=self.rptCfg.uicolumns
idName=self.rptCfg.getId()
results = []
reqs = DBSession().query(Request).select_from(outerjoin(Request,RequestItem))
childrenDisp = []
dispense = reqs.filter(RequestItem.request_item_dispense_date == None).order_by(Request.request_id).all()
for row in dispense:
# if row.hasOpenItems() or len(row.items)==0:
rowData = []
for col in columns:
val = getattr(row,col.id,None)
if isinstance(val,datetime):
val = val.strftime('%m/%d/%Y')
rowData.append(val)
childrenDisp.append({'id':row.__dict__[idName], 'data':rowData})
childrenComplete = []
complete = reqs.filter(RequestItem.request_item_dispense_date > (datetime.now()-timedelta(days=1))).order_by(Request.request_id).all()
for row in complete:
if not row.hasOpenItems():
rowData = []
for col in columns:
val = getattr(row,col.id,None)
if isinstance(val,datetime):
val = val.strftime('%m/%d/%Y')
rowData.append(val)
childrenComplete.append({'id':row.__dict__[idName], 'data':rowData})
results.append(dict(id='open',data=['Open Requests'],children=childrenDisp))
results.append(dict(id='closed',data=['Recently Closed'],children=childrenComplete))
results.append(dict(id='search',data=['Search']))
return results
示例2: register
# 需要导入模块: from app.model import DBSession [as 别名]
# 或者: from app.model.DBSession import filter [as 别名]
def register(self,pbarId,uid,request_id=None,prefix=None):
pbar = getTaskMonitor(pbarId)
log.debug('in register')
pbar.setText('Loading dispense data...')
file = self.getFile()
pbar.startProgress(len(file.rows))
rpt=Report(self.rptCfg)
failures=[]
successes=[]
for fileRow in file.rows:
rowValue = fileRow.unpickle()
try:
transaction.begin()
srcVialBarcode = rowValue['src_vial_barcode']
srcVialWell = rowValue['src_vial_rack_well']
srcRackBarcode = rowValue.get('src_rack_barcode', None)
# Track down the src vial
if srcVialBarcode:
srcVial = Vial.byBarcode(srcVialBarcode)
elif srcRackBarcode:
srcRack = Rack.byBarcode(srcRackBarcode)
srcVial = Vial.byRackAndWellName(srcRack, srcVialWell)
if srcVial is None:
raise ClientException("Could not find source vial in database")
lot=srcVial.lot
vial = Vial()
if rowValue['vial_barcode']:
vial.vial_barcode = rowValue['vial_barcode']
vial.vial_lot_aliquot_no = lot.getVialCount()+1
amount = rowValue.get('amount', None)
amountUnits = rowValue.get('amountUnits', None)
vial.vial_amt = calcValueFromDisp(amount, amountUnits)
vial.vial_amt_units = amountUnits
conc = rowValue.get('conc', None)
concUnits = rowValue.get('concUnits', None)
vial.vial_conc = calcValueFromDisp(conc, concUnits)
vial.vial_conc_units = concUnits
srcAmount = rowValue.get('srcAmount', None)
srcAmountUnits = rowValue.get('srcAmountUnits', None)
srcAmtChange = calcValueFromDisp(srcAmount, srcAmountUnits)
srcVial.dispense(srcAmtChange)
lot.vials.append(vial)
rackBarcode = None
rackBarcode = rowValue['rack_barcode']
rackTypeId = rowValue['rack_type_id']
rackWellName = rowValue['vial_rack_well']
on_hand=rowValue['on_hand']
if on_hand not in ['Y', 'N']:
on_hand = None
dbRack = None
if rackTypeId:
if rackBarcode:
dbRack = Rack.byBarcode(rackBarcode)
if dbRack is None:
dbRack = Rack()
dbRack.rack_type_id = rackTypeId
if rackBarcode:
dbRack.rack_barcode = rackBarcode
DBSession().add(dbRack)
DBSession().flush()
dbRack.rack_isactive = on_hand
if dbRack and len(dbRack.type.wells) >0:
vial.rack = dbRack
rackWell=RackWell.byTypeAndName(dbRack.type, rackWellName)
vial.vial_rack_well_id = rackWell.rack_well_id
elif rackWellName:
raise ClientException('Well %s was specified but no valid rack or plate was given' % rackWellName)
vial.parent = srcVial
if request_id is not None:
req=DBSession().query(Request).get(request_id)
if req is None:
raise ClientException('Unable to find corresponding compound request')
itemQuery=DBSession().query(RequestItem).filter(RequestItem.request == req)
itemQuery=itemQuery.filter(RequestItem.mol==lot.mol)
itemQuery=itemQuery.filter(RequestItem.request_item_dispense_date == None)
item=None
for i in itemQuery:
if i.request_item_lot_number == lot.lot_number or i.request_item_lot_number is None:
item=i
break
if item is None:
item=RequestItem()
item.request=req
item.mol = lot.mol
item.request_item_lot_number = lot.lot_number
item.request_item_dispense_date = datetime.now()
item.request_item_dispense_from_vial_id = srcVial.vial_id
item.request_item_dispense_to_vial_id = vial.vial_id
item.request_item_dispense_amt = srcAmount
item.request_item_dispense_amt_units = srcAmountUnits
transaction.commit()
pbar.incProgress()
successes.append(fileRow)
#.........这里部分代码省略.........