<!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&nbsp;might make your life easier if you used a 
dtml-let (WARNING: untested):</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&lt;dtml-in 
dictList="ScriptThatReturnsAListofDicts()"&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp; &lt;dtml-let 
aDict="_['sequence-item']"&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-if 
"aDict.has_key('titled')"&gt;</FONT></DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do 
something here</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>But this is still pretty ugly.&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Jonathan</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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 &lt;dtml-in...<BR>and within the dtml-in body I have:<BR>&lt;dtml-var 
  "_.getitem('sequence-item')['titled']" missing="none"&gt;<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.&nbsp; Another option is that I can use &lt;dtml-if 
  "_.getitem('sequence-item').has_key('titled')"&gt; but it doesn't work, says 
  has_key is an unknown attribute.&nbsp; 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&nbsp; 
  -&nbsp; 
  Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**&nbsp;&nbsp; 
  No cross posts or HTML encoding!&nbsp; **<BR>(Related lists - 
  <BR>&nbsp;http://mail.zope.org/mailman/listinfo/zope-announce<BR>&nbsp;http://mail.zope.org/mailman/listinfo/zope-dev 
  )<BR></BLOCKQUOTE></BODY></HTML>