@@ -84,7 +84,7 @@ def validate_id_is_docker_compatible(value):
8484def validate_app_structure (value ):
8585 """Error if the dict values aren't ints >= 0."""
8686 try :
87- if any (int (v ) < 0 for v in value .itervalues ()):
87+ if any (int (v ) < 0 for v in value .viewvalues ()):
8888 raise ValueError ("Must be greater than or equal to zero" )
8989 except ValueError , err :
9090 raise ValidationError (err )
@@ -230,7 +230,7 @@ def scale(self, user, structure): # noqa
230230 release = self .release_set .latest ()
231231 # test for available process types
232232 available_process_types = release .build .procfile or {}
233- for container_type in requested_structure . keys () :
233+ for container_type in requested_structure :
234234 if container_type == 'cmd' :
235235 continue # allow docker cmd types in case we don't have the image source
236236 if container_type not in available_process_types :
@@ -242,6 +242,7 @@ def scale(self, user, structure): # noqa
242242 # iterate and scale by container type (web, worker, etc)
243243 changed = False
244244 to_add , to_remove = [], []
245+ # iterate on a copy of the container_type keys
245246 for container_type in requested_structure .keys ():
246247 containers = list (self .container_set .filter (type = container_type ).order_by ('created' ))
247248 # increment new container nums off the most recent container
@@ -613,8 +614,8 @@ def save(self, **kwargs):
613614 try :
614615 previous_build = self .app .build_set .latest ()
615616 to_destroy = []
616- for proctype in previous_build .procfile . keys () :
617- if proctype not in self .procfile . keys () :
617+ for proctype in previous_build .procfile :
618+ if proctype not in self .procfile :
618619 for c in self .app .container_set .filter (type = proctype ):
619620 to_destroy .append (c )
620621 self .app ._destroy_containers (to_destroy )
@@ -665,7 +666,7 @@ def save(self, **kwargs):
665666 new_data = {}
666667 data .update (new_data )
667668 # remove config keys if we provided a null value
668- [data .pop (k ) for k , v in new_data .items () if v is None ]
669+ [data .pop (k ) for k , v in new_data .viewitems () if v is None ]
669670 setattr (self , attr , data )
670671 except Config .DoesNotExist :
671672 pass
0 commit comments