I have a little Plone extension which contains a simple Archetypes-based content type (the same which I had not been able to add TTW, see my previous question); the project setup is on GitHub.
After adding an object, I get a KeyError: 'view'
during execution of the plone.abovecontenttitle
content provider:
{'container': <MyType at /plone/test-for-new-types/a-mytype-object>,
'context': <MyType at /plone/test-for-new-types/a-mytype-object>,
'default': <object object at 0x7fc4f8ebe520>,
'here': <MyType at /plone/test-for-new-types/a-mytype-object>,
'loop': {},
'nothing': None,
'options': {'args': ()},
'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x7fc4c9484db8>,
'request': <HTTPRequest, URL=https://my.testing.site/test-for-new-types/a-mytype-object/mytype_view>,
'root': <Application at >,
'template': <FSPageTemplate at /plone/test-for-new-types/a-mytype-object/mytype_view>,
'traverse_subpath': [],
'user': <PloneUser 'me'>}
It should be reproducible easily with my little extension installed in develop
mode.
Edit:
I noticed that, in the "Installed Product" view (/portal_quickinstaller/MyCompany.MyProduct/manage_installationInfo
), my product has Status: installed
and Types MyType
, but Content Type Registry entries
is empty (None
).
Content-providers call adapters, which expect a view
-argument to be present[1] and skin-based templates don't provide, in contradiction to browser-based templates.
To fix that, we can use the global @@plone
-var[2] like it's done in main_template
, because @@plone
is an instance of BrowserView
, it provides the view-argument:
tal:define="view context/@@plone;"
Which makes me think, the adapters the content-providers are using, should regard the case that no view is available.
In case you want to have the usual site-structure and just customize the content-part, you could also fill your template into the content-slot, then everything from main_template is inherited, also the view-var:
<metal:main metal:use-macro="context/main_template/macros/master">
<metal:content fill-slot="content">
Hey, a working content-provider:
<div tal:replace="structure provider:plone.abovecontenttitle" />
Oh, so much more much, here...
</metal:content>
</metal:main>
Which I would recommend, because then you don't need to worry about doing everything right in the header-part. E.g. using "raiseAnon" shouldn't be necessary, because the item's workflow-state is taking care of that and things like the current language will be evaluated, etc.
If you only want to customize the body-part of the content-item, change content
to content-core
, the usual content-providers will be rendered then anyways, you don't need to insert them, if you want them in the usual order.
[1]https://docs.plone.org/4/en/old-reference-manuals/portlets/rendered.html
[2]https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/browser/ploneview.py