Here's a couple of improvements to the code referenced in David's message:
In the definition of postId(), change this line:
id = '%s%s' % (time.time(), random.random())
id = '%r%r' % (time.time(), random.random())
to avoid loss of precision.
And in isReposted(), add this as the second last line (just before "return 0"):
This ensures that your altered session data is committed to stable
storage right now, instead of at the end of the current
(possibly long-running) servlet. This may or may not be necessary,
depending on your choice of SessionStore.