Am 07.03.2008 um 16:09 schrieb Charlie Clark:
Hi,
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:
class RawImageView(ViewBase):
"""Return the raw data of the image call as @@index.html"""
def __call__(self):
response = self.context.request.RESPONSE
response.setHeader('content-type', self.context.contentType)
response.write(self.context._getData())
class TagImageView(ViewBase):
"""Return image infos for use in an HTML tag"""
@memoize
@decode
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.
Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226
_______________________________________________
Zope-CMF maillist - Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf
See http://collector.zope.org/CMF for bug reports and feature requests