I have the following in one of my TG 1.09 controllers.
@tg.expose(content_type="application/pdf")
@identity.require(identity.has_permission('purchasingReport'))
def futurePriceAnalysisReport(self, *args, **kw):
fromDate = kw['fromDate']
toDate = kw['toDate']
plantId = kw['plant']
excelPdf = kw['excelPdf']
plant = Plant.get(plantId)
fromDate = parse(fromDate)
toDate = parse(toDate)
userId = identity.current.user.id
letters_file = StringIO.StringIO()
fromDate = fromDate.strftime('%Y-%m-%d')
toDate = toDate.strftime('%Y-%m-%d')
fpa.futurePriceAnalysis(letters_file, plant.plantNumber,
fromDate, toDate, excelPdf)
pdf = letters_file.getvalue()
letters_file.close()
return(pdf)
If the excelPdf variable is equal to 'xls' I want to change my content
type to application/vnd.ms-excel. Is there a way for me to do so?
-Jim
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.