<HTML><BODY>
<div>Hi;</div>


<div>I've written this code:</div>


<div>&nbsp;</div>


<div>&lt;html&gt;<br>
&lt;body&gt;<br>
&lt;span tal:define="global number here/quotes/randomNumber"&gt;&lt;/span&gt;<br>
&lt;table&gt;&lt;tr&gt;&lt;td&gt;<br>
&lt;span metal:use-macro="here/en-us/quotes/?number/macros/quote"&gt;&lt;/span&gt;&lt;br /&gt;<br>
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;<br>
&lt;/body&gt;<br>
&lt;html&gt;<br>
&nbsp;</div>


<div>...and here's randomNumber, which is an External Method:</div>


<div>&nbsp;</div>


<div>def randomNumber(self):<br>
&nbsp;&nbsp; return randrange(1, len(self.objectValues()), 1)</div>


<div>&nbsp;</div>


<div>but it throws this error which ends with "Iteration over non-sequence". Well, the folder from which it's supposed to select a quote holds nothing but a sequential number of page templates (named 1, 2, 3...). What am I doing wrong?</div>


<div>TIA,</div>


<div>Tony</div>


<div>&nbsp;</div>


<div>&nbsp;</div>


<div><PRE>Traceback (innermost last):
  Module ZPublisher.Publish, line 101, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Shared.DC.Scripts.Bindings, line 306, in __call__
  Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
  Module Products.PageTemplates.ZopePageTemplate, line 222, in _exec
  Module Products.PageTemplates.PageTemplate, line 96, in pt_render
   - &lt;ZopePageTemplate at /footprints.by2012.com/en-us/Articles/Mine/America_How_It_Ends.pt&gt;
  Module TAL.TALInterpreter, line 190, in __call__
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 671, in do_useMacro
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 702, in do_defineSlot
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 409, in do_optTag_tal
  Module TAL.TALInterpreter, line 394, in do_optTag
  Module TAL.TALInterpreter, line 389, in no_tag
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 671, in do_useMacro
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 671, in do_useMacro
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 409, in do_optTag_tal
  Module TAL.TALInterpreter, line 394, in do_optTag
  Module TAL.TALInterpreter, line 389, in no_tag
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 671, in do_useMacro
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 409, in do_optTag_tal
  Module TAL.TALInterpreter, line 394, in do_optTag
  Module TAL.TALInterpreter, line 389, in no_tag
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 637, in do_condition
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 569, in do_insertStructure_tal
  Module Products.PageTemplates.TALES, line 221, in evaluate
   - URL: /templates/frame_content_1
   - Line 5, Column 0
   - Expression: standard:'here/s/getRandomQuote'
   - Names:
      {'container': &lt;Folder instance at e3eca10&gt;,
       'context': &lt;Folder instance at e3eca10&gt;,
       'default': &lt;Products.PageTemplates.TALES.Default instance at 0x8a4b6cc&gt;,
       'here': &lt;Folder instance at e3eca10&gt;,
       'loop': &lt;SafeMapping instance at a8d3b90&gt;,
       'modules': &lt;Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x8a4b06c&gt;,
       'nothing': None,
       'options': {'args': ()},
       'repeat': &lt;SafeMapping instance at a8d3b90&gt;,
       'request': &lt;HTTPRequest, URL=http://footprints.by2012.com/Articles/Mine/America_How_It_Ends.pt&gt;,
       'root': &lt;Application instance at e03c380&gt;,
       'template': &lt;ZopePageTemplate at /footprints.by2012.com/en-us/Articles/Mine/America_How_It_Ends.pt&gt;,
       'traverse_subpath': [],
       'user': Anonymous User}
  Module Products.PageTemplates.Expressions, line 174, in __call__
  Module Products.PageTemplates.Expressions, line 169, in _eval
  Module Products.PageTemplates.Expressions, line 66, in render
  Module Products.PageTemplates.ZRPythonExpr, line 76, in call_with_ns
  Module Shared.DC.Scripts.Bindings, line 320, in __render_with_namespace__
  Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
  Module Products.PageTemplates.ZopePageTemplate, line 222, in _exec
  Module Products.PageTemplates.PageTemplate, line 96, in pt_render
   - &lt;ZopePageTemplate at /s/getRandomQuote&gt;
  Module TAL.TALInterpreter, line 190, in __call__
  Module TAL.TALInterpreter, line 234, in interpret
  Module TAL.TALInterpreter, line 657, in do_useMacro
  Module Products.PageTemplates.TALES, line 221, in evaluate
   - URL: /s/getRandomQuote
   - Line 5, Column 0
   - Expression: standard:'here/en-us/quotes/?number/macros/quote'
   - Names:
      {'container': &lt;Folder instance at e37d4d0&gt;,
       'context': &lt;Folder instance at e37d4d0&gt;,
       'default': &lt;Products.PageTemplates.TALES.Default instance at 0x8a4b6cc&gt;,
       'here': &lt;Folder instance at e37d4d0&gt;,
       'loop': &lt;SafeMapping instance at dbf08f0&gt;,
       'modules': &lt;Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x8a4b06c&gt;,
       'nothing': None,
       'options': {'args': ()},
       'repeat': &lt;SafeMapping instance at dbf08f0&gt;,
       'request': &lt;HTTPRequest, URL=http://footprints.by2012.com/Articles/Mine/America_How_It_Ends.pt&gt;,
       'root': &lt;Application instance at e03c380&gt;,
       'template': &lt;ZopePageTemplate at /s/getRandomQuote&gt;,
       'traverse_subpath': [],
       'user': Anonymous User}
  Module Products.PageTemplates.Expressions, line 174, in __call__
  Module Products.PageTemplates.Expressions, line 162, in _eval
  Module Products.PageTemplates.Expressions, line 107, in _eval
TypeError: iteration over non-sequence
</PRE><SPAN contentEditable=false style="DISPLAY: inline-block"></SPAN></div>

<div class="AOLPromoFooter">
<hr style="margin-top:10px;" />
AOL now offers free email to everyone.  Find out more about what's free from AOL at <a href="http://pr.atwola.com/promoclk/1615326657x4311227241x4298082137/aol?redir=http://www.aol.com" target="_blank"><b>AOL.com</b></a>.<br />
</div>

</BODY></HTML>