本文整理匯總了Python中app.model.DBSession.add方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.add方法的具體用法?Python DBSession.add怎麽用?Python DBSession.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app.model.DBSession
的用法示例。
在下文中一共展示了DBSession.add方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: sendMessageToUser
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
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)
示例2: setUp
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
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()
示例3: setup
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
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
示例4: sendMessage
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
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)
示例5: setUp
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
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()
示例6: loadFeedDict
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
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)
示例7: gridInsert
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
def gridInsert(self, modelObjects,row):
mol=modelObjects[self._molClass]
DBSession.add(mol)
DBSession.flush()
return mol,
示例8: sendMessageToAllUsers
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import add [as 別名]
def sendMessageToAllUsers(cls, message):
users = DBSession.query(User).all()
for user in users:
userMessage = cls(user, message)
DBSession.add(userMessage)