~ubuntuone-pqm-team/canonical-identity-provider/trunk

« back to all changes in this revision

Viewing changes to identityprovider/management/commands/sqlcachedflush.py

  • Committer: Danny Tamez
  • Date: 2010-04-21 15:29:24 UTC
  • Revision ID: danny.tamez@canonical.com-20100421152924-lq1m92tstk2iz75a
Canonical SSO Provider (Open Source) - Initial Commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
from django.core.management.commands.flush import Command as FlushCommand
 
5
from django.core.management.color import no_style
 
6
 
 
7
 
 
8
class Command(FlushCommand):
 
9
    cached_flush = None
 
10
 
 
11
    def handle_noargs(self, **options):
 
12
        from django.db import connection
 
13
        from django.core.management.sql import sql_flush
 
14
        self.style = no_style()
 
15
        if self.cached_flush is not None:
 
16
            cursor = connection.cursor()
 
17
            cursor.execute(self.cached_flush)
 
18
        else:
 
19
            super(Command, self).handle_noargs(**options)
 
20
            # Call sql_flush instead of picking up the raw queries because
 
21
            # it's better SQL.
 
22
            queries = sql_flush(self.style, only_django=True)
 
23
            Command.cached_flush = ';'.join(queries)