Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion Adding hooks to methods that generate SQL in django/core/management.py
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
George Vilches  
View profile  
 More options Aug 13 2007, 9:29 am
From: George Vilches <g...@thataddress.com>
Date: Mon, 13 Aug 2007 09:29:21 -0400
Local: Mon, Aug 13 2007 9:29 am
Subject: Re: Adding hooks to methods that generate SQL in django/core/management.py

Russell Keith-Magee wrote:
> On 8/12/07, George Vilches <g...@thataddress.com> wrote:
>> How about the patch below?  When you create the cursor, if you want
>> access to "don't run this SQL, just have playback available", just use
>> connection.cursor(playback_only=True), and if you want to roll the

> This is a simple approach that would probably suffice for
> management.py based problems, but it isn't really practical on a large
> scale. For example, QuerySets open their own connections, so it won't
> be easy to pass an argument to an ORM call to enable capture of
> playback data.

> The configuration option will need to be a little more generic - i.e.,
> putting the entire backend into a record mode - not just a single
> cursor call.

Alright, that makes sense.  So, my thought is, if we can't change the
call to connection.cursor() on each instantiation, we're going to need
some sort of static variable store that can get updated at runtime (or
some global).  I know that settings is right out for anything that
changes at runtime, is there a Django-friendly way of storing a variable
of this nature?  If we can store this variable in some more non-code
changing way, the rest of the patch should be fine, right?  Here's my
two thoughts for hopefully Django-friendly approaches:

First, Brian Ferring's base class could have a static or class variable
easily enough, but I'd like this landing not to depend on that refactor,
since that could be a while coming.

Second, we could add a class level variable to each DatabaseWrapper,
since the handle to those seem to be instantiated only once at runtime
(at least, my short testing with just the Django built-in webserver
seemed to do so, I only assume that for Apache it's once per thread).
That would be an easy enough variable to update from pretty much
anywhere in the app:

     connection.playback_only = True

*should* be all we would need, anywhere in the app.  If need be, we can
add a helper to disguise this call, but every connection.cursor()
creation at that would just need to check for self.playback_only to get
the same effect as in the previously sent patch.

Thoughts?
George


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.