No. The two versions are equivalent. The 1.4 version is simpler, though.
How it used to work
The LazyUser
object implemented the descriptor protocol.
Descriptors are a bit convoluted to understand, but the general idea here is that although user
was a class attribute, accessing request.user
woud call request.__class__.user.__get__(request)
, and therefore let the __get__
method access the request parameters, which it would use to return the user bound to the request.
How it works now
The user
property uses the SimpeLazyObject
construct to achieve the same goal: avoid loading all the user machinery if it's not going to be needed.
As to when get_user
is called:
When you access an attribute on request.user
, for example request.user.attr1
, then request.user.__getattr__('attr1')
will be called, which will in turn call request.user._setup()
, which will eventually call get_user
.
How Django creates statefulness
Through the use of Sessions. Have a look at django's session middleware.