Hi;
I've written this code:
html
body
span tal:define=global number here/quotes/randomNumber/span
tabletrtd
span metal:use-macro=here/en-us/quotes/?number/macros/quote/spanbr /
/td/tr/table
/body
html
...and here's randomNumber, which is an External Method:
def randomNumber(self):
return randrange(1, len(self.objectValues()), 1)
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?
TIA,
Tony
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,