當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。