<HTML><BODY>
<div>Hi;</div>
<div>I've written this code:</div>
<div> </div>
<div><html><br>
<body><br>
<span tal:define="global number here/quotes/randomNumber"></span><br>
<table><tr><td><br>
<span metal:use-macro="here/en-us/quotes/?number/macros/quote"></span><br /><br>
</td></tr></table><br>
</body><br>
<html><br>
</div>
<div>...and here's randomNumber, which is an External Method:</div>
<div> </div>
<div>def randomNumber(self):<br>
return randrange(1, len(self.objectValues()), 1)</div>
<div> </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> </div>
<div> </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
- <ZopePageTemplate at /footprints.by2012.com/en-us/Articles/Mine/America_How_It_Ends.pt>
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': <Folder instance at e3eca10>,
'context': <Folder instance at e3eca10>,
'default': <Products.PageTemplates.TALES.Default instance at 0x8a4b6cc>,
'here': <Folder instance at e3eca10>,
'loop': <SafeMapping instance at a8d3b90>,
'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x8a4b06c>,
'nothing': None,
'options': {'args': ()},
'repeat': <SafeMapping instance at a8d3b90>,
'request': <HTTPRequest, URL=http://footprints.by2012.com/Articles/Mine/America_How_It_Ends.pt>,
'root': <Application instance at e03c380>,
'template': <ZopePageTemplate at /footprints.by2012.com/en-us/Articles/Mine/America_How_It_Ends.pt>,
'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
- <ZopePageTemplate at /s/getRandomQuote>
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': <Folder instance at e37d4d0>,
'context': <Folder instance at e37d4d0>,
'default': <Products.PageTemplates.TALES.Default instance at 0x8a4b6cc>,
'here': <Folder instance at e37d4d0>,
'loop': <SafeMapping instance at dbf08f0>,
'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x8a4b06c>,
'nothing': None,
'options': {'args': ()},
'repeat': <SafeMapping instance at dbf08f0>,
'request': <HTTPRequest, URL=http://footprints.by2012.com/Articles/Mine/America_How_It_Ends.pt>,
'root': <Application instance at e03c380>,
'template': <ZopePageTemplate at /s/getRandomQuote>,
'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>