I've just modified the method "render" of the class CPSCompoundWidget in the
module BasicWidgets.py
The code I propose is below. The only thing I dubt is if the check (not
widget.hidden_empty or rendered) is still needed. It's to say, if
widget.hidden_empty is true, does that mean that cell['widget_mode'] will be
true? In that case the check won't be necessary.
Thank you.
#####################################################
def render(self, mode, datastructure, **kw):
"""Render in mode from datastructure."""
layout = aq_parent(aq_inner(self))
widget_infos = kw['widget_infos']
cells = []
for widget_id in self.widget_ids:
cell = {}
# widget, widget_mode, css_class
cell.update(widget_infos[widget_id])
widget = layout[widget_id]
widget_mode = cell['widget_mode']
if widget_mode != 'hidden':
rendered = widget.render(widget_mode, datastructure, **kw)
rendered = rendered.strip()
cell['widget_rendered'] = rendered
if not widget.hidden_empty or rendered:
# do not add widgets to be hidden when empty
cells.append(cell)
render = self._getRenderMethod()
return render(mode=mode, datastructure=datastructure,
cells=cells, **kw)
#####################################################
JoseLuis de la Rosa Triviño
Becario Área de Sistemas de Información
FUNDACIÓN IAVANTE
[EMAIL PROTECTED]
Tel. 951 015 300
Este correo electrónico y, en su caso, cualquier fichero anexo, contiene
información confidencial exclusivamente dirigida a su(s) destinatario(s). Toda
copia o divulgación deberá ser autorizada por IAVANTE.
This e-mail and any attachments are confidential and exclusively directed to
its adressee(s). Any copy or distribution will have to be authorized by IAVANTE.
-----Mensaje original-----
De: Florent Guillaume [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 27 de abril de 2006 12:59
Para: JoseLuis de la Rosa Triviño
CC: [email protected]
Asunto: Re: [CPS-devel] Runtime error: Unknown mode hidden
I've opened http://svn.nuxeo.org/trac/pub/ticket/1627 for this.
Florent
On 27 Apr 2006, at 12:48, JoseLuis de la Rosa Triviño wrote:
> I modified the raise sentence and there's no spaces in the layout
> mode:
>
> Raise RuntimeError('unknown mode %r' % mode)
> RuntimeError: unknown mode 'hidden'
>
> However I don't generate the identifier of the layout mode, It's
> generated automatically when I say to hide in view mode.
> The error can be reproduced with this steps in a brand new CPS
> instance:
>
> 1.- Create a News Item in workspaces
> 2.- Go to portal_layouts->newsitem_end
> 3.- Add a new html widget with id "subwidget" with some content in
> "html for view" and "hidden in layout modes" with value "view".
> 4.- Add a new compound widget with id "superwidget" and in
> 5.- Try to show the News Item created in the first step and the
> error should appear.
>
> Thank you.
>
> JoseLuis de la Rosa Triviño
> Becario Área de Sistemas de Información
> FUNDACIÓN IAVANTE
> [EMAIL PROTECTED]
> Tel. 951 015 300
>
>
> Este correo electrónico y, en su caso, cualquier fichero anexo,
> contiene información confidencial exclusivamente dirigida a su(s)
> destinatario(s). Toda copia o divulgación deberá ser autorizada por
> IAVANTE.
>
> This e-mail and any attachments are confidential and exclusively
> directed to its adressee(s). Any copy or distribution will have to
> be authorized by IAVANTE.
>
>
>
> -----Mensaje original-----
> De: Florent Guillaume [mailto:[EMAIL PROTECTED]
> Enviado el: jueves, 27 de abril de 2006 11:39
> Para: JoseLuis de la Rosa Triviño
> Asunto: Re: [CPS-devel] Runtime error: Unknown mode hidden
>
> Removing hidden widgets is done in two phases in Layout.py.
> In your case it should be done. Are you sure you don't have a space
> after or before 'hidden' ?
> To make sure, replace the %s by a %r in the raise at the last line of
> the traceback.
>
> Florent
>
> On 27 Apr 2006, at 11:02, JoseLuis de la Rosa Triviño wrote:
>
>> Hello,
>>
>>
>> I'm working with CPS 3.4 and I'm using compound widgets. When a
>> widget that is inside a compound widget should be hidden, this
>> error occurs:
>>
>>
>> ######################################################
>>
>> 2006-04-27 09:56:56 ERROR Zope.SiteErrorLog http://
>> 10.207.248.60:4000/bpi_des/cpsdirectory_entry_view
>>
>> Traceback (most recent call last):
>>
>> File "/opt/zope2.9/lib/python/ZPublisher/Publish.py", line 114,
>> in publish
>>
>> request, bind=1)
>>
>> File "/opt/zope2.9/lib/python/ZPublisher/mapply.py", line 88, in
>> mapply
>>
>> if debug is not None: return debug(object,args,context)
>>
>> File "/opt/zope2.9/lib/python/ZPublisher/Publish.py", line 40, in
>> call_object
>>
>> result=apply(object,args) # Type s<cr> to step into published
>> object.
>>
>> File "/opt/zope2.9/lib/python/Shared/DC/Scripts/Bindings.py",
>> line 311, in __call__
>>
>> return self._bindAndExec(args, kw, None)
>>
>> File "/opt/zope2.9/lib/python/Shared/DC/Scripts/Bindings.py",
>> line 348, in _bindAndExec
>>
>> return self._exec(bound_data, args, kw)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CMFCore/
>> FSPageTemplate.py", line 195, in _exec
>>
>> result = self.pt_render(extra_context=bound_names)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CMFCore/
>> FSPageTemplate.py", line 134, in pt_render
>>
>> result = FSPageTemplate.inheritedAttribute('pt_render')(
>>
>> File "/opt/zope2.9/lib/python/Products/PageTemplates/
>> PageTemplate.py", line 104, in pt_render
>>
>> tal=not source, strictinsert=0)()
>>
>> File "/opt/zope2.9/lib/python/TAL/TALInterpreter.py", line 238,
>> in __call__
>>
>> self.interpret(self.program)
>>
>> File "/opt/zope2.9/lib/python/TAL/TALInterpreter.py", line 281,
>> in interpret
>>
>> handlers[opcode](self, args)
>>
>> File "/opt/zope2.9/lib/python/TAL/TALInterpreter.py", line 507,
>> in do_setLocal_tal
>>
>> self.engine.setLocal(name, self.engine.evaluateValue(expr))
>>
>> File "/opt/zope2.9/lib/python/Products/PageTemplates/TALES.py",
>> line 221, in evaluate
>>
>> return expression(self)
>>
>> File "/opt/zope2.9/lib/python/Products/PageTemplates/
>> ZRPythonExpr.py", line 47, in __call__
>>
>> return eval(code, g, {})
>>
>> File "Python expression "dir.renderEntryDetailed(id)"", line 1,
>> in <expression>
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CPSDirectory/
>> BaseDirectory.py", line 562, in renderEntryDetailed
>>
>> layout_mode=layout_mode, **kw)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CPSDirectory/
>> BaseDirectory.py", line 932, in _renderLayout
>>
>> layout.renderLayoutStructure(layout_structure, datastructure,
>> **kw)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CPSSchemas/
>> Layout.py", line 391, in renderLayoutStructure
>>
>> widget_infos=widget_infos, **kw)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CPSSchemas/
>> BasicWidgets.py", line 2030, in render
>>
>> rendered = widget.render(widget_mode, datastructure, **kw)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CPSSchemas/
>> BasicWidgets.py", line 2030, in render
>>
>> rendered = widget.render(widget_mode, datastructure, **kw)
>>
>> File "/root/instances/zope2.9/innovaDes/Products/CPSSchemas/
>> BasicWidgets.py", line 295, in render
>>
>> raise RuntimeError('unknown mode %s' % mode)
>>
>> RuntimeError: unknown mode hidden
>>
>> #################################################################
>>
>>
>> I have found the code in BasicWidgets.py, but in these classes I
>> can't find an example of how hidden mode is handled in other cases.
>> So I think this is controled before the call to render the widget.
>>
>> The question is, where should I control to avoid the widget get
>> rendered if the mode is hidden?
>>
>> I wouldn't like to modify BasicWidgets.py because in that case my
>> product would depend on a customized CPSSchemas.
>>
>>
>> Thank you very much.
>>
>> JoseLuis de la Rosa Triviño
>> Becario Área de Sistemas de Información
>> FUNDACIÓN IAVANTE
>> [EMAIL PROTECTED]
>> Tel. 951 015 300
>>
>>
>> Este correo electrónico y, en su caso, cualquier fichero anexo,
>> contiene información confidencial exclusivamente dirigida a su(s)
>> destinatario(s). Toda copia o divulgación deberá ser autorizada por
>> IAVANTE.
>>
>> This e-mail and any attachments are confidential and exclusively
>> directed to its adressee(s). Any copy or distribution will have to
>> be authorized by IAVANTE.
>>
>>
>> _______________________________________________
>> cps-devel mailing list
>> http://lists.nuxeo.com/mailman/listinfo/cps-devel
>
> --
> Florent Guillaume, Nuxeo (Paris, France) Director of R&D
> +33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED]
>
>
--
Florent Guillaume, Nuxeo (Paris, France) Director of R&D
+33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED]
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel