Back to index

plone3  3.1.7
getXMLSelectVocab.py
Go to the documentation of this file.
00001 ## Script (Python) "getXMLSelectVocab"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=method,param,value
00008 ##title=Get a DisplayList and format for XML request
00009 
00010 params = {param:value, 'display_list': True}
00011 
00012 vocab = getattr(context, method)(**params)
00013 site_encoding = context.plone_utils.getSiteEncoding()
00014 
00015 RESPONSE = context.REQUEST.RESPONSE
00016 RESPONSE.setHeader('Content-Type', 'text/xml;charset=%s' % site_encoding)
00017 translate = context.translate
00018 
00019 results = [(translate(vocab.getValue(item)),item) for item in vocab]
00020 
00021 item_strings = [u'^'.join(a) for a in results]
00022 result_string = u'|'.join(item_strings)
00023 
00024 return "<div>%s</div>" % result_string.encode(site_encoding)