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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to