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


Python Post.remove_cached_count_from_memcache方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import remove_cached_count_from_memcache [as 别名]
  def post(self):
    url = self.request.get('url')
    title = sanitizeHtml(self.request.get('title'))
    message = sanitizeHtml(self.request.get('message'))

    session = get_current_session()
    if session.has_key('user') and len(title) > 0:
      user = session['user']
      # decide if its a message or a link, if its a link we need a try/catch around the save, the link might be invalid
      if len(message) == 0:
        try:
          post = Post(url=url,title=title,message=message, user=user)
          post.put()
          vote = Vote(user=user, post=post, target_user=post.user)
          vote.put()
          Post.remove_cached_count_from_memcache()
          self.redirect('/noticia/' + str(post.key()));
        except db.BadValueError:
          self.redirect('/agregar')
      else:
        post = Post(title=title,message=message, user=user)
        post.put()
        post.url = "http://" + urlparse(self.request.url).netloc + "/noticia/" + str(post.key())
        post.put()
        Post.remove_cached_count_from_memcache()
        vote = Vote(user=user, post=post, target_user=post.user)
        vote.put()
        self.redirect('/noticia/' + str(post.key()));
    else:
      self.redirect('/')
开发者ID:soska,项目名称:Noticias-HAcker,代码行数:32,代码来源:main.py

示例2: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import remove_cached_count_from_memcache [as 别名]
    def post(self):
        session = get_current_session()
        url = self.request.get("url")
        title = helper.sanitizeHtml(self.request.get("title"))
        message = helper.sanitizeHtml(self.request.get("message"))
        nice_url = helper.sluglify(title)

        if session.has_key("user"):
            if len(nice_url) > 0:
                user = session["user"]
                if len(message) == 0:  # is it a post or a message?
                    # Check that we don't have the same URL within the last 'check_days'
                    since_date = date.today() - timedelta(days=7)
                    q = Post.all().filter("created >", since_date).filter("url =", url).count()
                    url_exists = q > 0
                    q = Post.all().filter("nice_url", nice_url).count()
                    nice_url_exist = q > 0
                    try:
                        if not url_exists:
                            if not nice_url_exist:
                                post = Post(url=url, title=title, message=message, user=user, nice_url=nice_url)
                                post.put()
                                vote = Vote(user=user, post=post, target_user=post.user)
                                vote.put()
                                Post.remove_cached_count_from_memcache()
                                self.redirect("/noticia/" + str(post.nice_url))
                            else:
                                session["post_error"] = "Este titulo ha sido usado en una noticia anterior"
                                self.redirect("/agregar")
                        else:
                            session["post_error"] = "Este link ha sido entregado en los ultimo 7 dias"
                            self.redirect("/agregar")
                    except db.BadValueError:
                        session["post_error"] = "El formato del link no es valido"
                        self.redirect("/agregar")
                else:
                    q = Post.all().filter("nice_url", nice_url).count()
                    nice_url_exist = q > 0
                    if not nice_url_exist:
                        post = Post(title=title, message=message, user=user, nice_url=nice_url)
                        post.put()
                        post.url = helper.base_url(self) + "/noticia/" + post.nice_url
                        post.put()
                        Post.remove_cached_count_from_memcache()
                        vote = Vote(user=user, post=post, target_user=post.user)
                        vote.put()
                        self.redirect("/noticia/" + post.nice_url)
                    else:
                        session["post_error"] = "Este titulo ha sido usado en una noticia anterior"
                        self.redirect("/agregar")
            else:
                session["post_error"] = "Necesitas agregar un titulo"
                self.redirect("/agregar")
        else:
            self.redirect("/login")
开发者ID:zetta,项目名称:Noticias-HAcker,代码行数:57,代码来源:SubmitNewStoryHandler.py

