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


Python Entry.all方法代码示例

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


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

示例1: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def get(self, page_slug=""):
        if page_slug:
            t_values = {}

            posts = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').filter("slug =", page_slug)
            if posts.count() == 1:
                logging.warning("find one page with slug=%s" % (page_slug))
                posts = posts.fetch(limit=1)
                post = posts[0]
                t_values['post'] = post
                # dump(post)

                # find all comments
                comments = Comment.all().filter("entry =", post).order("date")
                t_values['comments'] = comments
            else:
                logging.warning("%d entries share the same slug %s" % (posts.count(), page_slug))

            links = Link.all().order("date")
            t_values['links'] = links

            categories = Category.all()
            t_values['categories'] = categories

            pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
            t_values['pages'] = pages

            return self.response.out.write(render_template("page.html", t_values, "basic", False))
        else:
            self.redirect(uri_for("weblog.index"))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:32,代码来源:weblog.py

示例2: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def get(self):
        # find stats for this blog
        stats = {}
        stats['posts'] = Entry.all().filter("entrytype =", "post").filter("is_external_page =", True).count()
        stats['pages'] = Entry.all().filter("entrytype =", "page").filter("is_external_page =", True).count()
        stats['comments'] = Comment.all().count()
        stats['categories'] = Category.all().count()
        stats['links'] = Link.all().count()

        t_values = {}
        t_values['stats'] = stats
        return self.response.out.write(render_template("index.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:14,代码来源:admin.py

示例3: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def get(self, user, tag_title):
        """Gets RSS feed for a user, filtered by tag"""
        user = utils.get_user_model_by_id_or_nick(user)
        
        if not user:
            self.error(403)
            return
            
        tag_title = tag_title.decode('utf-8')
        tag = Tag.all().ancestor(user.key()).filter('title_lower =', tag_title.lower()).get()

        if not tag:
            self.error(404)
            return

        entries = Entry.all().filter('tags =', tag.key()).filter('published =', True).order('-time_published').fetch(20)
        entries = [e.to_struct() for e in entries]
            
        path = os.path.join(os.path.dirname(__file__), 'template.rss')
        self.response.headers['Content-Type'] = 'application/xml; charset=utf-8'
        self.response.out.write(template.render(path, {
            'entries': entries,
            'url': self.request.url,
            'title': tag_title,
        }))
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:27,代码来源:rss.py

示例4: delete

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def delete(self, title):
        """Delete the specified tag for the current user"""
        user = utils.get_current_user()
        
        title = title.decode('utf-8')
        
        if not user:
            self.error(403)
            return
            
        m = Tag.all().ancestor(user).filter('title_lower =', title.lower()).get()
        if not m:
            # Original tag not found
            self.error(404)
            return

        entries = Entry.all().filter('tags =', m.key())

        # Remove tag from entries
        for entry in entries:
            logging.info(entry)
            entry.tags.remove(m.key())
            entry.save()
        
        m.delete()

        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        self.response.out.write('ok')
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:31,代码来源:tags.py

示例5: getTagsForUrl

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
def getTagsForUrl(url):
    try:
        content = resource.get(url).decodeBody().lower()
    except:
        content = ""
    
    soup = BeautifulSoup(content) 
    texts = soup.findAll(text=True)

    def visible(element):
        if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
            return False
        elif re.match('<!--.*-->', str(element)):
            return False
        return True
    
    visible_texts = filter(visible, texts)
    visibleText = " ".join(visible_texts)
    
    result = getTagsProposalsForText(visibleText)
    
    entry = Entry.all().filter("url =", url).fetch(1)
    if len(entry) > 0:
        entryStableTags = entry[0].tags
        for t in entryStableTags:
            found = False
            name = Tag.get(t).name
            for r in result:
                if name == r:
                    found = True
            if not found:
                result.append(name)
                
    return result
开发者ID:outbounder,项目名称:api-techbrowser,代码行数:36,代码来源:tags.py

示例6: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
  def get(self):
    context = {}
    query = Entry.all().order("-updated")
    next = self.request.get("next")
    if next:
      dt = datetime.strptime(next, "%Y-%m-%dT%H:%M:%S")
      entries = query.filter("updated <=",
	  dt).fetch(PAGESIZE + 1)
      if len(entries) == PAGESIZE + 1:
	context["next"] = entries[-1].updated.isoformat("T")
      else:
	context["next"] = None
      context["entries"] = entries[:PAGESIZE]
      self.response.out.write(self.render_sec_entries(context))
      return
    else:
      sec = {}
      entries = query.fetch(PAGESIZE + 1)
      if len(entries) == PAGESIZE + 1:
	context["next"] = entries[-1].updated.isoformat("T")
      else:
	context["next"] = None
      context["entries"] = entries[:PAGESIZE]
      sec["entries"] = self.render_sec_entries(context)

      sec["featured"] = self.render_sec_featured()
      path = templatepath("main.html")
      self.response.out.write(template.render(path, sec))
开发者ID:juvenn,项目名称:microupdater,代码行数:30,代码来源:main.py

示例7: update_basic_info

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
	def update_basic_info(
		update_categories=False,
		update_tags=False,
		update_links=False,
		update_comments=False,
		update_archives=False,
		update_pages=False):

		from model import Entry,Archive,Comment,Category,Tag,Link
		basic_info = ObjCache.get(is_basicinfo=True)
		if basic_info is not None:
			info = ObjCache.get_cache_value(basic_info.cache_key)
			if update_pages:
				info['menu_pages'] = Entry.all().filter('entrytype =','page')\
							.filter('published =',True)\
							.filter('entry_parent =',0)\
							.order('menu_order').fetch(limit=1000)
			if update_archives:
				info['archives'] = Archive.all().order('-year').order('-month').fetch(12)
			if update_comments:
				info['recent_comments'] = Comment.all().order('-date').fetch(5)
			if update_links:
				info['blogroll'] = Link.all().filter('linktype =','blogroll').fetch(limit=1000)
			if update_tags:
				info['alltags'] = Tag.all().order('-tagcount').fetch(limit=100)
			if update_categories:
				info['categories'] = Category.all().fetch(limit=1000)

			logging.debug('basic_info updated')
			basic_info.update(info)
开发者ID:fly2014,项目名称:XBLOG,代码行数:32,代码来源:cache.py

示例8: post

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def post(self):
        # add new post or edit existed post
        t_values = {}
        current_post_id = self.request.POST["current_post_id"]
        post_title = self.request.POST["blog_title"]
        post_slug = get_safe_slug(self.request.POST["blog_slug"])
        post_content = self.request.POST["blog_content"]
        # find category
        blog_category_id = self.request.POST["blog_category_id"]
        post_category = Category.get_by_id(long(blog_category_id))
        if post_category:
            logging.info("find category %s for id %s" % (post_category.name, blog_category_id))
        else:
            logging.error("category id %s can't be located" % (blog_category_id))

        if current_post_id:
            logging.info("PostManager: post : edit post current_post_id = %s" % (current_post_id))
            # update existed post
            post = Entry.get_by_id(long(current_post_id))
            if post:
                t_values['alert_message'] = "Post %s has been updated!" % (post.title)
                post.title = post_title
                post.slug = post_slug
                post.content = post_content
                post.entrytype = "post"
                # update category count if this post is public
                if post.is_external_page and post.category != post_category:
                    if post.category and (post.category.entrycount > 0):
                        post.category.entrycount -= 1
                        post.category.put()
                    post_category.entrycount += 1
                    post.category.put()
                post.category = post_category
                post.put()
        else:
            logging.info("PostManager: post : new post title %s" % (self.request.POST['blog_title']))
            # create new post
            post = Entry()
            post.title = post_title
            post.slug = post_slug
            post.content = post_content
            post.entrytype = 'post'
            post.category = post_category
            # save as public or private?
            operation = self.request.POST["submit_action"]
            if operation == "save_publish":
                post.is_external_page = True
                # update category count
                post.category.entrycount += 1
                post.category.put()
            else:  # "save" operation
                post.is_external_page = False
            # save the post
            post.put()
            t_values['alert_message'] = "Post %s has been created!" % (post.title)

        # show all posts
        posts = Entry.all().filter("entrytype =", 'post')
        t_values['posts'] = posts
        return self.response.out.write(render_template("posts.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:62,代码来源:admin.py

示例9: EntryHandler_postTest

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
 def EntryHandler_postTest(self):
     weight = 75.0
     variance = 1.4
     currDate = "2012-10-10"
     currDt =dt.date(2012, 10, 10)
     nick= users.get_current_user().nickname()
     head = {"Content-Type" : "application/x-www-form-urlencoded", "Accept" : "text/plain"}
     payload = urlencode({"date" : currDate, "variance" : float(variance),"weight":float(weight)})
     #request = requests.Request("POST","/users/%s/"%nick, data=payload)
     request = webapp2.Request.blank('/users/%s/entry/%s'%(nick,currDate))
     request.method="POST"
     request.headers=head
     request.body=payload
     currUser=users.get_current_user()
     response = webapp2.Response()
     handler = EntryHandler()
     handler.initialize(request, response)
     handler.post(user=None,cd=None)
     self.setCurrentUser("[email protected]", "aaaaaaa")
     userId=users.get_current_user().user_id()
     db.delete(Entry.all())
     nick=users.get_current_user().nickname()
     handler.post(user=nick,cd='2012-10-10')
     Entry(weight=100.0, variance=5.0,date=currDt,user=currUser, parent=log_key(userId)).put()
     handler.post(user=nick,cd='2012-10-10')
     db.delete(Biometric.all())
     Biometric(height=150, target=73.3, parent=bio_key(currUser.user_id())).put()
     handler.post(user=nick,cd='2012-10-10')
     #Put Test
     handler.put(user=nick,cd='2012-10-10')
     handler.put(user=nick,cd='2012-10-15')
     handler.delete(user=nick,cd='2012-10-10')
开发者ID:acantatore,项目名称:Chompanion,代码行数:34,代码来源:SUT_Chompanion.py

示例10: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
	def get (self):
		offset = self.request.get('offset')
		if not offset:
			offset = 0
		e = Entry.all().order('addtime')
		e = e.fetch(10,int(offset))
		path = os.path.join(os.path.dirname(__file__),'templates/export.tpl')
		self.response.out.write(template.render(path,{'e':e}))	
开发者ID:zerofault-cn,项目名称:zerofault,代码行数:10,代码来源:dump.py

示例11: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
	def get(self,req_user=''):
		user_lang = 'en'
		#********************** User Auth **************************#
		user = users.get_current_user()
		nickname = ''
		if user:
			nickname=user.nickname()
		if nickname:
			user_info = User.all().filter('user',nickname)
			if user_info.count(1)>0:
				user_info = user_info.get()
				user_lang = user_info.lang
			auth_url = users.create_logout_url(self.request.uri)
			auth_text= 'signout'
		else:
			auth_url = users.create_login_url(self.request.uri)
			auth_text= 'signin'
		
		entry_count =Entry.all().count(1000)
		if req_user:
			tag_user = req_user
			tags = Tag.all().filter("user",req_user)
		else:
			tag_user = 'all'
			tags = Tag.all()
		tags_count = tags.count(1000)
		tag_list=[]
		for tag in tags:
			tag_count=tag.count_link + tag.count_note + tag.count_pic
			if tag.count_link >= tag.count_note:
				if tag.count_link >= tag.count_pic:
					max_type = 'link'
				else:
					max_type = 'pic'
			else:
				if tag.count_pic >= tag.count_note:
					max_type = 'pic'
				else:
					max_type = 'note'
			#logging.info(tag_count)
			#logging.info(entry_count)
			#logging.info(tags_count)
			tag_list.append({
				"info":tag,
				"type":max_type,
				"level":int(round(tag_count/(float(entry_count)/tags_count)))
				})
		template_values = {
			'nickname' : nickname,
			'req_user' : req_user,
			'auth_url' : auth_url,
			'auth_text': auth_text,
			'tag_user' : tag_user,
			'tags'     : tag_list,
			'uri'      : self.request.uri
			}
		path = os.path.join(os.path.dirname(__file__),'templates/'+user_lang+'/tag.html')
		self.response.out.write(template.render(path,template_values))
开发者ID:zerofault-cn,项目名称:zerofault,代码行数:60,代码来源:main.py

示例12: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def get(self):
        """Gets all entries from all feeds this user subscribes to"""
        user = utils.get_current_user()
        
        if not user:
            self.error(403)
            return
            
        # Filter and sorting
        order = self.request.get('order')
        lang = self.request.get('lang')
        tag_title = self.request.get('tag')

        # Filter
        if tag_title:
            tag = Tag.all().ancestor(user.key()).filter('title_lower =', tag_title.lower()).get()
            entries = Entry.all().filter('tags =', tag.key())
        else:
            entries = Entry.all().ancestor(user)

        if lang and lang != 'all':
            entries = entries.filter('language =', lang)

        # Sorting
        if order:
            if order == 'date-asc':
                entries = entries.order('time_published')
            elif order == 'date-desc':
                entries = entries.order('-time_published')
            elif order == 'title-asc':
                entries = entries.order('title')
            elif order == 'title-desc':
                entries = entries.order('-title')
        else:
            entries = entries.order('-time_published')

        entries = entries.fetch(25)
            
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        
        entries = [i.to_struct(include_tags=True) for i in entries]
        
        self.response.out.write(json.dumps(entries))
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:46,代码来源:news.py

示例13: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
    def get(self, format="json"):
        results = []

        tagsRaw = getTagTerms(self.request.get("q").lower())

        if len(tagsRaw) == 0 or tagsRaw[0] == "":
            simplewebapp.formatResponse(format, self, results)
            return

        entries = Entry.all().filter("tagsRaw IN ", tagsRaw).run()
        results = findEntries(entries, tagsRaw)

        simplewebapp.formatResponse(format, self, results)
开发者ID:outbounder,项目名称:api-techbrowser,代码行数:15,代码来源:search.py

示例14: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
 def get(self,format):
     tags = Tag.all().run()
     db.delete(tags)
     
     firstLevelTags = [
         "ActionScript",
         "Asp",
         "BASIC",
         "C",
         "C++",
         "Clojure",
         "COBOL",
         "ColdFusion",
         "Erlang",
         "Fortran",
         "Groovy",
         "Haskell",
         "Java",
         "JavaScript",
         "Lisp",
         "Perl",
         "PHP",
         "Python",
         "Ruby",
         "Scala",
         "Scheme",
         "haxe",
         "nodejs",
         'framework',
         'tool',
         'wiki',
         'tutorial',
         'howto',
         'library',
         'service',
         'language'
     ]
     
     for tag in firstLevelTags:
         t = Tag(name=tag.lower())
         t.put()
         
     entries = Entry.all()
     for e in entries:
         newtags = getTagKeys(e.tagsRaw)
         e.tags = newtags
         e.put()
         
     simplewebapp.formatResponse(format, self, "OK")
     
开发者ID:outbounder,项目名称:api-techbrowser,代码行数:51,代码来源:reset.py

示例15: get

# 需要导入模块: from model import Entry [as 别名]
# 或者: from model.Entry import all [as 别名]
 def get(self):
     """Gets all entries"""
     page = int(self.request.get('page', '0'))
     page_size = 30
     
     if not users.is_current_user_admin():
         self.error(401)
         return
         
     entries = Entry.all().order('-time_published').fetch(page_size, page_size * page)
         
     self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
     self.response.headers['Access-Control-Allow-Origin'] = '*'
     
     entries = [i.to_struct(include_tags=True) for i in entries]
     
     self.response.out.write(json.dumps(entries))
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:19,代码来源:all.py


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