def _encode_dictionary dictionary content for key in sorted dictionary

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def _encode_dictionary(dictionary):
content=''
for key in sorted(dictionary.keys()):
if isinstance(key,(StringType,StringTypes)):
content+=(encode(key)+encode(dictionary[key]))
else:
raise InvalidData(key,"dictionary keys must be strings")
return 'd%se' %content