Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamicTitle on Plone 3.3 raise error when visiting the FormSaveData2ContentEntry #6

Closed
keul opened this issue Feb 12, 2013 · 8 comments
Labels

Comments

@keul
Copy link
Member

keul commented Feb 12, 2013

I found a problem that can be reproduced only on Plone 3.3.

If you use the dynamicTitle, with whatever expression you lie (also "string:foo") and later you visit a generated content, you'll get an error (something related to loosing context)::

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.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CMFCore.FSPageTemplate, line 155, in pt_render
  Module Products.PageTemplates.PageTemplate, line 98, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.KeyError: 'macro'
  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 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 586, in do_setLocal_tal
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/Users/luca/Library/Buildout/eggs/Plone-3.3.6-py2.4.egg/Products/CMFPlone/skins/plone_templates/global_defines.pt
   - Line 8, Column 0
   - Expression: <PathExpr standard:u'plone_view/globalize'>
   - Names:
      {'container': <PloneSite at /test>,
       'context': <FormSaveData2ContentEntry at /test/test-uw/uww/2013-02-08.8390887068>,
       'default': <object object at 0x10031a200>,
       'here': <FormSaveData2ContentEntry at /test/test-uw/uww/2013-02-08.8390887068>,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x10ad34b48>,
       'request': <HTTPRequest, URL=http://localhost:8080/test/test-uw/uww/2013-02-08.8390887068/base_view>,
       'root': <Application at >,
       'template': <FSPageTemplate at /test/base_view used for /test/test-uw/uww/2013-02-08.8390887068>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 163, in _eval
  Module Products.PageTemplates.Expressions, line 125, in render
  Module Products.CMFPlone.browser.ploneview, line 74, in globalize
  Module Products.CMFPlone.browser.ploneview, line 123, in _initializeData
  Module plone.memoize.view, line 55, in memogetter
  Module plone.app.layout.globals.context, line 197, in actions
  Module Products.CMFPlone.ActionsTool, line 114, in listFilteredActionsFor
  Module Products.CMFPlone.ActionsTool, line 83, in listActionInfos
  Module Products.CMFCore.ActionInformation, line 200, in __getitem__
  Module Products.CMFCore.Expression, line 48, in __call__
  Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
   - __traceback_info__: plone_context_state.canonical_object().restrictedTraverse('@@plone_contentrules_info').show_rules_tab()
  Module PythonExpr, line 1, in <expression>
NameError: name 'plone_context_state' is not defined

If I remove the title override expression all is ok again.

After investigating it, the problem is generated inside the Title method, probably where the product is calling::

exprcontext = getExprContext(self, self)

I'm really not able to understand why (I tried to debug the function call on Plone 4.2 but there's no difference in the output or code execution).

If, for example, I change the context used in that function call (changing it to a non-sense "self, adapter") I get no more error (obviously the context is then wrong).

Have you any suggestion for fixing this issue?

@keul
Copy link
Member Author

keul commented Feb 12, 2013

Forget a detail (maybe it's already clean from the traceback above). Is not the Title call that raise the error (also: the return value from the method call is ok), but someway is the template rendering.

@vangheem
Copy link
Member

should the portal root be one of the expression context arguments? Is self properly acquisition wrapped at that point?

@keul
Copy link
Member Author

keul commented Feb 12, 2013

I really don't understand meaning of parameters of the getExprContext function (a docstring could really help!) but:

a. using getExprContext(self, getSite()) is not good, as the context in TAL expression became the Plone site
b. using getExprContext(getSite(), self) is ok on Plone 4, but I still get the same error on Plone 3.3

@vangheem
Copy link
Member

Can you see what's going on with the expression it's failing on? plone_view/globalize

I'm not quite sure why it'd even be calling the globals template. Is it possible that's customized with your theme?

@keul
Copy link
Member Author

keul commented Feb 12, 2013

The problem is inside plone_view, when defining globals:

...
self._data['actions'] = actions = def_actions or context_state.actions()
...

Also: i tested the problem on a fresh 3.3.6 site so it can't be related to customizations. The problem arise when trying to render the "Rules" content tab (disabling "Rule" tab from portal_action it will brake later on other stuff).

The problem is that I see no link from the error I get and the getExprContext call (which return normally a value).

I'll try to debug this more tomorrow. Thanks for feedback for the moment!

@vangheem
Copy link
Member

No problem. Sorry I can't help more but I don't use Plone 3 at all anymore...

@keul
Copy link
Member Author

keul commented Feb 12, 2013

...you are a lucky guy! :)

@vangheem
Copy link
Member

closing this since I have not heard any feedback. Reopen if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants