Adrian Holovaty wrote:
> On 1/11/06, Maniac <[EMAIL PROTECTED]> wrote:
> 
>>This will work only in Admin but authentication generally isn't tied to
>>it. I recall that people in django-users were interested in automatic
>>user assignment to work in any view and they didn't want to insert
>>"SomeModel.created_by=request.user" in every view. It's expected to work
>>just like auto_now fields.
> 
> 
> I don't see a need to add this functionality for use beyond the scope
> of the admin site. The auto_now options aren't coupled to a request,
> so they're a special case. Coupling a request's user object to
> manipulators is something we shouldn't do. The proposed solution of
> encapsulating it in the "class Admin" is nice and clean.
> 
> Adrian

Ok, back, kind of caught up - not entirely though.

Erk. I really don't like the idea of this "shove all vaguely complex
behaviour into the admin" way of going about things. The aim should be
for the admin to be a totally bog standard django app with not too much
special going on. The only reason that we can "get away" with not
passing in a request for auto_now etc is that the time is an implicitly
globally accessible bit of state. This is not always to be considered a
benefit ( referential transparency and covert channel issues).

We do need some general way to encapsulate extracting bits of
information from a request to populate/modify a field - and not repeat
ourselves in views - ie it needs to be doable in generic views. By this
I don't mean "shove the same hacks in the admin and the generic views" ,
but that if a view is written in a fairly oblivious  fashion, it should
just work.

We can shout "coupling is bad" until we are blue in the face : the fact
remains that this is a problem that a very large number of people are
having (and no - it certainly isn't limited to the admin), we shouldn't
sweep it under the carpet by hackishly solving it in the admin and
hoping that people will cut and paste it into their views...

The phrase "special case" should make us cringe - most of the time its a
sure sign you are doing something wrong.

Reply via email to