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


Python Entry.key方法代码示例

本文整理汇总了Python中models.Entry.key方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.key方法的具体用法?Python Entry.key怎么用?Python Entry.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Entry的用法示例。


在下文中一共展示了Entry.key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import key [as 别名]
    def post(self):
        """
        /api/item, POST, create item 
        表单字段: url, author, title, content
        """

        p = Entry()
        p.url = self.request.get('tUrl')
        p.author = self.request.get('tAuthor')
        p.title = self.request.get('tTitle')
        p.content = self.request.get('tContent')
        p.tags = self.request.get('tTags').split(',')
        p.put(); # save

        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write('{ "success":true, "id":%s }' % p.key().id())
开发者ID:tonychi,项目名称:readLater,代码行数:18,代码来源:api.py

示例2: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import key [as 别名]
    def post(self):
        #表单字段: url, author, title, content, allow_sendto_kindle
        bSendIt = self.request.get('bSendIt')

        p = Entry()
        p.url = self.request.get('tUrl')
        p.author = self.request.get('tAuthor')
        p.title = self.request.get('tTitle')
        p.content = self.request.get('tContent')
        p.tags = self.request.get('tTags').split(',')
        p.put(); # save

        #send to kindle
        if bSendIt: 
            common.add_task_sendmail(p.key().id());

        return self.redirect('/list/1')
开发者ID:tonychi,项目名称:readLater,代码行数:19,代码来源:main.py

示例3: handle_entry

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import key [as 别名]
  def handle_entry(self, message):

    entry = Entry(author='Julian')
    raw, entry.content = self.get_content(message)

    if entry.content is None:
      logging.error("Failed to find message body")
      logging.error(message)
      return

    matches = re.search("diaryentry(\d+)", raw)
    if matches is None:
      logging.error("received mail that wasn't a diary entry")
      logging.error(raw)
      return

    entry.date = datetime.date.fromtimestamp(int(matches.group(1)))
    entry.put()

    num_attachments = 0

    # fall back to raw mail message for attachment parsing
    for part in message.original.walk():
      content_type = part.get_content_type()
      if content_type not in ["text/plain", "text/html", "multipart/mixed",
                              "multipart/alternative"]:
        attachment = Attachment(name=part.get_param("name"),
                                content_type=content_type)

        # store attachment in blobstore
        bucket = '/infinite-diary.appspot.com'
        filename = os.path.join(bucket, 'attachments',
                                time.strftime('%Y-%m-%d_%H-%M'),
                                str(num_attachments))

        with gcs.open(filename, 'w') as f:
          f.write(base64.b64decode(part.get_payload()))

        attachment.content = blobstore.create_gs_key('/gs' + filename)
        attachment.entry = entry.key()
        attachment.thumbnail = images.get_serving_url(attachment.content,
                                                      size=400)

        attachment.put()
        num_attachments += 1
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:47,代码来源:mail.py


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