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


Python Tag.all方法代码示例

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


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

示例1: get

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

示例2: post

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
    def post(self):
        """Creates a new tag for the logged in user"""
        user = utils.get_current_user()
        title = self.request.get('title')
        new_title = self.request.get('newTitle') or None
        
        if not user:
            self.error(403)
            return
        
        if not title:
            self.error(400)

        # Create new tag
        if not new_title:
            m = Tag.all().ancestor(user).filter('title_lower =', title.lower()).get()
            
            if m:
                # Not unique
                self.error(409)
                return

            m = Tag(
                parent=user,
                title=title,
                title_lower=title.lower(),
            )
            m.put()

        # Rename Tag
        else:
            m = Tag.all().ancestor(user).filter('title_lower =', new_title.lower()).get()
            if m:
                # Not unique
                self.error(409)
                return

            m = Tag.all().ancestor(user).filter('title_lower =', title.lower()).get()
            if not m:
                # Original tag not found
                self.error(404)
                return

            m.title = new_title
            m.title_lower = new_title.lower()
            m.save()

        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,代码行数:52,代码来源:tags.py

示例3: update_basic_info

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

示例4: get

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

示例5: delete

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

示例6: getTagsProposalsForText

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
def getTagsProposalsForText(text):
    result = []
    tags = Tag.all()
    for tag in tags:
        if re.search(r'\b'+re.escape(tag.name)+r'\b',text):
            result.append(tag.name)
    
    result = excludeMismatches(result)
    
    return result
开发者ID:outbounder,项目名称:api-techbrowser,代码行数:12,代码来源:tags.py

示例7: getTagLists

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
def getTagLists():
  key_ = "tag_lists"
  tags = memcache.get(key_)
  if tags is not None:
    return tags
  else:
    tags_ = Tag.all()
    tags = [x for x in tags_]
    if not memcache.add(key_, tags, 3600):
      logging.error("Memcache set failed.")
    return tags
开发者ID:BlowBlood,项目名称:blowblood,代码行数:13,代码来源:util.py

示例8: getTagList

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
def getTagList():
    key_ = "blog_tagList_key"
    try:
        tags = memcache.get(key_)
    except Exception:
        tags = None
    if tags is None:
        tags = Tag.all().filter('valid',True).order('tag')
        memcache.add(key=key_, value=tags, time=3600)
    else:
        logging.debug("getTagList from cache. ")
    return tags
开发者ID:woodenbrick,项目名称:wedding,代码行数:14,代码来源:util.py

示例9: get

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

示例10: get

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
 def get(self):
     """Gets the tags for the logged in user"""
     user = utils.get_current_user()
     
     if not user:
         self.error(403)
         return
         
     tags = Tag.all().ancestor(user)
         
     self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
     self.response.headers['Access-Control-Allow-Origin'] = '*'
     
     tags = [i.to_struct() for i in tags]
     
     self.response.out.write(json.dumps(tags))
开发者ID:studyindenmark,项目名称:newscontrol,代码行数:18,代码来源:tags.py

示例11: get

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
 def get(self,format="json"):
     
     query = self.request.get("q").lower()
     if len(query) == 0:
         simplewebapp.formatResponse(format,self,[])
         return
     
     resultedTags = []
     
     tags = TagModel.all().run()
     for tag in tags:
         if tag.name.startswith(query):
             resultedTags.append(tag.name)
             
     simplewebapp.formatResponse(format,self,resultedTags)
     
开发者ID:outbounder,项目名称:api-techbrowser,代码行数:17,代码来源:tag.py

示例12: post

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
    def post(self, feed_id, entry_id, tag_title):
        """ Create or modify tag """
        current_user = utils.get_current_user()
        
        if not current_user:
            logging.info('no user logged in')
            self.error(403)
            return

        logging.info(feed_id)
        feed = InputFeed.get_by_id(int(feed_id), parent=current_user)

        if not feed:
            logging.info('no feed found')
            self.error(404)
            return

        entry = Entry.get_by_id(int(entry_id), parent=feed)

        if not entry:
            logging.info('no entry found')
            self.error(404)
            return

        if not tag_title:
            logging.info('no tag_title provided found')
            self.error(400)
            return

        tag_title = tag_title.decode('utf-8')
        tag = Tag.all().ancestor(current_user).filter('title_lower =', tag_title.lower()).get()

        if not tag:
            logging.info('tag not found, creating new')

            tag = Tag(
                parent=current_user,
                title=tag_title,
                title_lower=tag_title.lower(),
            )

        tag.tag_entry(entry)
        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,代码行数:47,代码来源:entries.py

示例13: get

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

示例14: delete

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
    def delete(self, feed_id, entry_id, tag_title):
        """ Delete tag """
        current_user = utils.get_current_user()
        
        tag_title = tag_title.decode('utf-8')
        
        if not current_user:
            logging.info('no user logged in')
            self.error(403)
            return

        logging.info(feed_id)
        feed = InputFeed.get_by_id(int(feed_id), parent=current_user)

        if not feed:
            logging.info('no feed found')
            self.error(404)
            return

        entry = Entry.get_by_id(int(entry_id), parent=feed)

        if not entry:
            logging.info('no entry found')
            self.error(404)
            return

        if not tag_title:
            logging.info('no tag_title provided found')
            self.error(400)
            return

        tag = Tag.all().ancestor(current_user).filter('title_lower =', tag_title.lower()).get()

        if not tag:
            logging.info('no tag found')
            self.error(404)
            return

        entry.tags.remove(tag.key())
        entry.save()
        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,代码行数:45,代码来源:entries.py

示例15: get

# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import all [as 别名]
 def get(self,format):
     url = self.request.get("url").lower()
     try:
         content = resource.get(url).decodeBody().lower()
     except:
         content = ""
     
     tags = JSONDecoder().decode(content);
     
     ''' appends only new tags ''' 
     newTags = []
     for tag in tags:
         t = None
         t = Tag.all().filter("name = ", tag).fetch(1)
         if len(t) == 0:
             newTag = saveTag(tag, None);
             newTags.append(newTag.name)
     
     simplewebapp.formatResponse(format, self, newTags)
开发者ID:outbounder,项目名称:api-techbrowser,代码行数:21,代码来源:synch.py


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