[Seaside] static image files

goran at krampe.se goran at krampe.se
Mon Feb 27 09:15:23 UTC 2006


Brad Fuller <brad at sonaural.com> wrote:
> How do others do it? What is the best way to serve graphics (be it small
> or large!)

Well, for small image files I added WACachedDocument and code, which Avi
merged into Seaside2.6-a3, here is the class comment:
This class is for serving smallish files like PNG images etc using
WADocumentHandler. Using the Canvas API for HTML generation you simply
do this:

	html image fileName: 'myimage.png'


	html image fileName: 'myimage.blurp' mimeType: 'blurp'

This will create a request handler in your WAApplication registry that
is accessible on a unique URL and does not expire.
The actual contents of the file will only be read upon first access, we
could augment this class with smarter caching, like checking the
modification time on disk.

The class has a Cache class var holding a Dictionary of created
instances so you can clear and preload files into the image using:

		fileName: 'myimage.png';
		fileName: 'another.gif'; "etc"

Of course, this code could be further hacked to also deal with large
files (without reading them in full into the image) but you would need
to hack into WAResponse etc.

regards, Göran

More information about the Seaside mailing list