Back to index

plone3  3.1.7
displayValue.py
Go to the documentation of this file.
00001 ## Script (Python) "Display Value"
00002 ##title=Use DisplayList getValue method to translate internal value to a label
00003 ##bind container=container
00004 ##bind context=context
00005 ##bind namespace=
00006 ##bind script=script
00007 ##bind subpath=traverse_subpath
00008 ##parameters=vocab, value
00009 
00010 
00011 try:
00012     # Maybe a string?
00013     value.capitalize()
00014 except AttributeError:
00015     try:
00016         # Maybe a list?
00017         return ', '.join([vocab.getValue(context.unicodeEncode(v),
00018                                          context.unicodeEncode(v)) \
00019                           for v in value if v])
00020     except TypeError:
00021         pass
00022 
00023 # Try to convert to a string and do the dirty job.
00024 return vocab.getValue(context.unicodeEncode(value),
00025                       context.unicodeEncode(value))