From c5248fba11755939b9b03aa996db697f8fd4b099 Mon Sep 17 00:00:00 2001 From: hernani Date: Sun, 18 Apr 2010 18:28:40 +0000 Subject: [PATCH] python 2.4 compatibility fixes and fix on score counter git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@50 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/models/base.py | 9 --------- forum/models/node.py | 2 ++ forum/models/user.py | 7 +++++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/forum/models/base.py b/forum/models/base.py index 7974af6..78f1242 100644 --- a/forum/models/base.py +++ b/forum/models/base.py @@ -1,5 +1,4 @@ import datetime -import hashlib from urllib import quote_plus, urlencode from django.db import models, IntegrityError, connection, transaction from django.utils.http import urlquote as django_urlquote @@ -194,14 +193,6 @@ class QandA(Node): self.wikified_at = datetime.datetime.now() self.save() - def save(self, *args, **kwargs): - self.__dict__['score'] = self.__dict__['vote_up_count'] - self.__dict__['vote_down_count'] - super(QandA,self).save(*args, **kwargs) - - try: - ping_google() - except Exception: - logging.debug('problem pinging google did you register you sitemap with google?') diff --git a/forum/models/node.py b/forum/models/node.py index 552944e..13749cd 100644 --- a/forum/models/node.py +++ b/forum/models/node.py @@ -190,6 +190,8 @@ class Node(BaseModel, NodeContent, DeletableContent): if self.parent_id and not self.abs_parent_id: self.abs_parent = self.parent.absolute_parent + + self.__dict__['score'] = self.__dict__['vote_up_count'] - self.__dict__['vote_down_count'] tags = self.get_tag_list_if_changed() super(Node, self).save(*args, **kwargs) diff --git a/forum/models/user.py b/forum/models/user.py index f8b8d14..82cfe3a 100644 --- a/forum/models/user.py +++ b/forum/models/user.py @@ -3,7 +3,10 @@ from forum import const from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser from django.db.models import Q -from hashlib import md5 +try: + from hashlib import md5 +except: + import md5 import string from random import Random @@ -97,7 +100,7 @@ class User(BaseModel, DjangoUser): @property def gravatar(self): - return hashlib.md5(self.email).hexdigest() + return md5(self.email).hexdigest() def save(self, *args, **kwargs): if self.reputation < 0: -- 2.39.5