Ticket #9865 (closed Bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Acquisition in IAdding + object fails

Reported by: do3cc Owned by: hannosch
Priority: minor Milestone: 4.0
Component: Upgrade/Migration Version:
Keywords: TuneUp26 Cc:

Description

Acquisition is no longer working on the + object in Plone 4. I modified an existing project to work with Plone 4, one of the actions I needed to do, was adding the new add_view_expr that should point to the right url. That works, so this is not the issue. But upon accessing that url, I get an AttributeError for the attribute main_template.

Further, the code in question that tries to call the main_template is not in my project, but the form plone/app/form/addingpageform.pt

I have created a minimal test case, that tries to get the maintemplate via unrestrictedTraverse. The test passes in Plone 3.3 and fails in Plone 4.

Some information that might be interesting. The code:

adding = self.portal.unrestrictedTraverse('+') print 'adding', adding print 'bases', adding.class.bases print 'is implicit:', isinstance(adding, Implicit)

The output in Plone 3.3: adding <+ at +> bases (<class 'plone.app.content.browser.adding.CMFAdding'>, <class 'Products.Five.browser.metaconfigure.ViewMixinForTemplates'>) is implicit: True

The output in Plone 4: adding <+ at /plone/+> bases (<class 'plone.app.content.browser.adding.CMFAdding'>, <class 'Products.Five.browser.metaconfigure.ViewMixinForTemplates'>) is implicit: True

Maybe this is relevant for the issue, I am not sure:  http://zope3.pov.lt/trac/changeset/78447/

Attachments

test_adding_acquisition.py Download (681 bytes) - added by do3cc 4 years ago.
Minimal test case to simulate the issue

Change History

Changed 4 years ago by do3cc

Minimal test case to simulate the issue

comment:1 Changed 4 years ago by do3cc

  • Milestone set to 4.0

comment:2 Changed 4 years ago by hannosch

  • Owner set to hannosch
  • Status changed from new to assigned

comment:3 Changed 4 years ago by davisagli

Yes, this is definitely related to the removal of implicit acquisition from the adding view -- now main_template and other things can no longer be implicitly acquired via the adding view by the form's template. That seems like a bad thing to me; can we revert it, Hanno?

In the meantime, you can probably work around it by editing your form's template and wrapping it with something that redefines context as context/context

comment:4 Changed 4 years ago by do3cc

That helps in the test case provided, but not in the add view.

The add view comes, btw, from plone.app.form. If I patch that view, I get an exception. The main_template does some acquisition tricks that fail too.

Basically getTypeInfo is not found on the context.

This is the full traceback

  • Module ZPublisher.Publish, line 127, in publish
  • Module ZPublisher.mapply, line 77, in mapply
  • Module ZPublisher.Publish, line 47, in call_object
  • Module zope.formlib.form, line 786, in call
  • Module zope.formlib.form, line 906, in render
  • Module zope.formlib.form, line 776, in render
  • Module plone.app.form._named, line 32, in call
  • Module Products.Five.browser.pagetemplatefile, line 126, in call
  • Module Products.Five.browser.pagetemplatefile, line 60, in call
  • Module zope.pagetemplate.pagetemplate, line 115, in pt_render Warning: Macro expansion failed Warning: <type 'exceptions.KeyError'>: 'global_cache_settings'
  • Module zope.tal.talinterpreter, line 271, in call
  • Module zope.tal.talinterpreter, line 343, in interpret
  • Module zope.tal.talinterpreter, line 888, in do_useMacro
  • Module zope.tal.talinterpreter, line 343, in interpret
  • Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  • Module zope.tal.talinterpreter, line 518, in do_optTag
  • Module zope.tal.talinterpreter, line 513, in no_tag
  • Module zope.tal.talinterpreter, line 343, in interpret
  • Module zope.tal.talinterpreter, line 583, in do_setLocal_tal
  • Module zope.tales.tales, line 696, in evaluate URL: file:/home/patrick/projects/collective_git/borg.project/eggs/plonetheme.sunburst-1.0a5-py2.6.egg/plonetheme/sunburst/skins/sunburst_templates/main_template.pt Line 6, Column 0 Expression: <PythonExpr plone_view.mark_view(view)> Names:

{'args': (),

'container': <+ at /Plone/+>, 'context': <+ at /Plone/+>, 'default': <object object at 0x7f663cde9b30>, 'here': <+ at /Plone/+>, 'loop': {}, 'nothing': None, 'options': {}, 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x6716248>, 'request': <HTTPRequest, URL= http://127.0.0.1:8080/Plone/+/borg.project.Project>, 'root': <Application at >, 'template': <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x4a78ed0>, 'traverse_subpath': [], 'user': <PropertiedUser 'admin'>, 'view': <Products.Five.metaclass.ProjectAddForm object at 0x6d26110>, 'views': <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x6dfa450>}

  • Module Products.PageTemplates.ZRPythonExpr, line 49, in call traceback_info: plone_view.mark_view(view)
  • Module PythonExpr, line 1, in <expression>
  • Module Products.CMFPlone.browser.ploneview, line 43, in mark_view
  • Module plone.memoize.view, line 44, in memogetter
  • Module plone.app.layout.globals.context, line 115, in is_view_template
  • Module plone.memoize.view, line 44, in memogetter
  • Module plone.app.layout.globals.context, line 95, in view_template_id
  • Module plone.app.layout.globals.context, line 232, in _lookupTypeActionTemplate

AttributeError: getTypeInfo

comment:5 Changed 4 years ago by hannosch

(In [33745]) Added test for adding view and Acquisition interaction. This refs #9865.

comment:6 Changed 4 years ago by hannosch

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [33747]) Mixed in Acquisition.Implicit back into the CMFAdding class. CMF skins depend on it inside templates. This closes #9865.

comment:7 Changed 4 years ago by hannosch

  • Keywords TuneUp26 added

Mark this as being closed during TuneUp26 :)

Note: See TracTickets for help on using tickets.