If these transformations are constant and you want to keep the images
around, I'd suggest using the static folder (or placing them in the db
if more control is needed).
We perform some transformations on the fly (which sounds like you
*may* be doing the same) and use a controller to server them. This
solution would still require modification of the html to point to this
controller though...
Example:
import cStringIO
def view():
''' action to get an image and display image
image_manager is a placeholder for data acquisition '''
img = request.args[0]
data = image_manager.get_image(img)
if not data: raise HTTP(404)
filename = "%s.png" % image_manager.get_filename(img)
response.headers["Content-Type"] = "image/png"
response.headers["Content-Disposition"] = "attachment; filename=
%s;" % filename
return response.stream(cStringIO.StringIO(data))
Then you just need an image_manager object to perform the mythical
transformation and return the data as a StringIO object. This way the
images/files do not have to be in the DB and are not in the 'static'
folder.
Note: The above code was typed out on screen, so may not be great (or
work for that matter). Also in general you likely want to get content
type from the file (or request), instead of hardcoding it as above.
Hope this helps
On Jul 29, 6:11 am, Hege <[email protected]> wrote:
> I've found that:
>
> (in httpserver.log)
> ..., GET, /tapir/default/test, HTTP/1.1, 200, 0.018923
> ..., GET, /tapir/default/
> tapir_proces_169_0_1_123_9043794a_fe13_4bf3_8c28_609408551db9test_odt.doc_html_b4fd3c9.png,
> HTTP/1.1, 400, 0.000671
> ... GET, /tapir/default/
> tapir_proces_169_0_1_123_9043794a_fe13_4bf3_8c28_609408551db9test_odt.doc_html_m36545889.jpg,
> HTTP/1.1, 400, 0.000549
>
> in html file is:
> "
> <IMG SRC="tapir_proces_169_0_1_123_9043794a_fe13_4bf3....
> So, the problem is that html is returned via
> response.stream(open(request.vars.url,'rb'),chunk_size=4096) --->/
> tapir/default/test
> and images aren't in /tapir/default/... and application can't find
> them to serve
>
> Solution would be modify html file so, it points <IMG SRC="/tapir/
> static/tapir_proces_169_0_1_123_9043794a_fe13_4bf3... and copy those
> graphic files to tapir/static.
>
> Is there any other possibility ?