當前位置: 首頁>>代碼示例>>Python>>正文


Python DBSession.location方法代碼示例

本文整理匯總了Python中app.model.DBSession.location方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.location方法的具體用法?Python DBSession.location怎麽用?Python DBSession.location使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app.model.DBSession的用法示例。


在下文中一共展示了DBSession.location方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: registerSdf

# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import location [as 別名]
    def registerSdf(self, prefix, pbar,jobId=0):
        file = self.getFile()
        pbar.startProgress(len(file.rows))
        rpt=Report(self.rptCfg)
        failures=[]
        successes=[]
        jobId=register.getJobId()
        
        # do some caching of various IDs to speed things up
        racks={}
        locationsByBarcode={}
        locationsByName={}
        wellsByType={}
        rackTypeHasWells={}
        for fileRow in file.rows:
            rowValue=fileRow.unpickle()
            mol=rpt.convertToModel(rowValue, self.MolClass)
            mol.mol_struct=fileRow.mol_struct
            mol.chirality = fileRow.chirality
            lot=rpt.convertToModel(rowValue, self.LotClass)
            if lot.lot_submitter_id is None:
                lot.lot_submitter_id =request.identity['user'].user_id
            try:
                transaction.begin()
                mol.mol_id = None
                mol=mergeMol(mol)
                mol.addLot(lot, jobId)
                DBSession().flush()

                rack=rpt.convertToModel(rowValue, self.RackClass)
                rackId = racks.get(rack.rack_barcode, None)
                dbRack = None
                if rackId is None:
                    dbRack=Rack.byBarcode(rack.rack_barcode)
                else:
                    dbRack = DBSession().query(Rack).get(rackId)
                if dbRack is None:
                    if rack.rack_type_id:
                        DBSession().add(rack)
                        DBSession().flush()
                        dbRack = rack
                if dbRack:
                    racks[rack.rack_barcode]=dbRack.rack_id
                        
                location=rpt.convertToModel(rowValue, RackLocation)
                if location.locationName != 'None' or location.barcode:
                    dbLoc=None
                    if location.barcode:
                        locId = locationsByBarcode.get(location.barcode, None)
                        if locId:
                            dbLoc=DBSession().query(RackLocation).get(locId)
                        else:
                            dbLoc=RackLocation.byBarcode(location.barcode)
                            if dbLoc:
                                locationsByBarcode[location.barcode]=dbLoc.id
                    if dbLoc is None:
                        locId=locationsByName.get(location.locationName, None)
                        if locId:
                            dbLoc=DBSession().query(RackLocation).get(locId)
                        else:
                            dbLoc=RackLocation.byName(location.locationName)
                        if dbLoc is None:
                            DBSession().add(location)
                            DBSession().flush()
                            dbLoc = location
                        locationsByName[dbLoc.locationName]=dbLoc.id
                    if dbLoc and dbRack:
                        dbRack.location=dbLoc

                vial = self.VialClass()
                rpt.updateModel(rowValue, vial)
                if dbRack:
                    typeId=dbRack.rack_type_id
                    hasWells = rackTypeHasWells.get(typeId, None)
                    if hasWells is None:
                        rackTypeHasWells[typeId]=len(dbRack.type.wells) > 0
                        hasWells = rackTypeHasWells[typeId]
                    if hasWells:
                        rackWell=None
                        rackWellId=None
                        if wellsByType.has_key(typeId):
                            rackWellId=wellsByType[typeId].get(rowValue.get('vial_rack_well'))
                        else:
                            wellsByType[typeId]={}
                        if rackWellId is None:
                            rackWell=RackWell.byTypeAndName(dbRack.type, rowValue.get('vial_rack_well', None))
                            wellsByType[typeId][rackWell.rack_well_name]=rackWell.rack_well_id
                            rackWellId = rackWell.rack_well_id
                        if rackWellId:
                            vial.vial_rack_well_id=rackWellId
                        else:
                            raise ClientException('Location (e.g., well) in rack or plate must be specified, "%s" is invalid' % rowValue.get('vial_rack_well', 'Nothing'))
                vial.vial_lot_aliquot_no = 1  #  has to be 1, since we're creating a new lot for every entry in the sd file
                if dbRack:
                    vial.vial_rack_id = dbRack.rack_id
                vial.vial_lot_id = lot.lot_id
                vial.amount = dict(amount=rowValue.get('vial_amt', None), amountUnits=rowValue.get('vial_amt_units', None),
                                   conc=rowValue.get('vial_conc', None), concUnits=rowValue.get('vial_conc_units', None))
                DBSession().add(vial)

#.........這裏部分代碼省略.........
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:103,代碼來源:grids.py


注:本文中的app.model.DBSession.location方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。