本文整理匯總了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()