本文整理汇总了Python中abstrackr.model.meta.Session.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Session.commit方法的具体用法?Python Session.commit怎么用?Python Session.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类abstrackr.model.meta.Session
的用法示例。
在下文中一共展示了Session.commit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _clear_this_user_locks
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def _clear_this_user_locks(self, all_assignments):
priorities_locked_by_this_user = self._get_all_priorities_locked_by_this_user(all_assignments)
for p in priorities_locked_by_this_user:
p.is_out = 0
p.locked_by = None
Session.add(p)
Session.commit()
示例2: customize_citations
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def customize_citations(self):
# Obtain the parameters.
show_journal_str = request.params['toggle_journal']
show_authors_str = request.params['toggle_authors']
show_keywords_str = request.params['toggle_keywords']
# Obtain the User object (as opposed to the auth.User object).
cur_user = controller_globals._get_user_from_email(request.environ.get('repoze.who.identity')['user'].email)
# Make changes to the booleans of the user object.
cur_user.show_journal = {"Show":True, "Hide":False}[show_journal_str]
cur_user.show_authors = {"Show":True, "Hide":False}[show_authors_str]
cur_user.show_keywords = {"Show":True, "Hide":False}[show_keywords_str]
# Add the changes to the database.
Session.commit()
# These messages appear in their designated separate locations,
# i.e. on the top left corner of the div that corresponds to this function.
# This is more appropriate than having a general message on some part of the screen.
c.account_msg = ""
c.account_msg_citation_settings = "Citation Settings changes have been applied."
return render("/accounts/account.mako")
示例3: create_account_handler
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def create_account_handler(self):
'''
Note that the verification goes on in model/form.py.
'''
# create the new user; post to db via sqlalchemy
new_user = model.User()
new_user.username = request.params['username']
new_user.fullname = " ".join([request.params['first_name'], request.params['last_name']])
new_user.experience = request.params['experience']
new_user._set_password(request.params['password'])
new_user.email = request.params['email']
# These are for citation settings,
# initialized to True to make everything in the citation visible by default.
new_user.show_journal = True
new_user.show_authors = True
new_user.show_keywords = True
Session.add(new_user)
Session.commit()
# send out an email
greeting_message = """
Hi, %s.\n
Thanks for signing up at abstrackr (%s). You
should be able to sign up now with username %s (only you know your password).
This is just a welcome email to say hello, and that we've got your email.
Should you ever need to reset your password, we'll send you instructions
to this email. In the meantime, happy screening!
-- The Brown EPC.
""" % (new_user.fullname, url('/', qualified=True), new_user.username)
try:
self.send_email_to_user(new_user, "welcome to abstrackr", greeting_message)
except:
# this almost certainly means we're on our Windows dev box :)
pass
###
# log this user in programmatically (issue #28)
rememberer = request.environ['repoze.who.plugins']['cookie']
identity = {'repoze.who.userid': new_user.username}
response.headerlist = response.headerlist + \
rememberer.remember(request.environ, identity)
rememberer.remember(request.environ, identity)
# if they were originally trying to join a review prior to
# registering, then join them now. (issue #8).
if 'then_join' in request.params and request.params['then_join'] != '':
redirect(url(controller="review", action="join", review_code=request.params['then_join']))
else:
redirect(url(controller="account", action="login"))
示例4: change_password
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def change_password(self):
current_user = request.environ.get('repoze.who.identity')['user']
if request.params["password"] == request.params["password_confirm"]:
current_user._set_password(request.params['password'])
Session.commit()
c.account_msg = "ok, your password has been changed."
else:
c.account_msg = "whoops -- the passwords didn't match! try again."
c.account_msg_citation_settings = ""
return render("/accounts/account.mako")
示例5: gen_token_to_reset_pwd
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def gen_token_to_reset_pwd(self, user):
# generate a random token for the user to reset their password; stick
# it in the database
make_token = lambda N: ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(N))
reset_pwd_q = Session.query(model.ResetPassword)
existing_tokens = [entry.token for entry in reset_pwd_q.all()]
token_length=10
cur_token = make_token(token_length)
while cur_token in existing_tokens:
cur_token = make_code(token_length)
reset = model.ResetPassword()
reset.token = cur_token
reset.user_email = user.email
Session.add(reset)
Session.commit()
return cur_token
示例6: confirm_password_reset
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def confirm_password_reset(self, id):
token = str(id)
reset_pwd_q = Session.query(model.ResetPassword)
# we pull all in case they've tried to reset their pwd a few times
# by the way, these should time-expire...
matches = reset_pwd_q.filter(model.ResetPassword.token == token).all()
if len(matches) == 0:
return """
Hrmm... It looks like you're trying to reset your password, but I can't match the provided token.
Please go back to the email that was sent to you and make sure you've copied the URL correctly.
"""
user = controller_globals._get_user_from_email(matches[0].user_email)
for match in matches:
Session.delete(match)
user._set_password(token)
Session.commit()
return '''
ok! your password has been set to %s (you can change it once you've logged in).\n
<a href="%s">log in here</a>.''' % (token, url('/', qualified=True))
示例7: _set_assignment_done_status
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
def _set_assignment_done_status(self, all_assignments):
for a in all_assignments:
b_assignment_done = controller_globals._check_assignment_done(a)
a.done = b_assignment_done
Session.add(a)
Session.commit()
示例8: open
# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import commit [as 别名]
not_found = 0
with open(FILE_PATH, 'r') as f:
reader = csv.DictReader(f, delimiter='\t')
for row in reader:
#print(row['id'], row['title'], row['abstract'])
citation = citations_q.filter_by(title=row['title'], project_id=PROJECT_ID).first()
if not citation:
print('could not find title matching with %s' % row['title'])
not_found += 1
else:
found += 1
citation.refman = row['id']
Session.add(citation)
Session.commit()
print("found %s" % found)
print("not found %s" % not_found)
##############################################################################################
### This was for getting PMID's from the titles
#citations_q = Session.query(model.Citation)
#citations = citations_q.filter(model.Citation.pmid == 0).all()
#
#print(len(citations))
#
#for c in citations:
# id = c.id
# title = c.title