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


Python model.DBSession類代碼示例

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


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

示例1: test_user

    def test_user(self):
        db = DBSession()
        user = db.query(User) \
            .filter(User.password == User.encryptPassword('root'), User.email == r'[email protected]') \
            .one()

        self.assertIsNotNone(user)
開發者ID:MarekSalat,項目名稱:Trine,代碼行數:7,代碼來源:_test_tag.py

示例2: gridInsert

 def gridInsert(self, modelObjects,row):
     rack = modelObjects[Rack]
     dbRack = None
     vial = modelObjects[Vial]
     if rack.rack_barcode:
         dbRack = Rack.byBarcode(rack.rack_barcode)
         if dbRack is None:
             dbRack = Rack()
             dbRack.rack_barcode = rack.rack_barcode
             if vial.well:
                 dbRack.rack_type_id = vial.well.rack_type_id
             DBSession().add(dbRack)
             DBSession().flush()
     mol=modelObjects[Mol]
     mol=mergeMol(mol)
     lot=modelObjects[Lot]
     if lot.lot_id is None:
         mol.addLot(lot, 0)
     else:
         lot=DBSession().merge(lot)
     lot.vials.append(vial)
     if dbRack:
         vial.vial_rack_id = dbRack.rack_id
     vial.vial_lot_aliquot_no = len(lot.vials)
     if lot.lot_submitter_id == None:
         lot.lot_submitter_id = request.identity['user'].user_id
     if hasattr(mol,'mol_reg_id') and not row.has_key('verify'):
         if mol.mol_reg_id is None:
             mol.setAltId(row['prefix'])
     DBSession().flush()
     return mol, lot, vial, dbRack
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:31,代碼來源:grids.py

示例3: gridData

    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
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:34,代碼來源:grids.py

示例4: testReagentRegistration

 def testReagentRegistration(self):
     """Authenticated users can register reagents"""
     numBeforeDbLots = len(DBSession.query(ReagentLot).all())
     self.doRegistration('reagents', 'app/tests/data/molregtest.sdf')
     self.checkGridPostReg('reagents')
     numAfterDbLots = len(DBSession.query(ReagentLot).all())
     ok_(numAfterDbLots == numBeforeDbLots + 2, 'Failed to register 2 new lots')
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:7,代碼來源:test_modreg_registration.py

示例5: testClone

 def testClone(self):
     r=DBSession().query(Rxn).first()
     ok_(r)
     newr=r.clone()
     ok_(newr)
     DBSession().add(newr)
     transaction.commit()
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:7,代碼來源:test_rxn.py

示例6: setAltId

 def setAltId(self,value):
     try:
         regConfig = DBSession().query(MolRegConfig).get(value)
         self.mol_reg_id = regConfig.getRegId()
     except Exception,e:
         log.exception(e)
         raise Exception("Configure your registry id prefix first using the 'Configure' link.")
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:7,代碼來源:compounds.py

示例7: clear

 def clear(self,parentId):
     retVal={}
     try:
         parent = DBSession().query(ReagentLotLocation).get(parentId)
         parent.lots=[]
     except Exception,e:
         log.exception(e)
         retVal={'error':'Parent not found'}
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:8,代碼來源:root.py

示例8: gridUpdate

 def gridUpdate(self, modelObjects,row):
     rpt=Report(self.rptCfg)
     pkCol=rpt._rptCfg._columns[rpt.getIdName()]
     modelClass=pkCol.modelClass
     id=getattr(modelObjects[modelClass], rpt.getIdName())
     fileRow=DBSession().query(FileRow).get(id)
     fileRow.pickle(rpt.convertToUI(*modelObjects.values()))
     return None
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:8,代碼來源:livegrid.py

示例9: checkOutLot

 def checkOutLot(self,barcode,userId,pbarId=None):
     retVal = {}
     try:
         lot = DBSession().query(ReagentLot).filter(ReagentLot.lot_barcode==barcode.strip()).one() #@UndefinedVariable : lot_barcode comes from SQLAlchemy reflection
         lot.lot_current_user_id = int(userId)
         retVal = {'success': "Successfully checked out " + lot.lot_barcode}
     except Exception,e:
         log.debug(e)
         retVal = {'error': 'barcode ' +  barcode + ' not found in inventory'}
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:9,代碼來源:root.py

示例10: sendMessageToUser

 def sendMessageToUser(cls, message, userId):
     if str(userId) == "#":
         user = _InnectusUser
         _sendMessageViaMail(message, user)
     else:
         user = DBSession.query(User).filter(User.user_id == userId).one()
         #_sendMessageViaMail(message, user)
         userMessage = cls(user, message)
         DBSession.add(userMessage)
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:9,代碼來源:messages.py

示例11: disposeLot

 def disposeLot(self,barcode,userId,pbarId=None):
     retVal = {}
     try:
         lot = DBSession().query(ReagentLot).filter(ReagentLot.lot_barcode==barcode.strip()).one() #@UndefinedVariable : lot_barcode comes from SQLAlchemy reflection
         lot.lot_is_disposed = 'Y'
         lot.lot_current_user_id = None
         retVal = {'success': 'Marked as disposed ' + lot.lot_barcode}
     except Exception,e:
         log.debug(e)
         retVal = {'error': 'barcode ' +  barcode + ' not found in inventory'}
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:10,代碼來源:root.py

示例12: link

 def link(self,parentId,childBarcode):
     retVal={'success': 'Successfully linked reagent'}
     try:
         child = DBSession().query(ReagentLot).filter(ReagentLot.lot_barcode==childBarcode).one()
         child.loc = DBSession().query(ReagentLotLocation).get(parentId)
         child.aud_modified_date = datetime.datetime.now()
         child.lot_current_user_id = None
     except Exception,e:
         log.exception(e)
         retVal={'error':"Could not find barcode " + childBarcode}
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:10,代碼來源:root.py

示例13: gridDelete

 def gridDelete(self,modelObjects):
     req = DBSession().query(Request).get(modelObjects[Request].request_id)
     if len(req.items) == 0:
         DBSession().delete(req)
     elif req.hasOpenItems() and not req.hasClosedItems():
         for i in req.items:
             DBSession().delete(i)
         DBSession().delete(req)
     else:
         raise ClientException("Can't delete a request with completed items")
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:10,代碼來源:grids.py

示例14: gridUpdate

 def gridUpdate(self, modelObjects,row):
     request = modelObjects[Request]
     requestItem = modelObjects[RequestItem]
     mol = modelObjects[Mol]
     mols = DBSession().query(Mol).filter(Mol.mol_reg_id==mol.mol_reg_id).all()
     if len(mols)==0:
         raise ClientException(mol.mol_reg_id + " was not found in the database")
     mol = mols[0]
     item = DBSession().merge(requestItem)
     item.mol = mol
     return mol,item,request
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:11,代碼來源:grids.py

示例15: setUp

 def setUp(self):
     '''
     Need a row of data in the login audit table
     '''
     super(TestUserAdministration, self).setUp()
     aud = AuditLogin(dict(REMOTE_ADDR='127.0.0.1'), dict(user_name='chemadmin'))
     result = AuditLoginResult.get('LOGIN_SUCCESS')
     aud.login_result = result
     log.debug(aud in DBSession())
     DBSession.add(aud)
     transaction.commit()
開發者ID:aytsai,項目名稱:ricebowl,代碼行數:11,代碼來源:test_admin.py


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