KeyError: 'view' when rendering document_view - plone

Migration from 2.5 to 3.3.5. I inherited a plone system that we have to migrate to 3.3.5 to keep the site accredited. I know zilch about plone and come from primarily a windows administration, sharepoint and .net programming background.
I feel like I'm so close to having this working.
When I navigate to a page, the page comes up with an error code instead of content (improvement over having the traceback show up instead of the page). The error is now this:
Exception traceback
Time 2012/09/19 11:24:04.160 GMT-7
User Name (User Id) Anonymous User (None)
Request URL http://localhost:8080/mission-vision/index_html/document_view
Exception Type KeyError
Exception Value 'view'
Traceback (innermost last):
Module ZPublisher.Publish, line 119, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 42, in call_object
Module Shared.DC.Scripts.Bindings, line 313, in __call__
Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
Module Products.PageTemplates.ZopePageTemplate, line 330, in _exec
Module Products.PageTemplates.ZopePageTemplate, line 427, in pt_render
Module Products.PageTemplates.PageTemplate, line 98, in pt_render
Module zope.pagetemplate.pagetemplate, line 117, in pt_render
Module zope.tal.talinterpreter, line 271, in __call__
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 891, in do_useMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 957, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 949, in do_defineSlot
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 861, in do_defineMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 536, in do_optTag_tal
Module zope.tal.talinterpreter, line 521, in do_optTag
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 891, in do_useMacro
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 534, in do_optTag_tal
Module zope.tal.talinterpreter, line 516, in no_tag
Module zope.tal.talinterpreter, line 346, in interpret
Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
Module Products.PageTemplates.Expressions, line 223, in evaluateStructure
Module zope.tales.tales, line 696, in evaluate
URL: file:d:\websites\nipo\plone 3.3.5\buildout-cache\eggs\plone-3.3.5-py2.4.egg\Products\CMFPlone\skins\plone_deprecated\document_actions.pt
Line 27, Column 4
Expression: <StringExpr u'plone.documentactions'>
Names:
{'container': <PloneSite at /Plone>,
'context': <ATDocument at /Plone/mission-vision/index_html>,
'default': <object object at 0x010BD528>,
'here': <ATDocument at /Plone/mission-vision/index_html>,
'loop': {},
'nothing': None,
'options': {'args': ()},
'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x04A37B98>,
'request': <HTTPRequest, URL=http://localhost:8080/mission-vision/index_html/document_view>,
'root': <Application at >,
'template': <ZopePageTemplate at /Plone/document_view used for /Plone/mission-vision/index_html>,
'traverse_subpath': [],
'user': <SpecialUser 'Anonymous User'>}
Module Products.Five.browser.providerexpression, line 17, in __call__
KeyError: 'view'
It looks like the problem is in the document_view template. Which is odd because it hasn't been modified at all, it's straight out of the box:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="here/main_template/macros/master"
i18n:domain="plone">
<body>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="kssClassesView context/##kss_field_decorator_view;
getKssClasses nocall:kssClassesView/getKssClassesInlineEditable;
templateId template/getId;
text here/getText;">
<div tal:replace="structure provider:plone.abovecontenttitle" />
<h1 class="documentFirstHeading">
<metal:field use-macro="python:here.widget('title', mode='view')">
Title
</metal:field>
</h1>
<div tal:replace="structure provider:plone.belowcontenttitle" />
<p class="documentDescription">
<metal:field use-macro="python:here.widget('description', mode='view')">
Description
</metal:field>
</p>
<div tal:replace="structure provider:plone.abovecontentbody" />
<p tal:condition="python: not text and is_editable"
i18n:translate="no_body_text"
class="discreet">
This item does not have any body text, click the edit tab to change it.
</p>
<metal:field use-macro="python:here.widget('text', mode='view')">
Body text
</metal:field>
<div metal:use-macro="here/document_relateditems/macros/relatedItems">
show related items if they exist
</div>
<div tal:replace="structure provider:plone.belowcontentbody" />
</tal:main-macro>
</metal:main>
</body>
</html>
Anyone know why this is coming up?

Related

Use show_placeholder inside inclusion tag template in Django CMS

