Django

Code

Changeset 7092

Show
Ignore:
Timestamp:
02/05/08 22:10:58 (7 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Removed another FIXME.

This time, simplifying the delete() method.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/db/models/query.py

    r7048 r7092  
    219219        return dict([(obj._get_pk_val(), obj) for obj in qs.iterator()]) 
    220220 
    221     # XXX Mostly DONE 
    222221    def delete(self): 
    223222        """ 
     
    235234        # Delete objects in chunks to prevent the list of related objects from 
    236235        # becoming too long. 
    237         more_objects = True 
    238         while more_objects: 
     236        while 1: 
    239237            # Collect all the objects to be deleted in this chunk, and all the 
    240238            # objects that are related to the objects that are to be deleted. 
    241239            seen_objs = SortedDict() 
    242             more_objects = False 
    243240            for object in del_query[:CHUNK_SIZE]: 
    244                 more_objects = True 
    245241                object._collect_sub_objects(seen_objs) 
    246242 
    247             # If one or more objects were found, delete them. 
    248             # Otherwise, stop looping. 
    249             # FIXME: Does "if seen_objs:.." work here? If so, we can get rid of 
    250             # more_objects. 
    251             if more_objects: 
    252                 delete_objects(seen_objs) 
     243            if not seen_objs: 
     244                break 
     245            delete_objects(seen_objs) 
    253246 
    254247        # Clear the result cache, in case this QuerySet gets reused.