App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
google.appengine._internal.django.core.management.base.BaseCommand Class Reference
Inheritance diagram for google.appengine._internal.django.core.management.base.BaseCommand:
google.appengine._internal.django.core.management.base.AppCommand google.appengine._internal.django.core.management.base.LabelCommand google.appengine._internal.django.core.management.base.NoArgsCommand google.appengine._internal.django.core.management.commands.compilemessages.Command google.appengine._internal.django.core.management.commands.dbshell.Command google.appengine._internal.django.core.management.commands.dumpdata.Command google.appengine._internal.django.core.management.commands.loaddata.Command google.appengine._internal.django.core.management.commands.makemessages.Command google.appengine._internal.django.core.management.commands.runfcgi.Command google.appengine._internal.django.core.management.commands.runserver.Command google.appengine._internal.django.core.management.commands.test.Command google.appengine._internal.django.core.management.commands.testserver.Command

Public Member Functions

def __init__
 
def get_version
 
def usage
 
def create_parser
 
def print_help
 
def run_from_argv
 
def execute
 
def validate
 
def handle
 

Public Attributes

 style
 
 stdout
 
 stderr
 

Static Public Attributes

tuple option_list
 
string help = ''
 
string args = ''
 
 can_import_settings = True
 
 requires_model_validation = True
 
 output_transaction = False
 

Detailed Description

The base class from which all management commands ultimately
derive.

Use this class if you want access to all of the mechanisms which
parse the command-line arguments and work out what code to call in
response; if you don't need to change any of that behavior,
consider using one of the subclasses defined in this file.

If you are interested in overriding/customizing various aspects of
the command-parsing and -execution behavior, the normal flow works
as follows:

1. ``django-admin.py`` or ``manage.py`` loads the command class
   and calls its ``run_from_argv()`` method.

2. The ``run_from_argv()`` method calls ``create_parser()`` to get
   an ``OptionParser`` for the arguments, parses them, performs
   any environment changes requested by options like
   ``pythonpath``, and then calls the ``execute()`` method,
   passing the parsed arguments.

3. The ``execute()`` method attempts to carry out the command by
   calling the ``handle()`` method with the parsed arguments; any
   output produced by ``handle()`` will be printed to standard
   output and, if the command is intended to produce a block of
   SQL statements, will be wrapped in ``BEGIN`` and ``COMMIT``.

4. If ``handle()`` raised a ``CommandError``, ``execute()`` will
   instead print an error message to ``stderr``.

Thus, the ``handle()`` method is typically the starting point for
subclasses; many built-in commands and command types either place
all of their logic in ``handle()``, or perform some additional
parsing work in ``handle()`` and then delegate from it to more
specialized methods as needed.

Several attributes affect behavior at various steps along the way:

``args``
    A string listing the arguments accepted by the command,
    suitable for use in help messages; e.g., a command which takes
    a list of application names might set this to '<appname
    appname ...>'.

``can_import_settings``
    A boolean indicating whether the command needs to be able to
    import Django settings; if ``True``, ``execute()`` will verify
    that this is possible before proceeding. Default value is
    ``True``.

``help``
    A short description of the command, which will be printed in
    help messages.

``option_list``
    This is the list of ``optparse`` options which will be fed
    into the command's ``OptionParser`` for parsing arguments.

``output_transaction``
    A boolean indicating whether the command outputs SQL
    statements; if ``True``, the output will automatically be
    wrapped with ``BEGIN;`` and ``COMMIT;``. Default value is
    ``False``.

``requires_model_validation``
    A boolean; if ``True``, validation of installed models will be
    performed prior to executing the command. Default value is
    ``True``. To validate an individual application's models
    rather than all applications' models, call
    ``self.validate(app)`` from ``handle()``, where ``app`` is the
    application's Python module.

Member Function Documentation

def google.appengine._internal.django.core.management.base.BaseCommand.create_parser (   self,
  prog_name,
  subcommand 
)
Create and return the ``OptionParser`` which will be used to
parse the arguments to this command.
def google.appengine._internal.django.core.management.base.BaseCommand.execute (   self,
  args,
  options 
)
Try to execute this command, performing model validation if
needed (as controlled by the attribute
``self.requires_model_validation``). If the command raises a
``CommandError``, intercept it and print it sensibly to
stderr.
def google.appengine._internal.django.core.management.base.BaseCommand.get_version (   self)
Return the Django version, which should be correct for all
built-in Django commands. User-supplied commands should
override this method.
def google.appengine._internal.django.core.management.base.BaseCommand.handle (   self,
  args,
  options 
)
The actual logic of the command. Subclasses must implement
this method.
def google.appengine._internal.django.core.management.base.BaseCommand.print_help (   self,
  prog_name,
  subcommand 
)
Print the help message for this command, derived from
``self.usage()``.
def google.appengine._internal.django.core.management.base.BaseCommand.run_from_argv (   self,
  argv 
)
Set up any environment changes requested (e.g., Python path
and Django settings), then run this command.
def google.appengine._internal.django.core.management.base.BaseCommand.usage (   self,
  subcommand 
)
Return a brief description of how to use this command, by
default from the attribute ``self.help``.
def google.appengine._internal.django.core.management.base.BaseCommand.validate (   self,
  app = None,
  display_num_errors = False 
)
Validates the given app, raising CommandError for any errors.

If app is None, then this will validate all installed apps.

Member Data Documentation

tuple google.appengine._internal.django.core.management.base.BaseCommand.option_list
static
Initial value:
1 = (
2  make_option('-v', '--verbosity', action='store', dest='verbosity', default='1',
3  type='choice', choices=['0', '1', '2'],
4  help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
5  make_option('--settings',
6  help='The Python path to a settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.'),
7  make_option('--pythonpath',
8  help='A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".'),
9  make_option('--traceback', action='store_true',
10  help='Print traceback on exception'),
11  )

The documentation for this class was generated from the following file: