本文整理汇总了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()
示例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)
示例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)
示例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)