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 Changing the options in manage.py, adding more signals
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 14 2007, 12:05 pm
From: George Vilches <g...@thataddress.com>
Date: Tue, 14 Aug 2007 12:05:57 -0400
Local: Tues, Aug 14 2007 12:05 pm
Subject: Re: Changing the options in manage.py, adding more signals

Marty Alchin wrote:
> This sounds like a far more complicated example than I had considered
> when I was doing my work with dynamic models[1], but I did have
> success getting syncdb to install dynamic models, provided a few
> things are in order. I probably didn't document them well enough on
> the wiki, but I could do so if this is a real need you have.

> I also can't speak for how well your audit example would work on the
> whole using that method, but if it's a real task for somebody, I'd
> love to help work it out. In theory though, given my past experience,
> it would be possible to do in such a way that a single line in each
> audit-enabled model would trigger all the hard work, enabling syncdb
> and even admin integration.

> Keep in mind that I have no opinion on the real meat of this thread,
> I'm just chiming in to help clarify what is and isn't possible with
> dynamic models.

> -Gul

> [1] http://code.djangoproject.com/wiki/DynamicModels

That page was a great start, that's where I started to figure most of it
out when I started down this path a while back.  And what I described is
a fully working app, but I've not exposed it because I'm not so sure
that it really fits into the spirit of Django, even on the contrib side.
:)  That having been said, it's something we very much needed for our
current app, and the current branch in the Django trunk for doing
history just doesn't have the performance for large DBs, especially with
large change counts (one table in columnar key/value fashion just won't
cut it, especially for reporting purposes).  We had to have row-based to
do reporting on millions of historical entries at any speed.  (And it's
also much faster for re-constructing history at the DB level, we can
recreate any table at any point in time with a roll-forward type
approach from the audit tables, columnar requires a lot more processing
to do the same).

As far as how well it works, it's great across the board. :)  We have
the syncdb signal stuff working fine (all the missing tables are created
happily, and I don't have to write any custom SQL, I just piggyback on
the things in django/core/management which do a fine job, since a Model
is a Model, dynamic or not), and it's actually really solid under load,
and easy to add into an existing model to "turn on" auditing.  Here's an
example of how you use it:

class SomeModel(models.Model):
   c1 = models.CharField(maxlength=10)
   c2 = models.ForeignKey(SomeOtherModel)

   class Audit:
     pass

That's it.  I think it's nifty. :)  Calling save() or delete() on the
model automagically writes the audit entries and all the related tasks,
all you have to do is add the Audit app to the INSTALLED_APPS, and all
the rest is handled, and it doesn't require any hackery to the Django
codebase, which makes it near perfect for my uses. :)

So, the problem itself is actually solved for the runtime portion of the
app.  The *only* thing that I found myself missing is the ability to
generate the correct DROP TABLE/CREATE TABLE/CREATE INDEX type SQL in a
printable manner that the Django manage.py commands could hook into and
either display or run.  When I reset an app, I want to reset all my
audit tables in that app as well, and there's just no signals in place
(and no way to inject SQL code for display even if the signals were
there, like in syncdb).  Same for "manage.py sql", "manage.py sqlclear",
and etc.  So, that's at least part of where this all came from, and all
the more reason that I like the --sql flag and reducing the manage.py
set of SQL-related options to something more straightforward.

Thoughts?

Thanks,
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.