[Zope] - Image object enhancements (patch included!)

Phillip J. Eby pje@telecommunity.com
Mon, 07 Dec 1998 20:42:43 -0500


At 04:51 PM 12/7/98 -0600, Ty Sarna wrote:
>Kent Polk wrote:
>> > The __str__ method on images really needs to figure out the true
>> > absolute path of the object and use that. (like <IMG SRC="/site/logo">)
>> 
>> I'm a bit worried that this will tend to break acquisition behavior
>> in general. For these types of problem, I'd tend to just specify the
>> absolute URL in the reference. Deals with the problem without having
>> to change acquisition.
>
>I don't think it would break anything. Basically, you know that the
>identical Image object is available at this other place, so you're just
>precalculating the acquisition. Instead of telling the browser that the
>image is at B when it's really at A, and then having a fetch of it at B
>acquire the version at A, the Image object just short-circuits this and
>tells the browser that it's at A to begin with. The change would be
>local to the Image product and wouldn't affect the Acquisition machinery
>at all.
>
>Then again, I haven't tried it yet, so maybe I'm missing something. And
>I'd better get back to work before you come over here and beat me up :^)

My ImageFile class for ASDF has a __repr__ method that returns a
(more-or-less) absolute URL, and it doesn't break anything,
acquisition-wise.  I wouldn't worry about it breaking in ZOPE.  I define
__str__ roughly the same way as in ZOPE (i.e., <IMG SRC="id">), but have
__repr__ just return the URL.  This makes it easy to do <IMG SRC="<!--#var
"`image`"-->" WIDTH=...> stuff.