Hello all, Folder structure is like this root |-SharedCode | |- CodeSnippet |-Folder a |-Folder 1 |-Folder A I put pieces of code we use across the whole website in Shared code. If I want to get CodeSnippet I use the following code in DTML. <dtml-with SharedCode> <dtml-var CodeSnippet> </dtml-with> Now, how do I do this in a python script? There doesn't seem to be an equivalent command like dtml-with to push a folder onto the namespace. And getitem doesn't support getting objects that are not in the namespace. Help!! Things I have tried (among many) _['SharedCode']['CodeSnippet'] - Returns Code Snippet, but all " are returned as ", I need " _.getitem('CodeSnippet',1) - Doesn't work, not in namespace. _.getitem(_['SharedCode']['CodeSnippet'], 1) - Doesn't work _['SharedCode'].getitem(... doesn't work because getitem is associated with the _ namespace. etc, etc, etc -Chris
DTML does not have assignment (okay, it has an ugly workaround in "REQUEST.set"). Therefore, it needs "dtml-with" to open up namespaces. Python script does not have "dtml-with" but it has assignment. You have the following rough equivalence: <dtml-with XXXX> <dtml-var aaaa> </dtml-with> is similar to: x= XXXX x.aaaa i.e. assign the XXXX expression to a variable and whenever you want to access any attribute of the "XXXX", use the attribute of the variable. Dieter
participants (2)
-
Chris Kratz -
Dieter Maurer