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


Python Entry.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [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)
开发者ID:footlooze,项目名称:Kowloon-Ice-House,代码行数:30,代码来源:main.py

示例2: get

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

        feed_id, feed_url = self.request.get('feed_id'), \
                self.request.get('feed_url')

        url_result = urllib2.urlopen(feed_url)
        feed_result = fd.parse(url_result)

        if feed_result.bozo == 1:
            logging.error('fetch error, id: %s, url: %s, error: %s', 
                    feed_id, feed_url, feed_result.bozo_exception)
            return

        feed_update_time = feed_result.get('updated', datetime.utcnow)
        has_update = True 

        f = Feed.get_by_id(int(feed_id))
        if f.is_allow_fetch(feed_update_time):
            for entry in feed_result.entries:
                if entry.published_parsed <= f.lastedPublishedTime:
                    logging.info('no updated, id: %s, url: %s', feed_id,
                            feed_url)
                    has_update = False
                    break

                e = Entry(title = entry.title,
                          url = entry.link,
                          author = entry.author,
                          content = entry.content),
                          publishedTime = entry.published_parsed)
                e.put()
                logging.debug('fetch entry, url: %s', entry.link)
开发者ID:tonychi,项目名称:readLater,代码行数:34,代码来源:work.py

示例3: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
  def post(self):
    enforce_key(self)

    rawEntries = self.request.get("entries")
    entries = json.loads(rawEntries)

    for e in Entry.all():
      e.delete()

    for e in entries:
      newEntry = Entry()
      newEntry.from_json(e)
      newEntry.put()

    rawTodos = self.request.get("todos")
    todos = json.loads(rawTodos)

    for t in ToDo.all():
      t.delete()

    for t in todos:
      newToDo = ToDo()
      newToDo.from_json(t)
      newToDo.put()

    self.response.out.write("Backup successfuly restored.")
开发者ID:Mononofu,项目名称:infinite-diary,代码行数:28,代码来源:backup.py

示例4: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
    def post(self):
        title = self.get_argument("title", default=None)
        if title is None or len(title) == 0:
            self.view("admin/article-new.html", menuIndex=1, error=u"请输入标题")
            return
        
        email = self.get_current_user()
        user = User.gql("WHERE email = :1", email).get()

        source = self.get_argument("cleanSource", default=" ")
        html = self.get_argument("content", default=" ")
        slug = " "
        if source != " ":
            slug = source.replace("\r\n", " ").replace("\t", "  ")[0:200]

        date = datetime.datetime.now() + datetime.timedelta(hours=8)

        entry = Entry(author=user.key(),
            slug=slug, 
            title=title, 
            html=html, 
            body_source=source,
            published=date,
            updated=date)
        try:
            entry.put()
            self.dispatch(msg=u"创建成功", to=u"文章列表页", toUrl="/admin/article", seconds=2)
        except:
            self.view("admin/article-new.html", menuIndex=1, error=u"创建失败")
开发者ID:youngpay,项目名称:myblog,代码行数:31,代码来源:admin.py

示例5: _create_or_edit

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
 def _create_or_edit(self, entry_key, status):
     title, slug, markdown, author, kind_name, reference = self.get_argument('title'), \
         self.get_argument('slug', ''), \
         self.get_argument('content', strip=False), \
         self.get_argument('author', None), \
         self.get_argument('kind_name', None), \
         self.get_argument('reference', None)
     # Check title and markdown is empty.
     if not (title and markdown):
         raise SaveException('标题或者内容为空!')
     if not slug:
         slug = title
     slug = Entry.check_slug(slug, entry_key)
     if slug==None:
         raise SlugException('该 Slug 已经存在!')
     now = get_now()
     if entry_key:
         entry = db.get(entry_key)
         if entry.entry_kind.name != 'blog':
             if not author:
                 raise Exception('作者未知!')
             entry.author = author
         entry.title = title
         entry.slug = slug
         entry.markdown = markdown
         entry.html = Entry.convert(markdown)
         entry.abstract = self._process_abstract(markdown)
         if entry.status == 'draft':
             entry.published = now
         else:
             entry.updated = now
         entry.status = status
     else:
         if kind_name not in KINDS:
             raise Exception('非法类型文章!')
         if kind_name == 'blog':
             author = self.current_user.nickname()
         if not author:
             raise Exception('作者未知!')
         entry = Entry(
             entry_kind = KINDS.get(kind_name),
             author = author or self.current_user.nickname(),
             reference = reference,
             title = title,
             slug = slug,
             markdown = markdown,
             html = Entry.convert(markdown),
             abstract = self._process_abstract(markdown),
             status = status,
             published = now
         )
     entry.put()
     return entry
