本文整理汇总了Python中model.Document.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Document.get_by_id方法的具体用法?Python Document.get_by_id怎么用?Python Document.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Document
的用法示例。
在下文中一共展示了Document.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Document [as 别名]
# 或者: from model.Document import get_by_id [as 别名]
def get(self, docid):
user_info = get_user_info()
if user_info is None:
self.redirect("/?error_message=%s" % "login required to view docs")
docid = long(docid)
doc = Document.get_by_id(docid, parent=user_info)
if doc is None:
self.response.out.write("Docid %d not found." % (docid))
return
pages = MediaObject.get(doc.pages)
size = self.request.get("size")
if not size:
size = 1200
show_single_list = long(size) > 600
self.response.out.write(
template.render(
"doc.html",
{
"doc": doc,
"pages": pages,
"user_info": user_info,
"size": size,
"show_single_list": show_single_list,
},
debug=True,
)
)
示例2: post
# 需要导入模块: from model import Document [as 别名]
# 或者: from model.Document import get_by_id [as 别名]
def post(self):
user_info = get_user_info()
if user_info is None:
self.redirect("/?error_message=%s" % "login required to view docs")
docid = long(self.request.get("docid"))
doc = Document.get_by_id(docid, parent=user_info)
if doc is None:
self.response.out.write("Docid %d not found." % (docid))
return
mode = self.request.get("mode")
if mode == "break":
break_and_delete_doc(user_info, doc)
self.response.out.write(
"[<< <a href='/'>Back</a>] Docid %d deleted and images broken out as un-annotated." % docid
)
return
if mode == "delete":
delete_doc_and_images(user_info, doc)
self.response.out.write("[<< <a href='/'>Back</a>] Docid %d and its images deleted." % docid)
return
# Simple properties:
doc.physical_location = self.request.get("physical_location")
doc.title = self.request.get("title")
# Tags
doc.tags = [x for x in re.split("\s*,\s*", self.request.get("tags")) if x]
doc.no_tags = len(doc.tags) == 0
# Document Date
date = self.request.get("date")
if date:
doc.doc_date = datetime.datetime.strptime(date, "%Y-%m-%d")
doc.no_date = False
else:
doc.doc_date = None
doc.no_date = True
# Due date
due_date_str = self.request.get("due_date")
doc.due_date = None
if due_date_str:
doc.due_date = datetime.datetime.strptime(due_date_str, "%Y-%m-%d")
def store():
db.put(doc)
db.run_in_transaction(store)
self.redirect("/?saved_doc=" + str(docid))