-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
thanks a lot, john. that's it :) alex lilspikey wrote: > Hi Alex, > well diving into the source for the expose decorator ( > http://trac.turbogears.org/browser/branches/1.0/turbogears/controllers.py > ) reveals that this should work: > > cherrypy.response.headers["Content-Type"] = content_type > > I guess that's what you're after? > > cheers, > John > > On Jan 10, 10:10 am, alex bodnaru <[EMAIL PROTECTED]> wrote: > smart idea, thanks. > > but i don't really want a function for every mime type :). > > thanks, and hope for more suggestions. > > alex > > > > lilspikey wrote: > >>>> On Jan 10, 3:02 am, alex bodnaru <[EMAIL PROTECTED]> wrote: >>>>> hi friends, >>>>> setting @expose(content_type="image/jpeg") allows me to serve a string >>>>> blob for a jpeg image. >>>>> could i set the content_type later in the function, after my code >>>>> decides it's type? >>>>> thanks in advance, >>>> Well one way is to simply call another function that has been >>>> decorated with @expose(content_type="image/jpeg") later on. e.g.: >>>> @expose() >>>> def something(self): >>>> # decide stuff here >>>> if serve_jpeg: >>>> return self._as_jpeg(jpeg_data) >>>> @expose(content_type="image/jpeg") >>>> def _as_jpeg(self,jpeg_data): >>>> return jpeg_data >>>> That would leave _as_jpeg() exposed and callable, so you might want to >>>> use it as a plain function, so that it can't be called directly. >>>> cheers, >>>> John > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQCVAwUBR4c+vdpwN1sq38njAQJQDgP7BWGnfajFY1GGiubsvoAxteIZG2sT03Oq InOiyggXpMVdPRtKUL8TzO7Fcr83CBRLxZFzB2GH9I+LOU7dbemxR6fHm/2HTd+D oA4dD5z2fjwP7+sM92+wqvLa7QDXELIlvmUM7TSsL2AbJHu3E6+PiAlqPzvaye5e T4zNt1fZSZE= =KGkF -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

