def setup(self): try: new_attrs = {} new_attrs.update(self.attrs) new_attrs.update(self.do_get_dependencies()) setup() self.obj = self.klass(**new_attrs) DBSession.add(self.obj) DBSession.flush() return self.obj except: DBSession.rollback() raise
def sendMessage(title, text, recipients, parentId=None, authorId=None): from tg import request authorId = None if authorId is None: authorId = request.identity['user'].user_id msg = Message(title=title, text=text, author_id=authorId, parent_id=parentId) DBSession.add(msg) DBSession.flush() UserMessage.sendMessageToUsers(msg, recipients)
def setUp(self): super(TestStructureSearch,self).setUp() org=DBSession.query(ReagentVendor).first() for name, smiles in self.smilesToReg.items(): mol = ReagentMol(toMolFromSmiles(smiles)) mol.mol_name = name submitter = User.by_user_name('chemadmin') lot = ReagentLot() lot.lot_submitter_id = submitter.user_id lot.lot_source_org_id = org.vendor_id mol.addLot(lot, 0) DBSession.add(mol) DBSession.flush()
def loadFeedDict(cls, feeds): for feed in feeds: guid = feed["id"] try: message = DBSession.query(Message).filter(Message.guid == guid).one() if _compareTime(message.updated.timetuple(),feed["updated_parsed"]) < 0: message.update(title=feed["title"], link=feed["link"], updated=feed["updated"], text=feed["summary"]) userMessages = DBSession.query(UserMessage).filter(UserMessage.message == message.message_id).all() for userMessage in userMessages: userMessage.new = True except NoResultFound: message = Message(text=feed["summary"], guid=feed["id"], **feed) DBSession.add(message) DBSession.flush() cls.sendMessageToAllUsers(message)
def gridInsert(self,modelObjects,row): o=modelObjects[self.rptCfg.pkcol.modelClass] DBSession().add(o) DBSession.flush() return (o,)
def gridInsert(self, modelObjects,row): mol=modelObjects[self._molClass] DBSession.add(mol) DBSession.flush() return mol,