#NEWLINE# def choices_from_dict( source , prepend_blank = True ) : #NEWLINE# #INDENT# '\n    Convert a dict to a format that\'s compatible with WTForm\'s choices. It also\n    optionally prepends a "Please select one..." value.\n\n    Example:\n      # Convert this data structure:\n      STATUS = OrderedDict([\n          (\'unread\', \'Unread\'),\n          (\'open\', \'Open\'),\n          (\'contacted\', \'Contacted\'),\n          (\'closed\', \'Closed\')\n      ])\n\n      # Into this:\n      choices = [(\'\', \'Please select one...\'), (\'unread\', \'Unread) ...]\n\n    :param source: Input source\n    :type source: dict\n    :param prepend_blank: An optional blank item\n    :type prepend_blank: bool\n    :return: list\n    ' #NEWLINE# choices = [ ] #NEWLINE# if prepend_blank : #NEWLINE# #INDENT# choices . append ( ( '' , _ ( 'Please select one...' ) ) ) #NEWLINE# #UNINDENT# for ( key , value ) in source . iteritems ( ) : #NEWLINE# #INDENT# pair = ( key , value ) #NEWLINE# choices . append ( pair ) #NEWLINE# #UNINDENT# return prepend_blank