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


Python models.Post方法代码示例

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


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

示例1: archive_eligible_submissions

# 需要导入模块: from app import models [as 别名]
# 或者: from app.models import Post [as 别名]
def archive_eligible_submissions(self, eligible_submissions):
        existing_post_ids = set([sub.id for sub in self.db_session.query(Post).filter(
            Post.id.in_(list(eligible_submissions.keys())))])

        # list of praw objects
        to_archive_posts = [eligible_submissions[sid] for sid in eligible_submissions if sid not in existing_post_ids]
            
        new_posts = []
        for post in to_archive_posts:
            post_info = post.json_dict if("json_dict" in dir(post)) else post['data'] ### TO HANDLE TEST FIXTURES
            new_post = Post(
                    id = post_info['id'],
                    subreddit_id = post_info['subreddit_id'].strip("t5_"), # janky
                    created = datetime.datetime.fromtimestamp(post_info['created_utc']),        
                    post_data = json.dumps(post_info))
            new_posts.append(new_post)
            #self.db_session.add(new_post)
        self.db_session.add_retryable(new_posts)
        #self.db_session.commit() 
开发者ID:mitmedialab,项目名称:CivilServant,代码行数:21,代码来源:sticky_comment_experiment_controller.py

示例2: make_shell_context

# 需要导入模块: from app import models [as 别名]
# 或者: from app.models import Post [as 别名]
def make_shell_context():
    return dict(app=app, db=db, User=User, Follow=Follow, Role=Role,
                Permission=Permission, Post=Post, Comment=Comment) 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:5,代码来源:manage.py

示例3: make_shell_context

# 需要导入模块: from app import models [as 别名]
# 或者: from app.models import Post [as 别名]
def make_shell_context():
    return dict(app=app, db=db, User=User, Role=Role, Post=Post, \
                Follow=Follow, Permission=Permission, Admin=Admin) 
开发者ID:Blackyukun,项目名称:Simpleblog,代码行数:5,代码来源:manage.py

示例4: test_index_with_posts

# 需要导入模块: from app import models [as 别名]
# 或者: from app.models import Post [as 别名]
def test_index_with_posts(self):
        with self.app.app_context():
            admin = User.get_by_email('admin@xyz.com')
            post = Post(user_id=admin.id, title='Post de prueba', content='Lorem Ipsum')
            post.save()
        res = self.client.get('/')
        self.assertEqual(200, res.status_code)
        self.assertNotIn(b'No hay entradas', res.data) 
开发者ID:j2logo,项目名称:tutorial-flask,代码行数:10,代码来源:test_blog_client.py


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