|
Re: File downloads etc: msg#00123lang.smalltalk.squeak.seaside
On Jan 10, 2006, at 12:13 AM, goran@xxxxxxxxx wrote:
I use Apache on the side :) But anyway...
Good question. I assume there's some good reason, but I honestly don't remember what. Anyway, suppose we add these two methods to WAImageTag: Hm, well, the problem with doing that is that although you're caching the contents in the image, you're also reading the file from disk every time, which does seem awfully wasteful. The right thing to do here is to add a level of abstraction and create a new document class. What #urlForDocument: is expecting is something with the following two properties: - it responds reasonably to #asMIMEDocument - it has a reasonable implementation of #= (most likely, it is #= to other things that produce the identical mime document) Beyond that, you can be as smart as you like. So, I would do something like: - Create a FileDocument class that holds onto the file name or path - Two FileDocuments with the same path are #= - #asMIMEDocument reads in the file stream on demand. It may cache it, with whatever caching policy seems reasonable, check the mtime of the file etc. For bonus points, have #= take the mtime of the cached version into account so that two FileDocuments are *not* equal if their mtimes differ; this means a new URL will be generated every time the file on disk changes and so clients will immediately get the updated content. I assume these handlers stick around for the session lifetime? Hmmm, ok Yes, they stick around effectively forever, so be careful with them... End usage with WACanvas: Certainly can't complain about the final API :) PS. I assume WAImageTag>>resourceUrl: is for referring to stuff served Yep, that's the idea. Avi |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | File downloads etc: 00123, goran |
|---|---|
| Next by Date: | Re: File downloads etc: 00123, Bert Freudenberg |
| Previous by Thread: | File downloads etci: 00123, goran |
| Next by Thread: | Re: File downloads etc: 00123, goran |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |