本文整理汇总了Python中models.Entry.get方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.get方法的具体用法?Python Entry.get怎么用?Python Entry.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def get(self, request, _id, *args, **kwargs):
entry = Entry.get(_id)
if not entry:
raise Http404
return render_to_response('detail.html', {
'entry': entry,
}, RequestContext(request))
示例2: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def post(self):
key = self.get_argument("key", None)
if key:
entry = Entry.get(key)
entry.title = self.get_argument("title")
entry.markdown = self.get_argument("markdown")
entry.html = markdown.markdown(self.get_argument("markdown"))
else:
title = self.get_argument("title")
slug = unicodedata.normalize("NFKD", title).encode(
"ascii", "ignore")
slug = re.sub(r"[^\w]+", " ", slug)
slug = "-".join(slug.lower().strip().split())
if not slug: slug = "entry"
while True:
existing = db.Query(Entry).filter("slug =", slug).get()
if not existing or str(existing.key()) == key:
break
slug += "-2"
entry = Entry(
author=self.current_user,
title=title,
slug=slug,
markdown=self.get_argument("markdown"),
html=markdown.markdown(self.get_argument("markdown")),
)
entry.put()
self.redirect("/entry/" + entry.slug)
示例3: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def get(self, key):
try:
entry = Entry.get(key)
entry.delete()
self.json({"success":1})
except:
self.json({"success":0, "error": "参数错误"})
示例4: remove_view
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def remove_view(entry_id):
user = Session.get_user()
if Entry.select().where(Entry.id == entry_id, Entry.user == user, Entry.is_active == True).exists():
entry = Entry.get(Entry.user == user, Entry.is_active == True)
entry.is_active = False
entry.save()
else:
abort(404)
return redirect(URLS['index'])
示例5: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def post(self):
key = self.request.get('key')
try:
e = Entry.get(key)
e.content = self.request.get('content')
e.put()
self.redirect("/")
except Exception as e:
self.response.out.write(indexTemplate.render({
'title': 'Append to Entry',
'body': "Error: No entry for key %s, exception %s" % (key, e)
}))
示例6: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def get(self, key):
e = Entry.get(key)
body = entryEditTemplate.render({
'entry_day': e.date.strftime("%A, %d %B"),
'content': e.content,
'key': e.key()
})
self.response.out.write(indexTemplate.render({
'title': 'Append to Entry',
'body': body
}))
示例7: new_view
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def new_view(parent_id=None):
user = Session.get_user()
if parent_id and Entry.select().where(Entry.id == parent_id, Entry.is_active == True).exists():
parent = Entry.get(Entry.id == parent_id, Entry.is_active == True)
else:
parent = None
title = views.form_get('title', 'no title')
body = views.form_get('body', '')
Entry.create(
user=user,
parent=parent,
title=title,
body=body,
)
return redirect(URLS['index'])
示例8: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def post(self, key):
entry = Entry.get(key)
title = self.get_argument("title", default=None)
if title is None or len(title) == 0:
self.view("admin/article-edit.html", menuIndex=1, error=u"请输入标题")
return
source = self.get_argument("cleanSource", default=" ")
html = self.get_argument("content", default=" ")
slug = self.get_argument("slug", default=" ")
date = datetime.datetime.now() + datetime.timedelta(hours=8)
entry.title = title
entry.body_source = source
entry.html = html
entry.slug = slug
entry.updated = date
entry.put()
self.dispatch(msg=u"修改成功", to=u"文章列表页", toUrl="/admin/article", seconds=2)
示例9: handle_GET
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def handle_GET(self, reactor, entry_id):
return Entry.get(entry_id, exc_class=HttpNotFound).get_dict()
示例10: handle_POST
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def handle_POST(self, reactor, entry_id):
entry = Entry.get(entry_id)
if entry.owner_id != reactor.user.id:
raise Forbidden()
entry.delete()
return ok("Delete OK")
示例11: post
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def post(self, ordinal):
e = Entry.get(self.request.get('key'))
h = Highlight(period='month', entry=e, date=date.fromordinal(int(ordinal)))
h.put()
self.redirect('/highlights')
示例12: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def get(self, key):
post = Entry.get(key)
self.view("post.html", post=post)
示例13: get
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import get [as 别名]
def get(self):
key = self.get_argument("key", None)
entry = Entry.get(key) if key else None
self.render("compose.html", entry=entry)