开发者ID:mrwlwan,项目名称:workspace2014,代码行数:55,代码来源:main.py

示例6: home

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
def home():
    if request.method == 'GET':
        profile = Profile.get_or_create(users.get_current_user())
        edit = request.query_string == 'edit'
        return jinja.get_template('home.html').render(locals())

    elif request.method == 'POST':
        profile = Profile.get_or_create(users.get_current_user())
        if request.query_string == 'edit':
            e = profile.entry_today
            e.body = request.form.get('body')
        else:
            e = Entry(body=request.form.get('body'))
        e.put()
        return redirect(request.path)
开发者ID:progrium,项目名称:workjournal,代码行数:17,代码来源:main.py

示例7: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [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

示例8: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [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

示例9: handle_entry

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [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

示例10: POST

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
	def POST(self, name):
		if name == 'entry':
			entity = Entry()
			title = 'New Blog Entry'
			mce_elms = 'content'
		elif name == 'category':
			entity = Category()
			title = 'New Blog Category'
			mce_elms = []
		else:
			raise web.badrequest()

		form = create_form(entity)
			
		if not form.validates():
			return render.form(title=title,mce_elms=mce_elms,form=form)
		else:
			entity = consume_form(entity, form.d)
			entity.put()
			raise web.seeother('/admin/list/%s' % name) 
开发者ID:sw00,项目名称:rigmarolesoup,代码行数:22,代码来源:admin.py

示例11: autosave

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
def autosave(handler, route, params):
    title = params.get("title", "")
    content = params.get("content", "")
    key = params.get("key", None)
    user = handler.session.get("account", False)
    if not title or not content:
        return {"saved": False}
    if not user:
        return {"account": False, "saved": False}
    if key:
        draft = Entry.get_by_key_name(key)
        if str(draft._author) != user:
            raise Exception("You are not this article's author")
    else:
        key = str(time.time()).replace(".", "")
        draft = Entry(key_name=key, author=db.Key(user))
    draft.title = title
    draft.content = content
    draft.put()
    return {"saved": key, "time": draft.isodate}
开发者ID:michael-gillette,项目名称:GaeMVC,代码行数:22,代码来源:writer.py

示例12: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
 def post(self):
     # try:
     # blob_info = self.get_uploads('file')[0]
     entry = Entry()
     entry.filename = self.request.POST['file'].filename
     entry.file = self.request.POST['file'].file.read()
     mime_type = mimetypes.guess_type(entry.filename)[0]
     if mime_type is None:
         entry.content_type = "application/octet-stream"
     else:
         entry.content_type = mime_type
     entry.etag = str(uuid.uuid4().hex)
     # entry.content_type =
     # entry.file = blob_info.key()
     # entry.filename = blob_info.filename
     # entry.content_type = blob_info.content_type
     # entry.size = blob_info.size
     # try:
     #     entry.pic_url = images.get_serving_url(blob_info.key())
     # except:
     #     entry.pic_url = None
     entry.put()
     return self.redirect('/')
开发者ID:liantian-cn,项目名称:StaticGAE,代码行数:25,代码来源:views.py

示例13: post

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
    def post(self, request, *args,  **kwargs):
        data = json.loads(request.raw_post_data)
        error_msg = ""
        for field in ('title', 'body_markdown'):
            if field not in data or not data[field]:
                error_msg += field + " " 
        if error_msg:
            error_msg = " and ".join(error_msg.split())
            status = 422
            content = create_error_message("%s missing" %error_msg, status)

            return self.render_to_response(content, status=status)
            
        entry = Entry(
            title=data['title'],
            body_markdown=data['body_markdown'],
            body_html=markdown.markdown(data['body_markdown'])
        )
        e = entry.put()
        content = entry.to_dict()
        return self.render_to_response(content)
开发者ID:michaelBenin,项目名称:django-backbone-blog,代码行数:23,代码来源:views.py

示例14: DummyEntryInsert

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import put [as 别名]
 def DummyEntryInsert(self):
     e = Entry(title="First Entry", body_html="body_html", body_markdown="body_markdown")
     e.put()
     self.assertEqual(1, db.Query(Entry).count())
开发者ID:thikonom,项目名称:django-backbone-blog,代码行数:6,代码来源:tests.py


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