本文整理汇总了Python中model.Page.title方法的典型用法代码示例。如果您正苦于以下问题:Python Page.title方法的具体用法?Python Page.title怎么用?Python Page.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Page
的用法示例。
在下文中一共展示了Page.title方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from model import Page [as 别名]
# 或者: from model.Page import title [as 别名]
def save():
try:
add = False
title = request.form['title']
content = request.form['content']
slug = request.form['slug']
if 'id' in request.form:
page = Page.query.get(request.form['id'])
cache.delete('view-page-%s' % slug) #Remove this page from cache for update in next view
else:
add = True
page = Page()
page.date_created = datetime.today()
page.title = title
page.content = content
page.slug = slug
page.date_updated = datetime.today()
if add:
db.session.add(page)
db.session.commit()
data = {}
data['message'] = "Página salva com sucesso! <a href='%s'>Visualizar</a>" % url_for('pages.view', slug=slug)
data['id'] = page.id
return jsonify(data)
except IntegrityError as e:
db.session.rollback()
data = {}
data['message'] = "O Slug informado ja existe. Altere e tente novamente."
return jsonify(data)
except:
db.session.rollback()
print "Unexpected error:", sys.exc_info()[0]
raise
示例2: SQLAlchemy
# 需要导入模块: from model import Page [as 别名]
# 或者: from model.Page import title [as 别名]
from flask_sqlalchemy import SQLAlchemy
from model import Page, User, Role, Image
from setting import app
db = SQLAlchemy(app)
# db.drop_all()
# db.create_all()
page = Page()
x=page.query.filter_by(title='homepage').first()
if x is None:
page.title='homepage'
page.contents='<h1> Selamat datang di dunia python </h1>'
page.is_homepage=True
db.session.add(page)
db.session.commit()
# x1=page.query.filter_by(title='Hallo Dunia').first()
# if x1 is None:
# page.title='Hallo Dunia'
# page.contents='<h1> Hallo Dunia ? apa kabar... </h1>'
# page.is_homepage=False
# page.url='page/hallo-dunia'
# page.image_id=1
# db.session.add(page)
# db.session.commit()
gbr=Image()