schemaActions.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:cloud-memory 作者: onejgordon 项目源码 文件源码
def get(self, d):
        BATCH_SIZE = 100
        cursor = self.request.get('cursor')
        q = Question.all()
        if cursor:
            q.with_cursor(cursor)
        logging.debug("Query count: %d" % q.count())
        batch = q.fetch(BATCH_SIZE)
        identifiers = []
        if batch:
            new_cursor = q.cursor()
            next_url = '/admin/schema/do_schema?cursor=%s' % (new_cursor)

            changed = []
            for item in batch:
                edited = False
                try:
                    if item.correct_response:
                        item.correct_responses=[item.correct_response]
                        item.correct_response = None
                        edited = True
                    if edited:
                        changed.append(item)
                except Exception, e:
                    logging.error("Error: %s" % e)
                identifiers.append("Question: %s, Changed: %s" % (item.correct_responses, edited))
            db.put(changed)

            context = {
                'identifiers': identifiers,
                'next_url': next_url,
                }
            self.render_template("schema_update.html", **context)
        else:
            self.redirect("/admin")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号