Пример #1
0
 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
Пример #2
0
        try:
            rxnMol=register.mergeMol(rxnMol)
            # Default state is solid if not set
            if not rxnMol.state:
                rxnMol.state = 'solid'
            if mol_name and mol_name != rxnMol.mol_name or mol_cas_no and mol_cas_no != rxnMol.mol_cas_no:
                checkModifyRxnMol(request.identity['user'], request.identity['permissions'], rxnMol)
                rxnMol.mol_name = mol_name
                rxnMol.mol_cas_no = mol_cas_no
                updateRxnProtocolsAndNamesFromMol(rxnMol)
        except register.MissingUniqueAttrError,e:
            raise ClientException('You must draw a structure, enter a CAS number or enter a compound name.')
        except Exception,e:
            raise e
        c=DBSession().merge(rxnComponent)
        c.mol=rxnMol
        checkModifyRxn(request.identity['user'], request.identity['permissions'], c.rxn)
        DBSession().flush()

        return rxnMol, c
    
    def gridDelete(self,modelObjects):
        rxnComponent = self._rxnComponent(modelObjects)
        rxnComponent = DBSession().merge(rxnComponent)
        rxnComponent.lotSalts = []
        checkModifyRxn(request.identity['user'], request.identity['permissions'], rxnComponent.rxn)
        DBSession().delete(rxnComponent)


    def _rxnComponent(self, modelObjects):
        rxnComponent=modelObjects[self.rptCfg.pkcol.modelClass]