Re: MSSQL Support

2006-10-21 Thread DavidA


Sean De La Torre wrote:
> I've been maintaining/enhancing a ticket
> (http://code.djangoproject.com/ticket/2358) contributed by another
> django user that adds MSSQL support to django.  In addition to what
> that user started, I've added full introspection capabilities and
> patched a few bugs that I've found.  I've been running a production
> site using this patch for about a month now, and the MSSQL integration
> seems to be stable.
>
> I'd appreciate it if other MSSQL users could give the patch a try.
> The one item missing from the ticket is paging, but MSSQL doesn't
> support that natively, so any input regarding that problem would also
> be most appreciated.
>
> If the Django-users list is the more appropriate place for this
> message, please let me know.
>
> Thanks,

What version of SQL Server have you been testing with? I think in 2005
there is support for paging. This brings up the question of how to
handle different versions of backends.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---



Re: MSSQL Support

2006-10-21 Thread Sean De La Torre

I've been testing with SQL Server 2000 and MSDE.  When I have more
time I intend to install SQL Server 2005 Express to see if there are
any issues with the newer versions.

On 10/21/06, DavidA <[EMAIL PROTECTED]> wrote:
>
>
> Sean De La Torre wrote:
> > I've been maintaining/enhancing a ticket
> > (http://code.djangoproject.com/ticket/2358) contributed by another
> > django user that adds MSSQL support to django.  In addition to what
> > that user started, I've added full introspection capabilities and
> > patched a few bugs that I've found.  I've been running a production
> > site using this patch for about a month now, and the MSSQL integration
> > seems to be stable.
> >
> > I'd appreciate it if other MSSQL users could give the patch a try.
> > The one item missing from the ticket is paging, but MSSQL doesn't
> > support that natively, so any input regarding that problem would also
> > be most appreciated.
> >
> > If the Django-users list is the more appropriate place for this
> > message, please let me know.
> >
> > Thanks,
>
> What version of SQL Server have you been testing with? I think in 2005
> there is support for paging. This brings up the question of how to
> handle different versions of backends.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---



Bugs in karma code

2006-10-21 Thread Guillermo Fernandez Castellanos

Hi,

I know it's going to be rewritten soon. And I know I should launch the
basic test cases before sending a patch. But to be honest, I've tried
to launch the tests without much success (i.e. I could not launch
them...). Furthermore I would like to be sure I'm not wrong before
contributing a patch.

When using the karma function for the first time I got the following errors:
'KarmaScoreManager' object has no attribute 'objects'

So i just had a look at the code :-P

Here is a list of the problems I found and their corrections (patch
with all errors at the end):

In django/contrib/comments/models.py, I change the line 212:
karma = self.objects.get(comment__pk=comment_id, user__pk=user_id)
to:
karma = self.get(comment__pk=comment_id, user__pk=user_id)
and it works perfectly.

I also identified this in line 157:
return self._karma_total_good + self._karma_total_bad
that should be:
return self._karma_total_good - self._karma_total_bad
indee, self._karma_total_bad is always a positive number, so the
total, to be meagninful, should be with the minus. Otherwise we get
the total number of karma votes, instead of the total karma.

In the line 136:
for k in self.karmascore_set:
should be:
for k in self.karmascore_set.all():
Otherwise I have a related manager over which I can not iterate.

Finally, in line 157:
if not hasattr(self, "_karma_total_bad") or not hasattr(self,
"_karma_total_good"):
self._fill_karma_cache()
should be:
self._fill_karma_cache()
Otherwise, the karma count does not actualise itself for each comment
and all comments have the same karma count.

Ok, hope it helps, and please tell me if something is wrong here.

G

The patch:
***
BEGIN PATCH
***
Index: contrib/comments/models.py

===

--- contrib/comments/models.py  (revision 3910)

+++ contrib/comments/models.py  (working copy)

@@ -133,7 +133,7 @@

 def _fill_karma_cache(self):
 "Helper function that populates good/bad karma caches"
 good, bad = 0, 0
-for k in self.karmascore_set:
+for k in self.karmascore_set.all():
 if k.score == -1:
 bad +=1
 elif k.score == 1:
@@ -151,9 +151,8 @@

 return self._karma_total_bad

 def get_karma_total(self):
-if not hasattr(self, "_karma_total_good") or not
hasattr(self, "_karma_total_bad"):
-self._fill_karma_cache()
-return self._karma_total_good + self._karma_total_bad
+self._fill_karma_cache()
+return self._karma_total_good - self._karma_total_bad

 def get_as_text(self):
 return _('Posted by %(user)s at
%(date)s\n\n%(comment)s\n\nhttp://%(domain)s%(url)s') % \
@@ -209,7 +208,7 @@

 class KarmaScoreManager(models.Manager):
 def vote(self, user_id, comment_id, score):
 try:
-karma = self.objects.get(comment__pk=comment_id, user__pk=user_id)
+karma = self.get(comment__pk=comment_id, user__pk=user_id)
 except self.model.DoesNotExist:
 karma = self.model(None, user_id=user_id,
comment_id=comment_id, score=score,
scored_date=datetime.datetime.now())
 karma.save()
***
END PATCH
***

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~--~~~~--~~--~--~---