That's probably it. I don't know why, but I had this wrong idea that the 'get' would *assign* a default value to the dictionary if the value was not found!
Thanks to both of you. G On 7/10/06, Ian Holsman <[EMAIL PROTECTED]> wrote: > > Hi Gullermo. > > I've done the same thing here: > http://svn.zyons.python-hosting.com/trunk/zilbo/common/utils/middleware/lastseen.py > > by the looks of it you are forgetting to actually store it. > ie > request.session['sysvortex_last_visit'] = datetime.datetime.now() > > cheers > Ian. > > > On 09/07/2006, at 11:56 PM, Guillermo Fernandez Castellanos wrote: > > > > Hi, > > Seems like last time I was not that clear, so here is what I want to > do: I want to keep track of the users that visit my site, keeping in > the DB what IP addresses visited my site, when, ... I define a visit > as a click on one of my pages, given that this visit is done a certain > time after the last visit (30 minutes, 1 hour, 1day,... that can be > choosen). > > I've decided to keep in the cookies, through the session middleware, > the value of the last visit. I do this with the request.session in the > process_view of a personal middleware I am trying to develop: > > class IpMiddleware: > def _add_ip(this_ip): > # Adds IP and Visit to database > [...] > def process_view(self, request, view_func, view_args, view_kwargs): > last_visit=request.session.get('sysvortex_last_visit', > datetime.now()) > difference=datetime.now()-last_visit > if difference > timedelta(minutes=30): > self._add_ip(request.META['REMOTE_ADDR']) > return None > > My problem is, I can not make the request.session to store my value. > No matter how many time I wait or what I do, 'difference' always is > (almost) 0. It seems to me that when I do > request.session.get('sysvortex_last_visit', datetime.now()) the value > is not actually saved, which seems strange. > > I am struggling with this for a few days now, so any help or pointer > is higly appreciated, thanks! > > G > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---

