[Zope-CMF] Updating CMFDefault.Image
charlie at begeistert.org
Mon Mar 10 09:13:36 EDT 2008
Am 07.03.2008 um 16:09 schrieb Charlie Clark:
> I've finally started looking at the missing browser views for
> CMFDefault: Image and Folder. Folder looks like a bit of a challenge
> because of the various views required but I think is a fairly
> straightforward migration to using formlib. Image looks like it
> might be a bit of a challenge because the current Image class
> contains presentation logic which might be more suited to views.
> Looking at some of the source for Zope 2.10 it looks like it might
> be time to look at a new implementation of Image and File based on
> zope.app.file rather than OFS.Image. Is this a reasonable assumption
> or have I misunderstood the source?
I now have something working based on zope.app.file but the views are
just as easily implemented with the existing CMF.Image class. I've
currently got this:
"""Return the raw data of the image call as @@index.html"""
response = self.context.request.RESPONSE
"""Return image infos for use in an HTML tag"""
def __init__(self, *args, **kw):
super(TagImageView, self).__init__(*args, **kw)
self.width, self.height = self.context.getImageSize()
self.title = self.context.title
With RawImageView registered as index_html allowing it to be called
from image tags without any decoration, assuming @@index.html is the
default view, and TagImageView providing any additional information.
Can't help but thinking that only one class should be required but
can't think of a way of doing it.
Looking at some of the views, now that I understand them a bit better,
it seems to me that the use of adapters is a bit excessive. Surely it
would be okay to extend the existing IMutable... interfaces with the
form fields and properties? That this hasn't been done hints at the
fact that things aren't that easy.
More information about the Zope-CMF