<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>It might make your life easier if you used a
dtml-let (WARNING: untested):</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><dtml-in
dictList="ScriptThatReturnsAListofDicts()"></FONT></DIV>
<DIV><FONT face=Arial size=2> <dtml-let
aDict="_['sequence-item']"></FONT></DIV>
<DIV><FONT face=Arial size=2> <dtml-if
"aDict.has_key('titled')"></FONT></DIV>
<DIV><FONT face=Arial
size=2> do
something here</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But this is still pretty ugly. Another
approach would be to clean up the data in your list/dicts within the python
script, before you get to the dtml method.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Jonathan</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=aluminum3458@yahoo.com href="mailto:aluminum3458@yahoo.com">Alric
Aneron</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=zope@zope.org
href="mailto:zope@zope.org">zope@zope.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, June 19, 2006 2:46 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Zope] dictionary from
sequence-item</DIV>
<DIV><BR></DIV>Hello,<BR>I am looping through a list of dictionary objects
using <dtml-in...<BR>and within the dtml-in body I have:<BR><dtml-var
"_.getitem('sequence-item')['titled']" missing="none"><BR>Some of the
dictionaries in the list don't have 'titled' key so it should replace it with
the word "none", but it gives me an error<BR><STRONG>Error Type:
KeyError</STRONG><BR><STRONG>Error Value: 'titled'<BR></STRONG>I don't
understand. Another option is that I can use <dtml-if
"_.getitem('sequence-item').has_key('titled')"> but it doesn't work, says
has_key is an unknown attribute. This is the stupidest thing ever! it's
a dictionary object!<BR>I try to typecast it using the
dict(_.getitem('sequence-item')).has_key('titled') it gives me an error saying
it can't typecast, but I am 100% sure it's a dictionary object because I can
access it easily _.getitem('sequence-item')['titled'] for those that have that
key.<BR><BR>Any idea how I can check if the titled key is in the dictionary
for the current list item?<BR><BR>Thanks in advance guys!<BR>
<P>
<HR SIZE=1>
<A
href="http://us.rd.yahoo.com/mail_us/taglines/postman3/*http://us.rd.yahoo.com/evt=39666/*http://messenger.yahoo.com">Yahoo!
Messenger with Voice.</A> PC-to-Phone calls for ridiculously low rates.
<P>
<HR>
<P></P>_______________________________________________<BR>Zope maillist
-
Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**
No cross posts or HTML encoding! **<BR>(Related lists -
<BR> http://mail.zope.org/mailman/listinfo/zope-announce<BR> http://mail.zope.org/mailman/listinfo/zope-dev
)<BR></BLOCKQUOTE></BODY></HTML>