On Sun, Oct 3, 2010 at 11:20 AM, Russell Keith-Magee
<russ...@keith-magee.com> wrote:
>> The issue is not only the frequency of failure, but how explicit/clear
>> it is. The failure here is so obscure and difficult to track down, it
>> is likely to generate an outsize support burden. In contrast, raising
>> an error on assigning to self can be completely explicit; no hours of
>> painful and confusing debugging necessary.
>>
>> Let's also be clear to distinguish "just document that you don't store
>> state on self" vs "raise an error if you set an attribute on self."
>> These are proposals with very different characteristics in terms of
>> likely confusion and support burden.
>
> Agreed. The "just document" approach is a non-starter; the 'error when
> you set attribute on self' is at least a technically viable option.
>
> My problem with the error-based approach is entirely conceptual -- it
> feels to me like throwing the baby out with the bathwater. I'm having
> a lot of trouble with the idea that class instances have state in
> every other Python class instance, and if we introduce an API that
> physically prohibits instance state that -- no matter how good the
> technical reasoning --  we're going to:
>
>  * Cause confusion amongst new users as to why this seemingly obvious
> thing can't be done
>
>  * Ignore the legitimate occasions where using state is a useful
> architectural approach.

While I'm in the "one singleton view instance is best" camp and think
that storing some state on the request and some on the view is a bit
gross, I understand Russell's arguments. New users are simply going to
save stuff on self no matter how much we complain, document etc. It's
simply a reality that likely can't be helped much.

Other frameworks seem have View/Handler instances per request, such as
appengine's webapp so there is some precedent for creating an instance
per request.

http://code.google.com/appengine/docs/python/gettingstarted/handlingforms.html

Flask seems to do it the callable singleton way:

http://flask.pocoo.org/docs/patterns/lazyloading/

Is there any precedent in other frameworks for doing it the singleton
way? Talking a bit about how other frameworks/libraries do this might
be a good idea to figure out what Joe User is likely to do.

-- 
Ian

http://www.ianlewis.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to