How to exclude Confera messages?
Based on code others have suggested on this list, I've implemented a "breadcrumbs" navigation stack method. The code is below. It works well unless I navigate into a Confera message object, where it fails with the Traceback included below. I don't understand why it fails, but that's OK. I don't really need for it to put Confera messages on the breadcrumbs stack. What I would like to know is: How can I detect and exclude a Confera message? Can anyone help me out? -- Thanks -- Loren <!--#call "REQUEST.set('dirs', [])"--> <!--#in expr="PARENTS" skip_unauthorized--> <!--#call "dirs.insert(0, id)"--> <!--#/in--> <!--#in dirs--> <!--#with "_[_['sequence-item']]"--> <!--#if "_['sequence-start']"--> <a href="/">Home</a> <!--#else--> <!--#if "_['sequence-end']"--> > <!--#var title_or_id--> <!--#else--> > <a href="<!--#var absolute_url-->"><!--#var id--></a> <!--#/if--> <!--#/if--> <!--#/with--> <!--#/in--> Sorry, an error occurred. Traceback (innermost last): File lib/python/ZPublisher/Publish.py, line 877, in publish_module File lib/python/ZPublisher/Publish.py, line 590, in publish (Info: //Discuss/934833119/index_html) File lib/python/Products/Confera/Confera.py, line 541, in index_html File lib/python/OFS/DTMLMethod.py, line 155, in __call__ (Object: message_html) File lib/python/OFS/DTMLMethod.py, line 151, in __call__ (Object: message_html) File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: message_html) File lib/python/OFS/DTMLMethod.py, line 147, in __call__ (Object: standard_html_header) File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: standard_html_header) File lib/python/OFS/DTMLMethod.py, line 147, in __call__ (Object: breadcrumbs) File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: breadcrumbs) File lib/python/DocumentTemplate/DT_In.py, line 683, in renderwob (Object: dirs) File lib/python/DocumentTemplate/DT_With.py, line 133, in render (Object: _[_['sequence-item']]) File lib/python/DocumentTemplate/DT_Util.py, line 266, in eval (Object: _[_['sequence-item']]) File <string>, line 0, in ? File lib/python/DocumentTemplate/DT_Util.py, line 150, in careful_getitem KeyError: Sorry, an error occured
I built an example on a public site. Go to http://209.67.167.51/Quena/Discuss, then click on the "Announce..." message. -- Loren
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Loren Stafford Sent: Tuesday, August 24, 1999 11:18 To: zope@zope.org Subject: [Zope] How to exclude Confera messages?
Based on code others have suggested on this list, I've implemented a "breadcrumbs" navigation stack method. The code is below. It works well unless I navigate into a Confera message object, where it fails with the Traceback included below.
I don't understand why it fails, but that's OK. I don't really need for it to put Confera messages on the breadcrumbs stack.
What I would like to know is: How can I detect and exclude a Confera message? Can anyone help me out?
-- Thanks -- Loren
<!--#call "REQUEST.set('dirs', [])"--> <!--#in expr="PARENTS" skip_unauthorized--> <!--#call "dirs.insert(0, id)"--> <!--#/in-->
<!--#in dirs--> <!--#with "_[_['sequence-item']]"-->
<!--#if "_['sequence-start']"--> <a href="/">Home</a> <!--#else--> <!--#if "_['sequence-end']"--> > <!--#var title_or_id--> <!--#else--> > <a href="<!--#var absolute_url-->"><!--#var id--></a> <!--#/if--> <!--#/if-->
<!--#/with--> <!--#/in-->
Sorry, an error occurred.
Traceback (innermost last): File lib/python/ZPublisher/Publish.py, line 877, in publish_module File lib/python/ZPublisher/Publish.py, line 590, in publish (Info: //Discuss/934833119/index_html) File lib/python/Products/Confera/Confera.py, line 541, in index_html File lib/python/OFS/DTMLMethod.py, line 155, in __call__ (Object: message_html) File lib/python/OFS/DTMLMethod.py, line 151, in __call__ (Object: message_html) File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: message_html) File lib/python/OFS/DTMLMethod.py, line 147, in __call__ (Object: standard_html_header) File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: standard_html_header) File lib/python/OFS/DTMLMethod.py, line 147, in __call__ (Object: breadcrumbs) File lib/python/DocumentTemplate/DT_String.py, line 513, in __call__ (Object: breadcrumbs) File lib/python/DocumentTemplate/DT_In.py, line 683, in renderwob (Object: dirs) File lib/python/DocumentTemplate/DT_With.py, line 133, in render (Object: _[_['sequence-item']]) File lib/python/DocumentTemplate/DT_Util.py, line 266, in eval (Object: _[_['sequence-item']]) File <string>, line 0, in ? File lib/python/DocumentTemplate/DT_Util.py, line 150, in careful_getitem KeyError: Sorry, an error occured
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
Loren Stafford wrote:
I built an example on a public site. Go to http://209.67.167.51/Quena/Discuss, then click on the "Announce..." message.
<!--#call "REQUEST.set('dirs', [])"--> <!--#in expr="PARENTS" skip_unauthorized--> <!--#call "dirs.insert(0, id)"--> <!--#/in-->
<!--#in dirs--> <!--#with "_[_['sequence-item']]"-->
<!--#if "_['sequence-start']"--> <a href="/">Home</a> <!--#else--> <!--#if "_['sequence-end']"--> > <!--#var title_or_id--> <!--#else--> > <a href="<!--#var absolute_url-->"><!--#var id--></a> <!--#/if--> <!--#/if-->
<!--#/with--> <!--#/in-->
Sorry, an error occurred. KeyError: Sorry, an error occured
I don't know off hand what your problem is, but I believe your DTML can be simplified by removing the building of the 'dirs' list, and extra with tag, and several python expressions. Here is a simplified, 'post-modern' Zope version of your DTML: <dtml-in PARENTS skip_unauthorized> <dtml-if sequence-start> <a href="/">Home</a> <dtml-else> <dtml-if sequence-end> > <dtml-var title_or_id> <dtml-else> > <a href="<dtml-var absolute_url>"><dtml-var id></a> </dtml-if> </dtml-if> </dtml-in> First, the inner layer with tag could be removed. Saying: <dtml-in sequence> <dtml-with sequence-item> <dtml-var whatever> </dtml-with> </dtml-in> is the same as: <dtml-in sequence> <dtml-var whatever> </dtml-in> The 'sequence-item' namespace is the first namespace on the top of the namespace stack while you are in an 'in' tag. The <dtml-with> is redundant. If you want to whole list PARENTS, it is not necesary to put it in quotes, because you are using it by name. Notice I also took 'sequence-item', 'sequence-start' and 'sequence-end' out of their "_['']" notation. This is because you are also using them by name, like PARENTS, so it is not necesary to quote them in an expression. If you had wanted to use 'sequence-item' in an expression, you would then need to use the quotes, like: <dtml-var "_['sequence-item'] * 5">. You can use PARENTS in an expression when you want a specific item out of the list, like <dtml-var "PARENTS[-1]"> (which is always the root folder, by the way). Since you had a keyerror it is likely that the 'dirs' list was causing it. It's removal might fix your bug. Otherwise, I'd say the Confera object is probably missing something that you want out of it. -Michel
With Michel's help, I got the following navigation stack method running at http://209.67.167.51/Quena/Discuss. It no longer causes an error when I navigate to a Confera message, but it doesn't do the right thing either. Try it. What I don't know how to do is test the type of the current object from inside an <!--#in--> loop. That is, how do I test if sequence-item is a 'Folder', 'Confera Topic', 'Message', or what? Can you help? -- Thanks -- Loren <!-- Start Breadcrumbs --> <!--#unless expr="PARENTS[0]==PARENTS[-1]"--> <!--#call "REQUEST.set('reverse_PARENTS', [])"--> <!--#in PARENTS skip_unauthorized--> <!--#call "reverse_PARENTS.insert(0, _['sequence-item'])"--> <!--#/in--> <!--#in reverse_PARENTS--> <!--#var sequence-item--> <!--#if sequence-start--><a href="/">Home</a> <!--#else--> <!--#if sequence-end--> > <font size="+1" color="#990000"><b><!--#var title_or_id--></b></font> <!--#else--> > <a href="<!--#var absolute_url-->"><!--#var id--></a> <!--#/if--> <!--#/if--> <!--#/in--> <!--#/unless--> <!-- End Breadcrumbs -->
participants (2)
-
Loren Stafford -
Michel Pelletier