本文整理汇总了Python中model.Page类的典型用法代码示例。如果您正苦于以下问题:Python Page类的具体用法?Python Page怎么用?Python Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exchange
def exchange(self):
params = self.request.params
page1 = Page.get_by_id(params.get('page1'), parent=self.master_key)
page2 = Page.get_by_id(params.get('page2'), parent=self.master_key)
page1.order, page2.order = page2.order, page1.order
page1.put()
page2.put()
示例2: save
def save(self):
params = self.request.params
page = Page.get_or_create(params.get('id'), self._get_parent_key())
page.mergeProps(params)
if page.order is None:
page.order = Page.get_children_count(self.master_key)
page.put()
self.redirect(self._redirect_url(page))
示例3: delete_page
def delete_page(self, page_id):
page = Page.get_by_id(page_id, parent=self.master_key)
if page:
Page.dec_order_number(self.master_key, page.order)
page.key.delete()
self.redirect(self._redirect_url())
else:
self.error(404)
示例4: get
def get(self, page_id=''):
if page_id:
page = Page.get_by_id(page_id, parent=self.master_key)
else:
page = Page.get_first_child(self.master_key, False)
if page:
return self._get_page(page)
else:
self.redirect('/_add?type=post')
示例5: post
def post(self, pid):
try:
page = Page.get(id = pid)
except:
self.flash("此栏目不存在")
self.redirect("/admin/pages")
return
name = self.get_argument("name", None)
slug = self.get_argument("slug", None)
content = self.get_argument("content", "")
template = self.get_argument("template", "staticpage.html")
page.name = name
page.slug = slug
page.content = content
page.template = template
try:
page.validate()
page.save()
self.flash(u"栏目%s修改成功" % name)
self.redirect("/admin/pages")
return
except Exception, ex:
self.flash(str(ex))
示例6: __init__
def __init__(self):
self.structure = {}
pages = Page.find()
for page in pages:
if page.attr['title'] != 'index':
self.structure[page.attr['title']] = \
{"_type": "button", "data": {"href": '/%s' % page.attr['title']}}
示例7: get
def get(self, link):
page = Page.by_path(link)
params = {}
if self.user and page:
params = {
'name': self.user.username,
'name_ev': 'edit',
'name_lio': 'logout',
'link_ev': self.uri_for('edit', link=link),
'link_lio': self.uri_for('logout')
}
elif not self.user and page:
params = {
'name_lio': 'login',
'link_lio': self.uri_for('login')
}
else:
return self.redirect_to('edit', link=link)
self.render_response(self.template, page=page, params=params)
示例8: getPage
def getPage(self, id):
"""Return a Page object
@type id: string, or Page object
@param id: page id, or Page object
@rtype: Page"""
return Page.create(self.pm_getSpaceManager().getPage(self._unbox(id)), self._modelDataManager)
示例9: get_file
def get_file(self, file_id):
page = Page.get_by_id(file_id, parent=self.master_key)
if page and page.file_content:
self.response.headers['Content-Type'] = str(page.file_type)
self.response.write(page.file_content)
else:
self.error(404)
示例10: editPage
def editPage(self, page):
"""Update content of page
@type page: Page object
@param page: Page object having the updated content
@rtype: Page
@return: updated Page"""
return Page.create(self.pm_getSpaceManager().editPage(page.toDict()), self._modelDataManager)
示例11: findPage
def findPage(self, space, title):
"""Return a Page object
@type space: string, or Space object
@param space: space key, or Space object
@param title: the title of the page
@rtype: Page"""
return Page.create(self.pm_getSpaceManager().findPage(self._unbox(space), title), self._modelDataManager)
示例12: listPages
def listPages(self, space):
"""Return a list of available pages in this space
@type space: string, or Space Object
@param space: space key, or Space object
@rtype: Page list
@return: list of Pages contained in space"""
return tuple(Page.create(page, self._modelDataManager) for page in self.pm_getSpaceManager().listPages(self._unbox(space)))
示例13: getPageParent
def getPageParent(self,page):#get parent from its page
if page:
my_key = page.parent;
if my_key:
PID = my_key.id();
parent = Page.get_by_id(PID);
return parent;
return;
示例14: get
def get(self, pid):
try:
page = Page.get(id = pid)
except:
self.flash("此栏目不存在")
self.redirect("/admin/pages")
return
self.render('admin/editpage.html', page = page)
示例15: get
def get(self, slug):
try:
page = Page.get(slug = slug)
except:
raise HTTPError(404)
return
self.render("static/%s" % page.template, page = page)