本文整理汇总了Python中zkpylons.model.DbContent类的典型用法代码示例。如果您正苦于以下问题:Python DbContent类的具体用法?Python DbContent怎么用?Python DbContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DbContent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _delete
def _delete(self, id):
c.db_content = DbContent.find_by_id(id)
meta.Session.delete(c.db_content)
meta.Session.commit()
h.flash("Content Deleted.")
redirect_to('index')
示例2: list_press
def list_press(self):
if c.db_content_types:
page = request.GET.get('page', 1)
pagination = paginate.Page(DbContent.find_all_by_type("In the press"), page = page, items_per_page = 10)
c.db_content_pages = pagination
c.db_content_collection = pagination.items
c.result = True
else:
c.result = False
return render('/db_content/list_press.mako')
示例3: list_news
def list_news(self):
if c.db_content_types:
page = 1
if request.GET.has_key('page'):
page = request.GET['page']
pagination = paginate.Page(DbContent.find_all_by_type("News"), page = page, items_per_page = 10)
c.db_content_pages = pagination
c.db_content_collection = pagination.items
c.result = True
else:
c.result = False
return render('/db_content/list_news.mako')
示例4: edit
def edit(self, id):
c.db_content = DbContent.find_by_id(id)
defaults = h.object_to_defaults(c.db_content, 'db_content')
# This is horrible, don't know a better way to do it
if c.db_content.type:
defaults['db_content.type'] = defaults['db_content.type_id']
defaults['db_content.publish_date'] = c.db_content.publish_timestamp.strftime('%d/%m/%y')
defaults['db_content.publish_time'] = c.db_content.publish_timestamp.strftime('%H:%M:%S')
form = render('/db_content/edit.mako')
return htmlfill.render(form, defaults)
示例5: view
def view(self, id):
c.db_content = DbContent.find_by_id(id)
if c.db_content.publish_timestamp > datetime.now() and not h.auth.authorized(h.auth.has_organiser_role):
c.db_content = None
return NotFoundController().view()
elif c.db_content.publish_timestamp > datetime.now():
h.flash(("This content is marked to be published on %s and will not be visiable to public until then." % c.db_content.publish_timestamp), 'Warning')
if c.db_content.type.name == 'Redirect':
redirect_to(c.db_content.body.encode("latin1"), _code=301)
c.html_headers, c.html_body, c.menu_contents = self.parse_dbpage(
c.db_content.body)
return render('/db_content/view.mako')
示例6: _edit
def _edit(self, id):
c.db_content = DbContent.find_by_id(id)
for key in self.form_result['db_content']:
if ( not key in ['publish_date', 'publish_time'] ):
setattr(c.db_content, key, self.form_result['db_content'][key])
if self.form_result['db_content']['publish_time'] is None:
self.form_result['db_content']['publish_time'] = datetime.time(datetime.now())
if self.form_result['db_content']['publish_date'] is not None:
c.db_content.publish_timestamp = \
datetime.combine(self.form_result['db_content']['publish_date'], \
self.form_result['db_content']['publish_time'])
else:
c.db_content.publish_timestamp = datetime.now()
# update the objects with the validated form data
meta.Session.commit()
h.flash("Page updated.")
redirect_to(action='view', id=id)
示例7: index
def index(self):
c.db_content_collection = DbContent.find_all()
return render('/db_content/list.mako')
示例8: delete
def delete(self, id):
c.db_content = DbContent.find_by_id(id)
return render('/db_content/confirm_delete.mako')
示例9: page
def page(self):
url = h.url_for().strip("/")
c.db_content = DbContent.find_by_url(url, abort_404=False)
if c.db_content is not None:
return self.view(c.db_content.id)
return NotFoundController().view()