Min schrieb:
> That code seems to be geared for reading an image from the database
> and serving it, but what about opening an image that sits on the hard
> drive?

open(filename).read()

Diez

> On Aug 14, 6:57 am, "Diez B. Roggisch" <[email protected]> wrote:
>> Min schrieb:
>>
>>> How do I serve up images that sit on the server's hard drive, but not
>>> in the static folder?
>>> I've begun porting over a TG1 site to TG2, and I always used to use
>>> CherryPy's serveFile function to do this, but I haven't been able to
>>> find an equivalent for Pylons.
>>> Alternatively, what are some other common ways people use to serve up
>>> dynamically generated images?
>> There isn't anything special regarding serving files. This is all you
>> shuold need:
>>
>>    @expose(content_type=CUSTOM_CONTENT_TYPE)
>>    def image(self, id):
>>          image = Image.get(id)
>>          pylons.request['Content-Type'] = image.mime_type
>>          return image.data
>>
>> Diez
> > 


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