本文整理汇总了Python中models.Page.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Page.get_by_key_name方法的具体用法?Python Page.get_by_key_name怎么用?Python Page.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Page
的用法示例。
在下文中一共展示了Page.get_by_key_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get_by_key_name [as 别名]
def post(self, **kwargs):
batch = []
blob_info = self.get_uploads('Filedata')[0]
page_id = re.sub('\/edit\/page\/','',self.request.get('folder'))
page_id = re.sub('\D*','', decrypt(page_id.decode('hex')))
header_image_url = images.get_serving_url(str(blob_info.key()))
#update uploaded file info
uploaded_file = UploadedFiles.get_by_key_name(page_id)
if not uploaded_file:
uploaded_file = UploadedFiles(key_name=page_id,blob=blob_info.key(),page_id=page_id)
batch.append(uploaded_file)
else:
blobstore.delete(uploaded_file.blob.key())
uploaded_file.blob=blob_info.key()
batch.append(uploaded_file)
#update page info
page = Page.get_by_key_name(page_id)
page.header_image_url = header_image_url
batch.append(page)
if batch:
db.put(batch)
self.response.set_status(302)
示例2: get
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get_by_key_name [as 别名]
def get(self, **kwargs):
page_id = self.request.get('page_id')
try:
page = Page.get_by_key_name(page_id)
widgets = Widget.all().filter('page =', page).filter('deleted = ', False).order('order')
except:
page=None
widgets=None
self.render("app/fb-tab.html", page=page,widgets=widgets, method="get")
示例3: get
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get_by_key_name [as 别名]
def get(self, pagename):
page = Page.get_by_key_name(pagename)
if page:
self.render_secure("page.html", page=page)
else:
self.redirect('/_edit' + pagename)