I am about 95% through a filesystem product that stores the object data on the filesystem. All my views inside ZMI work nice but I am having a couple of troubles with my views of my repository files in CMF. So I am looking for a bit of advice to help me to get past the final 5%

With this type of product I made an OFS-based product and a portal based product. Instead of creating two distinct products I used the same approach that OFSImage and portal image use. Portal image subclasses OFSImage and as a result there is very little to it. In anycase, I subclassed my OFSbased filesystem product so that I would not have so much work to have all the methods that were created for the OFS based product. The OFS product subclasses Persistent, Implicit, PropertyManager, RoleManager, Item_w__name__, Cacheable

Because the portal filesystem object can have any mime type, I am making a view template for my product that uses tal:condition to display something appropriate for the content types depending on what it gets. I looked at fileEdit for some ideas on this since it is the manage_main for ZMI and seems to do pretty much the right thing. My goal is this:

* images/jpeg images/gif images/png display the image in view if less than 64K in size (otherwise provide link for download) * text/* provides text editing through Cooked body for text files if less than 64K in size (otherwise provide link for download)
* any other mime type just gives link to download the file.

Instead of reinventing the wheel, CMF also has a document_view and image_view template so I am attempting to incorporate these in my template. The key tal in here is ' tal:replace="structure here/tag" ' for portal image and ' tal:structure here/CookedBody' for text document.

The initial problem I got was attribute error with tag method. (Tag method is responsible for grabbing img tag and contents with portal image rendering.) I am not quite sure how tag does because I haven't found the method to view it but it seems to take the content from the OFSImage view and takes img tag and everything inside it. But I did not originally subclass OFSImage (which is the base of portal image). To solve this, I just made the image tag in my template and gave it absolute_url as tal:attribute for src. So now I get my image to appear for conditions that fit image which is fine.

But for my text files such as HTML, plain text and restructured text, I wanted to use CookedBody method which is already called in standard document_view template since this will allow users to modify their documents even if the object's data is not really in the object database. So getting attribute error on CookedBody and trying to figure out what this needs to work.

I guess I am wondering where I may have missed the boat that my Images and text can't use the same methods already available in CMF- would adding OFSImage to my subclasses in my OFSbased product help? My problem is I don't really know tag method or CookedBody and what they need to render content. Hoping someone has some suggestions. My thinking is that perhaps I am missing something in my subclassing that could have made this work better so it could use same view methods consistently (just conditional on content type in a single template instead of as separate templates). Sorry about the long message. Many thanks.

Regards,
David


_______________________________________________
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

Reply via email to