I'm trying to create a portfolio overview page using Django CMS.
I have my detail pages already and they have a placeholder called preview-img. For my portfolio overview page, I need to loop over all detail pages and render that placeholder.
The Django docs tell me that an inclusion tag is the way to go. So I defined my tag (show_portfolio) in the templatetags directory such that it returns the pages:
from django import template
from cms.models.pagemodel import Page
from django.template import RequestContext
register = template.Library()
#register.inclusion_tag('portfolio_item.html', takes_context=True)
def show_portfolio(context, parent_slug):
cms_pages = Page.objects.public()
cms_pages = [
page for page in cms_pages
if page.parent_page and page.parent_page.get_slug() == parent_slug
]
return {
'cms_pages': cms_pages,
}
It simply returns the page objects with a given parent page (via slug).
The template in which I now loop over the cms_pages is this (note the attempt to render each pages' preview show_placeholder):
[portfolio_item.html]
{% load cms_tags %}
<div class="row">
{% for page in cms_pages %}
...
{% show_placeholder "preview-img" page %}
...
{% endfor %}
</div>
Running this, the server hits an uncaught KeyError (key: request) when trying to evaluate show_placeholder. I do not see the connection to what I'm doing. Where does the request come into play? Is it even possible to use show_placeholder inside the template of an inclusion tag?
Here's the trace for completeness:
Traceback:
File ".../python3.6/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File ".../python3.6/site-packages/django/core/handlers/base.py" in _get_response
217. response = self.process_exception_by_middleware(e, request)
File ".../python3.6/site-packages/django/core/handlers/base.py" in _get_response
215. response = response.render()
File ".../python3.6/site-packages/django/template/response.py" in render
107. self.content = self.rendered_content
File ".../python3.6/site-packages/django/template/response.py" in rendered_content
84. content = template.render(context, self._request)
File ".../python3.6/site-packages/django/template/backends/django.py" in render
66. return self.template.render(context)
File ".../python3.6/site-packages/django/template/base.py" in render
207. return self._render(context)
File ".../python3.6/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File ".../python3.6/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File ".../python3.6/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File ".../python3.6/site-packages/classytags/core.py" in render
153. return self.render_tag(context, **kwargs)
File ".../python3.6/site-packages/sekizai/templatetags/sekizai_tags.py" in render_tag
93. rendered_contents = nodelist.render(context)
File ".../python3.6/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File ".../python3.6/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File ".../python3.6/site-packages/classytags/core.py" in render
153. return self.render_tag(context, **kwargs)
File ".../python3.6/site-packages/cms/templatetags/cms_tags.py" in render_tag
443. return toolbar.render_with_structure(context, nodelist)
File ".../python3.6/site-packages/cms/toolbar/toolbar.py" in render_with_structure
498. rendered_contents = nodelist.render(context)
File ".../python3.6/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File ".../python3.6/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File ".../python3.6/site-packages/django/template/library.py" in render
245. return t.render(new_context)
File ".../python3.6/site-packages/django/template/base.py" in render
209. return self._render(context)
File ".../python3.6/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File ".../python3.6/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File ".../python3.6/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File ".../python3.6/site-packages/django/template/defaulttags.py" in render
216. nodelist.append(node.render_annotated(context))
File ".../python3.6/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File ".../python3.6/site-packages/django/template/library.py" in render
203. output = self.func(*resolved_args, **resolved_kwargs)
File ".../python3.6/site-packages/cms/templatetags/cms_tags.py" in _show_placeholder_by_id
116. request = context['request']
File ".../python3.6/site-packages/django/template/context.py" in __getitem__
87. raise KeyError(key)
I got this working in my test setup by explicitly passing the request in the context for the inclusion tag:
from django import template
from cms.models.pagemodel import Page
register = template.Library()
#register.inclusion_tag('portfolio_item.html', takes_context=True)
def show_portfolio(context, parent_slug):
cms_pages = Page.objects.public()
cms_pages = [
page for page in cms_pages
if page.parent_page and page.parent_page.get_slug() == parent_slug
]
return {
'request': context.request,
'cms_pages': cms_pages,
}

Angular 4.x - CSS Background color not changing IE11

I have some code within an Angular 4.x application that works fine in Chrome/Firefox but does nothing within Internet Explorer 11 - a user clicks a div which changes the css background colour of the div.header (no issues in modern browsers) but within IE11 - can anyone suggest why this is?
<div class="header" [style.background-color]="note ? colours[note.colour] : selectedColor">
<div (click)="selectColor('#3b589799', 'blue')" class="select opt --blue"></div>
<div (click)="selectColor('#bf3a2b99', 'red')" class="select opt --red"></div>
<div (click)="selectColor('#4cae4f99', 'green')" class="select opt --green"></div>
// js controller
selectColor(color, choice): void {
this.selectedColor = color;
this.selected = choice;
}
<div (click)="selectColor('rgba(59, 88, 151, 0.6)')" class="select opt --blue">b</div>
<div (click)="selectColor('rgba(191, 58, 43, 0.6)')" class="select opt --red">r</div>
<div (click)="selectColor('rgba(76, 174, 79, 0.6)')" class="select opt --green">g</div>
use rgba as i am using. it works.

Invalid RSS Feed / <media>

does somebody know what is wrong with my RSS Feed?
I see this message:
Line 69 is as follows:
<media:content url="http://elbmadame.de/wp-content/uploads/2016/03/perito_moreno_gletscher_titel-620x450.jpg" type="" medium="image" width="620" height="450"><media:description type="plain"><![CDATA[Patagonien: eine Reise zum Perito Moreno Gletscher. Oder: wenn hausgroße Eisbrocken fallen.]]></media:description><media:copyright>Jasmin</media:copyright></media:content> </item>
Thanks.
You are using the media: namespace prefix without defining it as pointing to a namespace (with xmlns:media="some namespace identifier")

Problems with same page scroll plugin in django-cms

I need to make a same-page scroll design with links on a sidebar that scrollto anchors for different sections within the same page.
I am trying to use the cmsplugin-sections and run into a 'NoneType' object is not iterable error when trying to add a section container. Someone opened an identical issue too on the same subject a few days ago. Below the trace:
Any help most welcome as I am new to django-cms. MAybe another plugin with the same functionality? Basically I need an custom text plugin for each section which has a title field and a display menu title too.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/en/?edit
Django Version: 1.8.9
Python Version: 2.7.9
Installed Applications:
('djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_text_ckeditor',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'reversion',
'grounded_change',
'cmsplugin_sections')
Installed Middleware:
('cms.middleware.utils.ApphookReloadMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware')
Template error:
In template /Users/user/templates/fullwidth.html, error at line 7
'NoneType' object is not iterable
1 : {% extends "base.html" %}
2 : {% load cms_tags %}
3 :
4 : {% block title %}{% page_attribute "page_title" %}{% endblock title %}
5 :
6 : {% block content %}
7 : {% placeholder "content" %}
8 : {% endblock content %}
9 :
Traceback:
File "/Users/user/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
response = response.render() File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/response.py" in render
self.content = self.rendered_content File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/response.py" in rendered_content
content = template.render(context, self._request) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/backends/django.py" in render
return self.template.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in render
return self._render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in _render
return self.nodelist.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in render
bit = self.render_node(node, context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/debug.py" in render_node
return node.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/loader_tags.py" in render
return compiled_parent._render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in _render
return self.nodelist.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in render
bit = self.render_node(node, context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/debug.py" in render_node
return node.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/classytags/core.py" in render
return self.render_tag(context, **kwargs) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/sekizai/templatetags/sekizai_tags.py" in render_tag
rendered_contents = nodelist.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in render
bit = self.render_node(node, context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/debug.py" in render_node
return node.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/classytags/core.py" in render
return self.render_tag(context, **kwargs) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cms/templatetags/cms_tags.py" in render_tag
rendered_contents = nodelist.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in render
bit = self.render_node(node, context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/debug.py" in render_node
return node.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/loader_tags.py" in render
result = block.nodelist.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/base.py" in render
bit = self.render_node(node, context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/django/template/debug.py" in render_node
return node.render(context) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/classytags/core.py" in render
return self.render_tag(context, **kwargs) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cms/templatetags/cms_tags.py" in render_tag
content = get_placeholder_content(context, request, page, name, inherit, nodelist) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cms/templatetags/cms_tags.py" in get_placeholder_content
content = render_placeholder(placeholder, context, name) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cms/plugin_rendering.py" in render_placeholder
content.extend(render_plugins(plugins, context, placeholder, processors)) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cms/plugin_rendering.py" in render_plugins
out.append(plugin.render_plugin(context, placeholder, processors=processors)) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cms/models/pluginmodel.py" in render_plugin
context = plugin.render(context, instance, placeholder_slot) File "/Users/user/.virtualenvs/gc/lib/python2.7/site-packages/cmsplugin_sections/cms_plugins.py" in render
for child in instance.child_plugin_instances:
Exception Type: TypeError at /en/
Exception Value: 'NoneType' object is not iterable
I managed to overcome this by:
Editing the cms_plugins.py file, basically adding an if statement before the for loops to check whether there is anything inside the section container to iterate
Running python manage.py migrate to create the tables (not mentioned in the installation instructions)

symfony2: how to include line breaks / newlines in translations?

how am I supposed to get line breaks working in Symfony 2.4?
#messages.de.yml
foo: |
Hello i am a line
Hello i am a new line
and
#messages.de.yml
foo: >
Hello i am a line
Hello i am a new line
twig
#template.html.twig
{{ 'foo'|trans }}
The translation is working but line breaks aren't.
The documentation isn't really clear to me. Hints will be highly appreciated.
Twig does not convert line feeds to <br /> automatically.
Use the nl2br filter.
#template.html.twig
{{ 'foo'|trans|nl2br }}
I'm not quite sure but eventually you'll have to add \n to the translation strings additonally.
#messages.<locale>.yml
foo: >
Hello i am a line \n
Hello i am a new line
In your YAML file use:
foo: |
first line
second line
and in your TWIG file:
<p>{{ 'foo'|trans|nl2br }}</p>
tested on:
Symfony version 2.6.6
twig/twig 1.x-dev 6792014
For me the following version did the trick:
foo: "| Hello \n this is a new line"

Resources