本文整理汇总了Python中models.Note.owner_query方法的典型用法代码示例。如果您正苦于以下问题:Python Note.owner_query方法的具体用法?Python Note.owner_query怎么用?Python Note.owner_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Note
的用法示例。
在下文中一共展示了Note.owner_query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _render_template
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import owner_query [as 别名]
def _render_template(self,template_name,context=None):
if context is None:
context = {}
user = users.get_current_user()
ancestor_key = ndb.key("User",user.nickname())
qry = Note.owner_query(ancestor_key)
context["notes"] = qry.fetch()
template = jinja_env.get_template(template_name)
return template.render(context)
示例2: post
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import owner_query [as 别名]
def post(self):
if not 'X-AppEngine-TaskName' in self.request.headers:
self.error(403)
user_email = self.request.get('user_email')
user = users.User(user_email)
ancestor_key = ndb.Key("User", user.nickname())
notes = Note.owner_query(ancestor_key).map(self._shrink_note, projection=[Note.files])
sender_address = "Notes Team <[email protected]>"
subject = "Shrink complete!"
body = "We shrunk {} images attached to your notes!".format(len(notes))
mail.send_mail(sender_address, user_email, subject, body)
示例3: _render_template
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import owner_query [as 别名]
def _render_template(self, template_name, context=None):
if context is None:
context = {}
user = users.get_current_user()
ancestor_key = ndb.Key("User", user.nickname())
qry = Note.owner_query(ancestor_key)
context['notes'] = qry.fetch()
template = jinja_env,get_template(template_name)
return template.render(context)
self.response.out.write(self._render_template('main.html', template_context))
示例4: _render_template
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import owner_query [as 别名]
def _render_template(self, template_name, context=None):
if context is None:
context = {}
user = users.get_current_user()
ancestor_key = ndb.Key("User", user.nickname())
qry = Note.owner_query(ancestor_key)
future = qry.fetch_async()
template = jinja_env.get_template(template_name)
context['notes'] = future.get_result()
context['note_count'] = get_note_counter()
return template.render(context)
示例5: post
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import owner_query [as 别名]
def post(self):
if not 'X-AppEngine-TaskName' in self.request.headers:
self.error(403)
user_email = self.request.get('user_email')
user = users.User(user_email)
ancestor_key = ndb.Key("User", user.nickname())
notes = Note.owner_query(ancestor_key).fetch()
for note in notes:
self._shrink_note(note)
sender_address = "Notes Team <[email protected]>"
subject = "Shrink complete!"
body = "We shrunk all the images attached to your notes!"
mail.send_mail(sender_address, user_email, subject, body)
示例6: post
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import owner_query [as 别名]
def post(self):
# otherwise task queue request is not received
if not 'X-Appengine-Taskname' in self.request.headers:
self.error(403) # Forbidden
user_email = self.request.get('user_email')
user = users.User(user_email)
ancestor_key = ndb.Key("User", user.nickname())
notes = Note.owner_query(ancestor_key).fetch()
for note in notes:
self._shrink_note(note)
# compose, send a mail
sender_address = "Notes team <[email protected]>"
subject = "Shrink complete"
body = "All images attached to your notes have been shrunk"
mail.send_mail(sender_address, user_email, subject, body)