On Mon, Oct 18, 2010 at 2:00 AM, legutierr <leguti...@gmail.com> wrote:
>
>
> On Oct 17, 11:58 am, Russell Keith-Magee <russ...@keith-magee.com>
> wrote:
>> On Sat, Oct 16, 2010 at 12:45 AM, Russell Keith-Magee
>>
>> I should also be able to port the tutorial before I commit -- which,
>> barring objection, I will do tomorrow night my time (about 24 hours
>> from now). Speak now, etc etc.
>>
>> Yours,
>> Russ Magee %-)
>
> If it is too late for this, then just disregard, but I do have one
> slight observation about the TemplateMixin.  Might it be a good idea
> to encourage alternate response mixins (JSONResponseMixin, etc.)
> implemented by the community to implement and use get_response() and
> get_context_instance() methods?  If so, would it be a good idea to
> implement a BaseResponseMixin that implements those methods, as well
> as a `render_to_response` that raises NotImplementedError, that could
> be subclassed?
>
> This seems like a relatively inconsequential thing, but I thought I'd
> just put it out there.  Without it, I think the tendency would be for
> alternate response mixins not to contain either of these methods
> (which seem like useful hooks), or to just copy and paste what's
> there.

I contemplated this after looking at your bitbucket fork, but decided
against it. The ResponseMixin in your branch contains three methods:

 * render_to_response() -- which must be overridden
 * get_context_instance() -- which is of arguable utility in the general case
 * get_response() -- which will probably need to be overridden in most
subclassing cases to provide a default content type.

Given that the only three methods in that mixin are either not
necessary or will need to be overridden, I decided that
reimplementation would ultimately make more sense. If this were Java
and types mattered, having the common base class might make sense, but
Python is fine about ducks, so we might as well exploit that fact.

However, you will note that the topic guide that Andrew prepared has a
section heading specifically targeted at JSON responses. That section
isn't written yet, but the idea is to put in a guide on how to handle
JSON responses as way to point out why template rendering has been
factored out in the way that it has.

Yours,
Russ Magee %-)

-- 
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