当前位置: 首页>>代码示例>>Python>>正文


Python Session.add方法代码示例

本文整理汇总了Python中abstrackr.model.meta.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在abstrackr.model.meta.Session的用法示例。


在下文中一共展示了Session.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _clear_this_user_locks

# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import add [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()
开发者ID:shihikoo,项目名称:abstrackr-web,代码行数:9,代码来源:account.py

示例2: create_account_handler

# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import add [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"))
开发者ID:shihikoo,项目名称:abstrackr-web,代码行数:58,代码来源:account.py

示例3: gen_token_to_reset_pwd

# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import add [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
开发者ID:shihikoo,项目名称:abstrackr-web,代码行数:19,代码来源:account.py

示例4: _set_assignment_done_status

# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import add [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()
开发者ID:shihikoo,项目名称:abstrackr-web,代码行数:8,代码来源:account.py

示例5: open

# 需要导入模块: from abstrackr.model.meta import Session [as 别名]
# 或者: from abstrackr.model.meta.Session import add [as 别名]
found = 0
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
开发者ID:jensjap,项目名称:pylons_dirty_fix,代码行数:33,代码来源:pmid_fixer.py


注:本文中的abstrackr.model.meta.Session.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。