Using story GUID's on top of permalinks.

This commit is contained in:
Samuel Clay 2009-09-05 02:22:25 +00:00
parent fbe5c19ab5
commit acd464af86
3 changed files with 11 additions and 6 deletions

View file

@ -1,7 +1,7 @@
import datetime
import random
import re
import sha
import hashlib
from django.conf import settings
from django.db import models
@ -137,8 +137,8 @@ class RegistrationManager(models.Manager):
username and a random salt.
"""
salt = sha.new(str(random.random())).hexdigest()[:5]
activation_key = sha.new(salt+user.username).hexdigest()
salt = hashlib.sha.new(str(random.random())).hexdigest()[:5]
activation_key = hashlib.sha.new(salt+user.username).hexdigest()
return self.create(user=user,
activation_key=activation_key)

View file

@ -94,7 +94,8 @@ class Feed(models.Model):
story_title = story.get('title'),
story_content = story_content,
story_author = story.get('author'),
story_permalink = story.get('link')
story_permalink = story.get('link'),
story_guid = story.get('id')
)
try:
ret_values[ENTRY_NEW] += 1
@ -125,7 +126,8 @@ class Feed(models.Model):
story_content = diff.getDiff(),
story_original_content = original_content,
story_author = story.get('author'),
story_permalink = story.get('link')
story_permalink = story.get('link'),
story_guid = story.get('id')
)
try:
ret_values[ENTRY_UPDATED] += 1
@ -172,7 +174,9 @@ class Feed(models.Model):
content_ratio = 0
if story_pub_date > start_date and story_pub_date < end_date:
if story.get('link') == existing_story['story_permalink']:
if story.get('id') == existing_story['story_guid']:
story_in_system = existing_story
elif story.get('link') == existing_story['story_permalink']:
story_in_system = existing_story
# Title distance + content distance, checking if story changed
@ -254,6 +258,7 @@ class Story(models.Model):
blank=True)
story_author = models.CharField(max_length=255, null=True, blank=True)
story_permalink = models.CharField(max_length=1000)
story_guid = models.CharField(max_length=1000)
story_past_trim_date = models.BooleanField(default=False)
tags = models.ManyToManyField(Tag)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB