Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:35:42+00:00 2026-06-11T16:35:42+00:00

This is ridicolously trivial but i’ve spent half an hour trying to solve it.

  • 0

This is ridicolously trivial but i’ve spent half an hour trying to solve it.

class SocialPost(model.Model):
  total_comments=model.IntegerProperty(default=0)

def create_reply_comment(self,content,author):
    ...
    logging.info(self)
    self.total_comments=self.total_comments+1
    self.put()

In the logfile, i can see how total_comments is 0 but in the admin console, it is 1. The other fields are correct, except for this one.

Probably there’s something wrong in that “default=0” but i can’t find what is wrong.

Edit: full code of my function

def create_reply_comment(self,content,author):
floodControl=memcache.get(“FloodControl-“+str(author.key))
if floodControl:
raise base.FloodControlException

    new_comment= SocialComment(parent=self.key)
    new_comment.author=author.key
    new_comment.content=content
    new_comment.put()

    logging.info(self)
    self.latest_comment_date=new_comment.creation_date
    self.latest_comment=new_comment.key
    self.total_comments=self.total_comments+1
    self.put()
    memcache.add("FloodControl-"+str(author.key), datetime.now(),time=SOCIAL_FLOOD_TIME)

Where i call the function:

if cmd == "create_reply_post":
           post=memcache.get("SocialPost-"+str(self.request.get('post')))
           if post is None:
              post=model.Key(urlsafe=self.request.get('post')).get()
              memcache.add("SocialPost-"+str(self.request.get('post')),post)
           node=node.get()
           if not node.get_subscription(user).can_reply:
               self.success()
               return


           post.create_reply_comment(feedparser._sanitizeHTML(self.request.get("content"),"UTF-8"),user)  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:35:43+00:00Added an answer on June 11, 2026 at 4:35 pm

    You’re calling memcache.add before you make your change to total_comments, so when you read it back from memcache on subsequent calls, you’re getting an out-of-date value from the cache. Your create_reply_comment needs to either delete or overwrite the "SocialPost-"+str(self.request.get('post') cache key.

    [edit] Though your post title says you’re using NDB (model.Model though? Hmm.), so you could just skip the memcache bits entirely, and let NDB do it’s thing?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this will be ridiculously simple, but whatever... I'm trying to display a
This sounds ridiculously easy, and it is with other shells. But I can't seem
This might be ridiculously easy for you but I've been struggling with this for
This might seem ridiculously simple, but I've been getting all kinds of error depending
Ok so this is likely a ridiculously stupid question but I can't seem to
This is more of a maths/general programming question, but I am programming with PHP
I didn't think this was possible, but http://www.snapabug.com provides a service that uses screen
I have this ridicolously easy piece of code. It works flawlessly on Firefox and
Quick question, again, I'm sure this is ridiculously simple but I don't see what
This is a ridiculously simple question. I am trying to find a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.