Opened 18 years ago

Closed 17 years ago

#4612 closed (invalid)

Since change [5482], SQL queries that occur in the templates no longer appear in connection.queries

Reported by: gpd@… Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Before change [5482] SQL queries that occur in the templates appear in connection.queries so that I can use them for stats in Middleware. Although all other queries appear in connection.queries, those produced by database access in templtes are no longer present.

Change History (4)

comment:1 by Malcolm Tredinnick, 18 years ago

I think you can work around this by accessing response.content anywhere in your middleware handler function, since that will convert the output to a single string. So you will have something like

def process_response(self, request, response):
    response.content # Force evaluation of content
    ...

Can you test that out and let us know? If it works, we can document that solution.

We don't want to do this unconditionally, since the savings gained through lazy evaluation are enormous in some cases if you can take advantage of them, as noted in the original ticket. However, this side-effect is worth documenting if we can find a workaround.

comment:2 by gpd@…, 18 years ago

Yes, that works. Thanks.

In this case it was in my process_view function and I put the response.content call right after the view_func call has returned.

I'm also using the Stats Middleware from the wiki page, http://code.djangoproject.com/wiki/PageStatsMiddleware. That will need modifying or a note adding for anyone else that may use it.

comment:3 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Malcolm Tredinnick, 17 years ago

Resolution: invalid
Status: newclosed

Since [5482] was subsequently backed out, pending a bunch of unintended side-effects, I don't believe this is a problem any longer. Feel free to reopen if I've missed something.

Note: See TracTickets for help on using tickets.
Back to Top