Opened 8 years ago

Closed 8 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
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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 Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 8 years ago by gpd@…

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, That will need modifying or a note adding for anyone else that may use it.

comment:3 Changed 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 8 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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