当前位置: 首页>>代码示例>>Python>>正文


Python Note.owner_query方法代码示例

本文整理汇总了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)
开发者ID:sky5497,项目名称:vantansy,代码行数:11,代码来源:main.py

示例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)
开发者ID:PacktPublishing,项目名称:Python-for-Google-App-Engine,代码行数:16,代码来源:main.py

示例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))
开发者ID:TetsuoS,项目名称:pythonforgae,代码行数:16,代码来源:main.py

示例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)
开发者ID:PacktPublishing,项目名称:Python-for-Google-App-Engine,代码行数:17,代码来源:main.py

示例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)
开发者ID:PacktPublishing,项目名称:Python-for-Google-App-Engine,代码行数:19,代码来源:main.py

示例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)
开发者ID:vishalsanfran,项目名称:gcloud-apps,代码行数:20,代码来源:main.py


注:本文中的models.Note.owner_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。