from django.shortcuts import render_to_response

class FullPageAdMiddleware(object):
    def process_view(self, request, view_func, view_args,
view_kwargs):

        request.session['testing'] = request.session['testing'] + 1

        if request.session['testing'] > 10:
            return None
        else:
            return render_to_response('base/advertisement.html')

This code fails to work properly. There are numerous issues with even
this example, and I could probably simply the code further, but here
are some of the errors:

— Many times when return None occurs, my site's CSS and JavaScript
files will not return, because supposedly the MIME type is not
correct.
— "request.session['testing'] = request.session['testing'] + 1" does
not increment by 1. It sometimes increments by 10, sometimes 20,
sometimes 1. It is totally messed up, and I don't understand why.
I've tried several other methods to increment: "request.session
['testing'] += 1" and many more, but all have failed.
— That's only the beginning, but I figure these first two issues
should be interesting enough for someone to examine.

Note: I have tried this code on my production and test servers. I have
the latest version of Django, and I've tried this on Python 2.6 and
Python 2.4.

I've also tried using different session storage options: db and cache,
both with the same result.

I'm pretty much out of options.

Oh, and for an explanation as to what I'm trying to accomplish, so you
understand what I'm trying to do:

I want to attach a visit counter to each user who visits my site, and
then increment that amount by 1 for each page view. Once the user hits
a certain number of page views, I want to display a full page
advertisement, and then provide a link to continue to the page.

So, hopefully someone can help me because no one seems to know in the
IRC.

Thanks for any responses
--~--~---------~--~----~------------~-------~--~----~
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