示例3: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import remove_cached_count_from_memcache [as 别名]
  def post(self):
    session = get_current_session()
    url = self.request.get('url')
    title = helper.sanitizeHtml(self.request.get('title'))
    message = helper.sanitizeHtml(self.request.get('message'))

    if session.has_key('user'):
      if len(title) > 0:
        user = session['user']
        if len(message) == 0: #is it a post or a message?
          #Check that we don't have the same URL within the last 'check_days'
          since_date = date.today() - timedelta(days=7)
          q = Post.all().filter("created >", since_date).filter("url =", url).count()
          url_exists = q > 0
          try:
            if not url_exists:
              post = Post(url=url,title=title,message=message, user=user)
              post.put()
              vote = Vote(user=user, post=post, target_user=post.user)
              vote.put()
              Post.remove_cached_count_from_memcache()
              self.redirect('/noticia/' + str(post.key()));
            else:
              session['post_error'] = "Este link ha sido entregado en los ultimo 7 dias"
              self.redirect('/agregar')
          except db.BadValueError:
            session['post_error'] = "El formato del link no es valido"
            self.redirect('/agregar')
        else:
          post = Post(title=title,message=message, user=user)
          post.put()
          post.url = helper.base_url(self) + "/noticia/" + str(post.key())
          post.put()
          Post.remove_cached_count_from_memcache()
          vote = Vote(user=user, post=post, target_user=post.user)
          vote.put()
          self.redirect('/noticia/' + str(post.key()));
      else:
        session['post_error'] = "Necesitas agregar un titulo"
        self.redirect('/agregar')
    else:
      self.redirect('/login')
开发者ID:mantus,项目名称:Noticias-HAcker,代码行数:44,代码来源:main.py

示例4: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import remove_cached_count_from_memcache [as 别名]
  def post(self):
    session = get_current_session()
    url = self.request.get('url')
    title = helper.sanitizeHtml(self.request.get('title'))
    message = helper.sanitizeHtml(self.request.get('message'))
    nice_url = helper.sluglify(title)
    key = self.request.get('comment_key')
 
    if session.has_key('user') and key == keys.comment_key:
      if len(nice_url) > 0:
        user = session['user']
        if len(message) == 0: #is it a post or a message?
          #Check that we don't have the same URL within the last 'check_days'
          since_date = date.today() - timedelta(days=7)
          q = Post.all().filter("created >", since_date).filter("url =", url).count()
          url_exists = q > 0
          q = Post.all().filter("nice_url", nice_url).count()
          nice_url_exist = q > 0
          try:
            if not url_exists:
              if not nice_url_exist:
                post = Post(url=url,title=title,message=message, user=user, nice_url=nice_url)
                post.put()
                helper.killmetrics("Submit","Link", "do", session, "",self)
                vote = Vote(user=user, post=post, target_user=post.user)
                vote.put()
                Post.remove_cached_count_from_memcache()
 	
                #index with indextank
                helper.indextank_document( helper.base_url(self), post)
                
                self.redirect('/noticia/' + str(post.nice_url));
              else:
                session['post_error'] = "Este titulo ha sido usado en una noticia anterior"
                self.redirect('/agregar')
            else:
              session['post_error'] = "Este link ha sido entregado en los ultimo 7 dias"
              self.redirect('/agregar')
          except db.BadValueError:
            session['post_error'] = "El formato del link no es valido"
            self.redirect('/agregar')
        else:
          q = Post.all().filter("nice_url", nice_url).count()
          nice_url_exist = q > 0
          if not nice_url_exist:
            post = Post(title=title,message=message, user=user, nice_url=nice_url)
            post.put()
            helper.killmetrics("Submit","Post", "do", session, "",self)
            post.url = helper.base_url(self) + "/noticia/" + post.nice_url
            post.put()
            Post.remove_cached_count_from_memcache()
            vote = Vote(user=user, post=post, target_user=post.user)
            vote.put()

	    #index with indextank
	    helper.indextank_document( helper.base_url(self), post)
            
	    self.redirect('/noticia/' + post.nice_url);
          else:
            session['post_error'] = "Este titulo ha sido usado en una noticia anterior"
            self.redirect('/agregar')
      else:
        session['post_error'] = "Necesitas agregar un titulo"
        self.redirect('/agregar')
    else:
      self.redirect('/login')
开发者ID:grillermo,项目名称:Noticias-HAcker,代码行数:68,代码来源:SubmitNewStoryHandler.py


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