當前位置: 首頁>>代碼示例>>Python>>正文


Python Entry.put方法代碼示例

本文整理匯總了Python中blog.models.Entry.put方法的典型用法代碼示例。如果您正苦於以下問題:Python Entry.put方法的具體用法?Python Entry.put怎麽用?Python Entry.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在blog.models.Entry的用法示例。


在下文中一共展示了Entry.put方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create

# 需要導入模塊: from blog.models import Entry [as 別名]
# 或者: from blog.models.Entry import put [as 別名]
def create(request):
	if request.is_ajax():
		e = Entry(title=request.POST['title'],
				  body=request.POST['editor_data'],
				  author = users.get_current_user())
		e.put()
		return archive_index(request)
	else:
		return render_to_response('blog/create.html')
開發者ID:rmalik,項目名稱:dspillini,代碼行數:11,代碼來源:views.py

示例2: create

# 需要導入模塊: from blog.models import Entry [as 別名]
# 或者: from blog.models.Entry import put [as 別名]
	def create(self, form):
		entry = Entry(parent=Service.to_key(form.category.data))
		entry.title = form.title.data
		entry.summary = form.summary.data
		entry.post = form.post.data
		entry.tags = [Key(urlsafe=tag) for tag in form.tags.data]
		entry.slug = Service.slugify(entry.title)
		# entry.user = users.get_current_user()
		return entry.put()
開發者ID:stretchhog,項目名稱:stretchhog,代碼行數:11,代碼來源:entry_service.py

示例3: post

# 需要導入模塊: from blog.models import Entry [as 別名]
# 或者: from blog.models.Entry import put [as 別名]
    def post(self):
        self.response.out.write('<html><body>You wrote:<pre>')
        key = self.request.get('id_key')
        title = self.request.get('title')
        slug = str(slugify(title))
        item_type = self.request.get('item_type')
        tag_list = None


        if item_type == "entry":
            content = self.request.get('content')
            genre = self.request.get('genre')
            enable_comments = self.request.get('enable_comments')
            country = self.request.get('country')
            core_topic = self.request.get('core_topic')
            tags = self.request.get('tags')
            private = self.request.get('private')
            publish_date = self.request.get('publish_date')
 
            if publish_date:
                publish_date = datetime.strptime(publish_date, '%Y-%m-%d').date()
            else:
                publish_date = datetime.today().date()
                
            if genre == "blog":
                country_obj = Country.get(country)
            else:
                country_obj = None

            if key:
                entry = Entry.get(key)
            else:
                entry = Entry()
            entry.title = title
            entry.slug = slug
            entry.content = content
            entry.genre = genre
            entry.country = country_obj
            entry.publish_date = publish_date
            if len(core_topic):
                entry.core_topic = core_topic
            if private == "on":
                b = bool("1")
            else:
                b = bool("")
            entry.private = b
            entry.put()

            if len(tags) > 0:
                tag_list = shlex.split(str(tags))
                if tag_list:
                  for tag in tag_list:
                      tag_obj = Tag.get_or_insert(str(tag))
                      if tag_obj.name == None:
                          tag_obj.name = str(tag)
                          tag_obj.put()
                      entry.tags.append(tag_obj.key())
                  entry.put()
        else:
            map_url = self.request.get('map_url')
            if key:
                country = Country.get(key)
            else:
                country = Country()
            country.title = title
            country.slug = slug
            country.map_url = map_url
            country.put()

        self.response.out.write(str("Key: %s<br />" % key))
        self.response.out.write(str("Title: %s<br />" % title))
        self.response.out.write(str("Slug: %s<br />" % slug))
        self.response.out.write(str("Type: %s<br />" % item_type))
        if tag_list:
          self.response.out.write(str("Tags: %s<br />" % tags))
       
        self.response.out.write('</pre></body></html>')
開發者ID:kelvinn,項目名稱:gae-demo-blog,代碼行數:79,代碼來源:admin.py


注:本文中的blog.models.Entry.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。