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',
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
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
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 =
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
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
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:
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,
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
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
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
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 =
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
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
> > 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
>
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
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
--~--~-~--~~~---~--~~
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
18 matches
Mail list logo