How should a collection be in a Python product if i want to trave rse it with <dtml-in> rse it with <dtml-in>
This is a question I guess has something to do with popping an object onto the namespace, or about me not understanding how stuff works. When I make a list of objects: class simple: def __init__(self, value): self.value = value theList = [simple(1), simple(2), simple(3), simple(4)] I would expect to be able to traverse it like below (The objects namespace would be popped onto the namespace.): <dtml-in theList> <dtml-var value> </dtml-in> But it isn't so. What do I need to do to make the objects namespace count in my traversal? (I'd like to keep the dtml as simple as possible.) -------------- If I make a list: theList = [1, 2, 3, 4] I can traverse it with: <dtml-in theList> <dtml-var sequence-item> </dtml in> --------- and if it's a list if dicts: theList = [{'value':1},{'value':2},{'value':3},{'value':4}] I can traverse it like: <dtml in theList> <dtml-let item=sequence-item> <dtml-var "item['value']"> </dtml-let> </dtml in>
On Wed, 25 Oct 2000, [iso-8859-1] Max MЬller Rasmussen wrote:
class simple: def __init__(self, value): self.value = value
theList = [simple(1), simple(2), simple(3), simple(4)]
I would expect to be able to traverse it like below (The objects namespace would be popped onto the namespace.):
<dtml-in theList> <dtml-var value> </dtml-in>
Looks good...
But it isn't so.
Why? What was the error? Oleg. (All opinions are mine and not of my employer) ---- Oleg Broytmann Foundation for Effective Policies phd@phd.russ.ru Programmers don't die, they just GOSUB without RETURN.
Oleg Broytmann wrote:
On Wed, 25 Oct 2000, [iso-8859-1] Max Møller Rasmussen wrote:
class simple: def __init__(self, value): self.value = value
theList = [simple(1), simple(2), simple(3), simple(4)]
I would expect to be able to traverse it like below (The objects namespace would be popped onto the namespace.):
<dtml-in theList> <dtml-var value> </dtml-in>
If you're getting security errors, try this new version (untested): class simple(Acquisition.Implicit) __ac__permissions__ = ( ('View', ('get_value','get_list'),('Manager','Anonymous')), ) def __init__(self,value): self.value=value def get_value(self): return value Globals.default__class_init__(simple) Now, hopefully, theList is being returned from within a class method, in which case: theList = [simple(1).__of__(self), simple(2)__of__(self), simple(3)__of__(self), simple(4)__of__(self)] return theList then: <dtml-in get_theList> <dtml-var get_value> </dtml-in> should work... hmmmm, Chris
participants (3)
-
Chris Withers -
Max Møller Rasmussen -
Oleg Broytmann