How to register a view for content_type image?

I created and registered different types for different types of content. They work fine, but only for content types other than Image and File. I cannot make the view available for the image content type.

There is no layout menu for images. However, views are displayed in /Plone/portal_view_customizations:

Products.ATContentTypes.content.document.ATDocument
    about-view (zope.publisher.interfaces.browser.IDefaultBrowserLayer)
Products.ATContentTypes.content.image.ATImage
    camera-view (zope.publisher.interfaces.browser.IDefaultBrowserLayer)

But it getAvailableLayoutsreturns an empty list for the image and a non-empty list for the document:

>>> image.getAvailableLayouts()
[]
>>> image.getTypeInfo().getAvailableViewMethods(image)
('image_view', 'camera-view')
>>> page.getAvailableLayouts()
[('about-view')]
>>> page.getTypeInfo().getAvailableViewMethods(page)
('document_view', 'about-view')

Next call in getAvailableLayouts()in Products.CMFDynamicViewFTI-4.0.5-py2.7.egg/Products/CMFDynamicViewFTI/browserdefault.pyreturns None

view = zope.component.queryMultiAdapter((self, self.REQUEST),
                                         zope.interface.Interface, 
                                         name='image_view')

Any tips on how to register views for an image and file?

The coding is similar for all my representations and is reproduced here (examples for the document and image):

AT /browser/configure.zcml

<browser:page
    for="Products.ATContentTypes.content.image.ATImage"
    name="camera-view"
    class=".camera_view.CameraView"
    permission="zope2.View"
    template="camera_view.pt"
    />

<browser:page
    for="Products.ATContentTypes.content.document.ATDocument"
    name="about-view"
    class=".about_view.AboutView"
    permission="zope2.View"
    template="about_view.pt"
    />

AT /browser/about_view.py

from Products.Five import BrowserView
class AboutView(BrowserView):
    """ """

AT /profiles/default/types/Document.xml

<object name="Document">
    <property name="view_methods" purge="False">
        <element value="about-view"/>
    </property>
</object>

AT /browser/camera_view.py

from Products.Five import BrowserView
class CameraView(BrowserView):
    """ """

AT /profiles/default/types/Image.xml

<object name="Image">
    <property name="view_methods" purge="False">
        <element value="camera-view"/>
    </property>
</object>

AT /profiles/default/types.xml

<object name="portal_types" meta_type="Plone Types Tool">
    <object name="Document" meta_type="Factory-based Type Information with dynamic views"/>
    <object name="Image" meta_type="Factory-based Type Information with dynamic views"/>
</object>
+3
source
1

Plone 4 ( ) blob ATBlob plone.app.blob, ATImage.

plone.app.blob.interfaces.IATBlobImage, , , ATImage.

+4

All Articles