当前位置: 首页>>代码示例>>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;未经允许,请勿转载。