Fix TypeError on comparison on Python 3

On Python 3, comparison between None and int or comparison between
dictionaries raises a TypeError.

LaunchForm: use 0 default value instead of None to compare it to 1.

sort() and sorted(): use a key function to compare strings instead of
comparing dictionaries.

Partial-Implements: blueprint porting-python3
Change-Id: I0664c2f6c19c3f105da8b4b5a72cea4eb02c245d
This commit is contained in:
Victor Stinner 2015-10-06 16:39:04 +02:00
parent 3bc8d1dadd
commit 6c037cf70b

@ -135,7 +135,7 @@ class LaunchForm(forms.SelfHandlingForm):
datastore = datastore_field_value.split(',')[0]
if db_capability.is_mongodb_datastore(datastore):
if self.data.get("num_shards", None) < 1:
if self.data.get("num_shards", 0) < 1:
msg = _("The number of shards must be greater than 1.")
self._errors["num_shards"] = self.error_class([msg])