Re: Help with Last Seen (why doesn't this work???)

2007-02-01 Thread [EMAIL PROTECTED]
Honza, if I ever meet ya, I'm buying you a cookie. Here's what I ended up with. Hopefully it'll help someone else. import datetime class LastSeen (object): def process_request(self, request): now = datetime.datetime.now() last_request = request.session.get( 'last_request',

Re: Help with Last Seen (why doesn't this work???)

2007-02-01 Thread [EMAIL PROTECTED]
Thanks. I've been working my way through diveintopython as well as some other materials, but obviously have a long way to go. That, and request.session.get() makes a bit more sense! On Feb 1, 10:18 am, "Honza Král" <[EMAIL PROTECTED]> wrote: > btw, some literature about python and programming in

Re: Help with Last Seen (why doesn't this work???)

2007-02-01 Thread Honza Král
btw, some literature about python and programming in general would perhaps be in order... I recommend diveintopython.org On 2/1/07, Honza Kr�l <[EMAIL PROTECTED]> wrote: > On 2/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > I like that brevity and simplicity, but could you clarify

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
this seems more accurate: def process_request( self, request ): now = datetime.datetime.now() # get last_request, defaults to now, when he was never seen before # you may wish to omit setting last_seen in that case (he wasn't ever seen) last_request =

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Doug Van Horn
On Jan 30, 7:01 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > There's some conceptual thing I'm apparently just not getting. I > attempted to follow Doug's advice and came up with: > > [snip] > > Which appears to do the exact same thing I was doing before. I may have misled you with the

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread [EMAIL PROTECTED]
I think this MAY be working now and I think I even finally wrapped my head around what's going on. So, in hopes of helping someone else some day (or, alternately, someone pointing out any trouble spots remaining), the last_visit middleware: import datetime class LastSeen (object): def

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I know I'm dense, and I'm just not seeing this, but isn't that what > I'm doing? > > now = datetime.datetime.now() > last_request = request.session['last_request'] > > if (now - last_request).seconds > (60 * 60 *4): > ... but this line:

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread [EMAIL PROTECTED]
I know I'm dense, and I'm just not seeing this, but isn't that what I'm doing? now = datetime.datetime.now() last_request = request.session['last_request'] if (now - last_request).seconds > (60 * 60 *4): ... request.session['last_request'] = now On Jan 31, 7:47 am,

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Ok, but if I update last_request at every request, then won't (now - > last_request) ALWAYS be more or less 0? not if you update it AFTER the comparison... > > > On Jan 31, 4:16 am, "Honza Kr�l" <[EMAIL PROTECTED]> wrote: > > On

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread [EMAIL PROTECTED]
Ok, but if I update last_request at every request, then won't (now - last_request) ALWAYS be more or less 0? On Jan 31, 4:16 am, "Honza Král" <[EMAIL PROTECTED]> wrote: > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > There's some conceptual thing I'm apparently just not

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > There's some conceptual thing I'm apparently just not getting. I > attempted to follow Doug's advice and came up with: > > class LastSeen (object): > """Middleware that adds various objects to thread local storage > from the request

Re: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread [EMAIL PROTECTED]
There's some conceptual thing I'm apparently just not getting. I attempted to follow Doug's advice and came up with: class LastSeen (object): """Middleware that adds various objects to thread local storage from the request object.""" def process_request(self, request): now =

Re: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread Doug Van Horn
On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Well, if I were doing it by hand, every time they came to the site I > would set this_visit, and then set last_visit (or last_seen, or > whatever) to the previous value of this_visit, and I would only do it > once, when they

Re: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread [EMAIL PROTECTED]
Well, if I were doing it by hand, every time they came to the site I would set this_visit, and then set last_visit (or last_seen, or whatever) to the previous value of this_visit, and I would only do it once, when they first come to the site. Problem is two-fold.. 1) I don't have a central

RE: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread Chris Brand
> > The problem is that it resets when the visitor first comes to the page. > > In other words, when I go to the site first thing in the morning > > last_seen resets to NOW. But that's exactly what your code says : > > l = request.session['last_seen'] > > last = now -l >

Re: Help with Last Seen (why doesn't this work???)

2007-01-30 Thread [EMAIL PROTECTED]
Looks like an apology is in order... I'm sorry... I didn't mean to ruffle any feathers, nor did I intend to be a poor member of the community. Again, I'm sorry. Here's the source of frustration though... I've been dealing with this problem for months. I've searched and reviewed every thread

Re: Help with Last Seen (why doesn't this work???)

2007-01-29 Thread Adrian Holovaty
On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > C'mon guys... anyone? Hey there, Please don't "bump" your threads like this -- it's unacceptable mailing-list behavior. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~-~--~~~---~--~~

Re: Help with Last Seen (why doesn't this work???)

2007-01-29 Thread [EMAIL PROTECTED]
C'mon guys... anyone? On Jan 29, 7:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Anyone? > > I know this is a common question... I've seen it come up more than > once (frankly, I've asked more than once). And I know that some people > have alluded to having an answer. I know having