Russell Keith-Magee wrote:
> On Wed, May 14, 2008 at 1:20 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> Russell Keith-Magee wrote:
>>> On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>> What are the chances of getting a dumpdata hack to exclude certain apps?
>>
>> I know it isn't too hard to figure out what apps I want to backup, but it 
>> sounds
>> like the 'exclude' feature might be useful even once this issue is resolved.
> 
> It's a reasonable idea - one well worth suggesting as a feature
> enhancement (I have a nagging feeling that there is something in there
> already, but I could be getting confused).
> 
> What are the chances such a fix will automagically materialize out of
> the ether? Not high. What are the chances that a patch implementing
> this feature would be added to trunk? Fairly good, conditional on the
> quality of the patch.

I am not submitting here, I just want to discuss it first.

1. what do you think of this syntax I invented:
  --option "list of items"

I don't like it, but not sure how else to do it.

2. should I leave in --debug?  I really meant it for debugging, but I can see 
it 
being handy to debug the "list of items" and such.

Why does the current code has 'json' listed in 2 places:
make_option('--format', default='json'
options.get('format', 'json')

note: "default - Deprecated; use parser.set_defaults() instead. "
http://docs.python.org/lib/optparse-option-attributes.html


Index: dumpdata.py
===================================================================
--- dumpdata.py (revision 7534)
+++ dumpdata.py (working copy)
@@ -9,6 +9,10 @@
              help='Specifies the output serialization format for fixtures.'),
          make_option('--indent', default=None, dest='indent', type='int',
              help='Specifies the indent level to use when pretty-printing 
output'),
+        make_option('--exclude', default=None, dest='exclude',
+            help='List of apps to exclude ("space seperated").'),
+        make_option('--debug', dest='debug', action='store_true',
+            help='Prints the list of apps excluded, to be processed, and 
exits.'),
      )
      help = 'Output the contents of the database as a fixture of the given 
format.'
      args = '[appname ...]'
@@ -18,6 +22,8 @@

          format = options.get('format', 'json')
          indent = options.get('indent', None)
+        exclude = options.get('exclude')
+        debug = options.get('debug')
          show_traceback = options.get('traceback', False)

          if len(app_labels) == 0:
@@ -25,6 +31,18 @@
          else:
              app_list = [get_app(app_label) for app_label in app_labels]

+        if exclude:
+            excl_apps = [get_app(app_label) for app_label in exclude.split()]
+            for excl_app in excl_apps:
+                app_list.remove(excl_app)
+                if debug:
+                    print "excluded: %s" % excl_app.__name__
+
+        if debug:
+            for app in app_list:
+                print "included: %s" % app.__name__
+            return
+
          # Check that the serialization format exists; this is a shortcut to
          # avoid collating all the objects and _then_ failing.
          if format not in serializers.get_public_serializer_formats():

Carl K

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to