I've got some strange problems in my hosting enviroment using mod_wsgi
like that:
WSGIDaemonProcess mygroup  user=myuser group=users processes=3
threads=10 display-name=mygroup

Enviroment:
python-2.6.1
python-apache-2.2.11
psycopg2-2.0.11
apache-mod_wsgi-2.5
glibc-2.10.1


The problem is that random requests (originating from the same client
which is ab -n 1000 -c 3 http://...) generates 404, because these
requests generates different sql:

Query which is OK as I think:
SELECT "pressroom_article"."id", "pressroom_article"."pub_date",
"pressroom_article"."headline", "pressroom_article"."slug",
"pressroom_article"."summary", "pressroom_article"."body",
"pressroom_article"."author_id", "pressroom_article"."publish",
"pressroom_article"."enable_comments" FROM "pressroom_article"
 WHERE ("pressroom_article"."pub_date" <= E'2009-09-29 13:54:00.806995'
 AND "pressroom_article"."publish" = true  AND
"pressroom_article"."pub_date" BETWEEN E'2009-09-29 00:00:00' and
E'2009-09-29 23:59:59.999999' AND "pressroom_article"."slug" =
E'spotting-na-jfk'  AND "pressroom_article"."pub_date" <= E'2009-09-29
13:54:00.808648' ) ORDER BY "pressroom_article"."pub_date" DESC
^^^^^^^^^^^^^^^

And the one which renders 404 is
WHERE ("pressroom_article"."pub_date" <= E'2009-09-29 06:55:06.859015'
                                                      ^^^^^^^^^^^^^^^^
AND "pressroom_article"."publish" = true  AND

The question is - what's wrong? it happens in different projects.

My setting:
TIME_ZONE = 'Europe/Warsaw'


My Model is (it's modified part of
http://code.google.com/p/django-pressroom/):

class ArticleManager(models.Manager):
    def get_published(self):
        return self.filter(publish=True, pub_date__lte=datetime.now)
    def get_drafts(self):
        return self.filter(publish=False)

class Article(models.Model):
    pub_date = models.DateTimeField("Publish date", default=datetime.now)
    headline = models.CharField(max_length=200)
    slug = models.SlugField(help_text='A "Slug" is a unique URL-friendly
title for an object.')
    summary = models.TextField(help_text="A single paragraph summary or
preview of the article.")
    body = models.TextField("Body text")
    #author = models.CharField(max_length=100)
    author = models.ForeignKey(User, verbose_name="Author" )
    publish = models.BooleanField("Publish on site", default=True,
                                  help_text='Articles will not appear on
the site until their "publish date".')
    sections = models.ManyToManyField('Section', related_name='articles')
    photos = models.ManyToManyField(Photo, related_name='articles',
null=True, blank=True)
    documents = models.ManyToManyField('Document',
related_name='articles', null=True, blank=True)
    enable_comments = models.BooleanField(default=True)

    # Custom article manager
    objects = ArticleManager()
[...]

And my view is:
def article_detail(request, *args, **kwargs):
        kwargs['queryset'] = Article.objects.get_published()
        return date_based.object_detail(request, *args, **kwargs)


Another view in another project which act the same is:
def my_akt_detail(request, *args, **kwargs):
        kwargs['queryset'] =
Akt.objects.select_related('zrodla').filter(visible_since__lte=datetime.now())
        return date_based.object_detail(request, *args, **kwargs)


In above views I use intentionally my own views to get rid of cache-like
queryset behaviour like
http://pascut.com/2008/08/16/django-generic-views-cache-behavior/

It does not matter, if in my view i return
Article.objects.get_published() or Article.objects.all() - It's probably
because default value of allow_future=False in date_based.object_detail
Strange thing is that 404 NOT FOUND appears random, sometimes it's 25%,
30, or even about 70% times.
For now i'm not sure, if original date_based.object_detail is buggy in
my enviroment.
Any ideas?
-- 
B.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to