本文整理汇总了Python中models.Page.picture方法的典型用法代码示例。如果您正苦于以下问题:Python Page.picture方法的具体用法?Python Page.picture怎么用?Python Page.picture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Page
的用法示例。
在下文中一共展示了Page.picture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import picture [as 别名]
def get(self, **kwargs):
'''Get Users Pages From Facebook'''
try:
fb_users_pages = self.graph.get_connections("me", "accounts")
fb_page_ids = []
for p in fb_users_pages['data']:
#if p['category'] != 'Application' or p['id'] == '141947329155355':
try:
if p['name']:
fb_page_ids.append(p["id"])
except:
pass
fb_pages = self.graph.get_objects(fb_page_ids)
'''Update Pages Cache'''
batch = []
for k,fb_page in fb_pages.items():
try:
picture = fb_page["picture"]
except KeyError:
picture = None
try:
fan_count = fb_page["fan_count"]
except KeyError:
fan_count = None
try:
has_added_app = fb_page["has_added_app"]
except KeyError:
has_added_app = None
try:
category = fb_page["category"]
except KeyError:
category = None
page = Page.get_by_key_name(fb_page["id"])
if not page:
page = Page(key_name=str(fb_page["id"]),
id=str(fb_page["id"]),
name=fb_page["name"],
link=fb_page["link"],
category=category,
picture=picture,
fan_count=str(fan_count),
has_added_app=has_added_app
)
batch.append(page)
else:
page.picture = picture
page.fan_count=str(fan_count)
page.has_added_app = has_added_app
batch.append(page)
if batch:
page_keys = db.put(batch)
user = self.current_user
user.pages = page_keys
db.put(user)
except:
pass
"""Get Users Pages"""
try:
user = self.current_user
pages = Page.get(user.pages)
self.render("app/dashboard.html", admin=True,pages=pages)
except:
pass