Greetings all, I have two snippets of code, the later I wish would work. Can anyone point out why? The structure: / folder1 / index_html folder2 / index_html This works: <dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with> This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in> I'd like the second to work. If I inject that with a try/except I find the first iteration works, but the second raises a key error. Can someone help? Thanks as always, Paz
Hi, are those two snippets supposed to be equivalent? Because I dont think they are -- the second one doesn't nest like the first one Depending on where those snippets live that might be the cause of the keyerror cheers, peter. On Wed, 12 Jun 2002, Paz wrote:
Greetings all,
I have two snippets of code, the later I wish would work. Can anyone point out why?
The structure: / folder1 / index_html folder2 / index_html
This works:
<dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with>
This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in>
I'd like the second to work. If I inject that with a try/except I find the first iteration works, but the second raises a key error. Can someone help?
Thanks as always, Paz
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
The keyerror is folder2. But how are they different? The outcome is that a document is rendered as: folder1.index_html folder1.folder2.index_html Or isn't it? Paz -----Original Message----- From: Peter Sabaini [mailto:sabaini@inode.at] Sent: Wednesday, June 12, 2002 10:51 PM To: Paz Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with Hi, are those two snippets supposed to be equivalent? Because I dont think they are -- the second one doesn't nest like the first one Depending on where those snippets live that might be the cause of the keyerror cheers, peter. On Wed, 12 Jun 2002, Paz wrote:
Greetings all,
I have two snippets of code, the later I wish would work. Can anyone point out why?
The structure: / folder1 / index_html folder2 / index_html
This works:
<dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with>
This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in>
I'd like the second to work. If I inject that with a try/except I find the first iteration works, but the second raises a key error. Can someone help?
Thanks as always, Paz
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
The first snippet renders folder1.index_html folder1.folder2.index_html The second one renders folder1.index_html folder2.index_html I dont know what want to accomplish but you might have to recode this using some recursive script. cheers, peter. On Wed, 12 Jun 2002, Paz wrote:
The keyerror is folder2. But how are they different? The outcome is that a document is rendered as:
folder1.index_html folder1.folder2.index_html
Or isn't it? Paz
-----Original Message----- From: Peter Sabaini [mailto:sabaini@inode.at] Sent: Wednesday, June 12, 2002 10:51 PM To: Paz Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with
Hi, are those two snippets supposed to be equivalent? Because I dont think they are -- the second one doesn't nest like the first one
Depending on where those snippets live that might be the cause of the keyerror
cheers, peter.
On Wed, 12 Jun 2002, Paz wrote:
Greetings all,
I have two snippets of code, the later I wish would work. Can anyone point out why?
The structure: / folder1 / index_html folder2 / index_html
This works:
<dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with>
This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in>
I'd like the second to work. If I inject that with a try/except I find the first iteration works, but the second raises a key error. Can someone help?
Thanks as always, Paz
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hmm, Im a bit confused then. How then would I traverse across and up into each folder then? -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of Peter Sabaini Sent: Wednesday, June 12, 2002 11:21 PM To: Paz Cc: zope@zope.org Subject: RE: [Zope] nested dtml-with The first snippet renders folder1.index_html folder1.folder2.index_html The second one renders folder1.index_html folder2.index_html I dont know what want to accomplish but you might have to recode this using some recursive script. cheers, peter. On Wed, 12 Jun 2002, Paz wrote:
The keyerror is folder2. But how are they different? The outcome is that a document is rendered as:
folder1.index_html folder1.folder2.index_html
Or isn't it? Paz
-----Original Message----- From: Peter Sabaini [mailto:sabaini@inode.at] Sent: Wednesday, June 12, 2002 10:51 PM To: Paz Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with
Hi, are those two snippets supposed to be equivalent? Because I dont think
they are -- the second one doesn't nest like the first one
Depending on where those snippets live that might be the cause of the keyerror
cheers, peter.
On Wed, 12 Jun 2002, Paz wrote:
Greetings all,
I have two snippets of code, the later I wish would work. Can anyone point out why?
The structure: / folder1 / index_html folder2 / index_html
This works:
<dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with>
This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in>
I'd like the second to work. If I inject that with a try/except I find the first iteration works, but the second raises a key error. Can someone help?
Thanks as always, Paz
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Don't do recursion in dtml. It's a cardinal sin, and it will make your head explode. Do it in a Python script instead. untested:: def subTree(context, type=None): """ Returns the entire sub-branch below this recursively as a flat list """ children = context.objectValues(type) grandChildren = [] for child in children: grandChildren += child.subTree(type) return children + grandChildren regards Max M Paul Zwarts wrote:
Hmm, Im a bit confused then. How then would I traverse across and up into each folder then?
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of Peter Sabaini Sent: Wednesday, June 12, 2002 11:21 PM To: Paz Cc: zope@zope.org Subject: RE: [Zope] nested dtml-with
The first snippet renders
folder1.index_html folder1.folder2.index_html
The second one renders
folder1.index_html folder2.index_html
I dont know what want to accomplish but you might have to recode this using some recursive script.
cheers, peter.
On Wed, 12 Jun 2002, Paz wrote:
The keyerror is folder2. But how are they different? The outcome is
that
a document is rendered as:
folder1.index_html folder1.folder2.index_html
Or isn't it? Paz
-----Original Message----- From: Peter Sabaini [mailto:sabaini@inode.at] Sent: Wednesday, June 12, 2002 10:51 PM To: Paz Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with
Hi, are those two snippets supposed to be equivalent? Because I dont think
they are -- the second one doesn't nest like the first one
Depending on where those snippets live that might be the cause of the keyerror
cheers, peter.
On Wed, 12 Jun 2002, Paz wrote:
Greetings all,
I have two snippets of code, the later I wish would work. Can anyone point out why?
The structure: / folder1 / index_html folder2 / index_html
This works:
<dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with>
This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in>
I'd like the second to work. If I inject that with a try/except I
find
the first iteration works, but the second raises a key error. Can someone help?
Thanks as always, Paz
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Max, I tried your code out, but subTree('Folder') returns an attribute error and I cant find anything under 'subTree' search anywhere on zope.org.. Are you sure that's what it is? I'd like to be able to call a document from the root of my site based on a list stored in a Session. Thanks, Paz -----Original Message----- From: Max M [mailto:maxm@mxm.dk] Sent: Thursday, June 13, 2002 8:33 AM To: Paul Zwarts Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with Don't do recursion in dtml. It's a cardinal sin, and it will make your head explode. Do it in a Python script instead. untested:: def subTree(context, type=None): """ Returns the entire sub-branch below this recursively as a flat list """ children = context.objectValues(type) grandChildren = [] for child in children: grandChildren += child.subTree(type) return children + grandChildren regards Max M Paul Zwarts wrote:
Hmm, Im a bit confused then. How then would I traverse across and up into each folder then?
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of Peter Sabaini Sent: Wednesday, June 12, 2002 11:21 PM To: Paz Cc: zope@zope.org Subject: RE: [Zope] nested dtml-with
The first snippet renders
folder1.index_html folder1.folder2.index_html
The second one renders
folder1.index_html folder2.index_html
I dont know what want to accomplish but you might have to recode this using some recursive script.
cheers, peter.
On Wed, 12 Jun 2002, Paz wrote:
The keyerror is folder2. But how are they different? The outcome is
that
a document is rendered as:
folder1.index_html folder1.folder2.index_html
Or isn't it? Paz
-----Original Message----- From: Peter Sabaini [mailto:sabaini@inode.at] Sent: Wednesday, June 12, 2002 10:51 PM To: Paz Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with
Hi, are those two snippets supposed to be equivalent? Because I dont think
they are -- the second one doesn't nest like the first one
Depending on where those snippets live that might be the cause of the keyerror
cheers, peter.
On Wed, 12 Jun 2002, Paz wrote:
Greetings all,
I have two snippets of code, the later I wish would work. Can anyone point out why?
The structure: / folder1 / index_html folder2 / index_html
This works:
<dtml-with folder1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with>
This doesn't: <dtml-in "['folder1', 'folder2']"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-var index_html> </dtml-with> </dtml-in>
I'd like the second to work. If I inject that with a try/except I
find
the first iteration works, but the second raises a key error. Can someone help?
Thanks as always, Paz
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Paul Zwarts wrote:
I tried your code out, but subTree('Folder') returns an attribute error and I cant find anything under 'subTree' search anywhere on zope.org.. Are you sure that's what it is?
You need to define a Python script called subTree ... see my code example.
I'd like to be able to call a document from the root of my site based on a list stored in a Session.
You are either talking nonsense, skipping several lines of thought, or I havn't understood a bit! Was your problem not that you wanted to get a list of all objects and subobjects in a folderish object? regards Max M
From: Max M [mailto:maxm@mxm.dk] Sent: Thursday, June 13, 2002 8:33 AM To: Paul Zwarts Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with
Don't do recursion in dtml. It's a cardinal sin, and it will make your head explode.
Do it in a Python script instead.
untested::
def subTree(context, type=None): """ Returns the entire sub-branch below this recursively as a flat list """ children = context.objectValues(type) grandChildren = [] for child in children: grandChildren += child.subTree(type) return children + grandChildren
regards Max M
-- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Ah, lol.. No. Sorry... I must not be making much sense. I wont explain everything because it would really sound strange. Long story short, I have a list which is basically the location of a document (folder, folder2, index_html = folder1.folder.index_html).
From a method called from the root of the site: /index_html
I want to basically do the same as this code: <dtml-with folder 1> <dtml-var index_html> <dtml-with folder2> <dtml-var index_html> </dtml-with> </dtml-with> But instead using the list. The reason is that every folder may or may not have an index_html, and any directory that DOES have one in the traversal path from root to the end of the list (folder1 to folder2.index_html (3 steps)) will be rendered into the document. So I would get something like: <!-- this is from /folder1/index_html !--/> <h1>Folder 1</h1> <!-- this is from /folder1/folder2/index_html !--/> <h1>Folder2</h1> The trick is that I am currently in the root namespace. I tried ascending the tree with the code I pasted earlier, but it seems to just query all iterations from root, and of course this doesn't work. Did I explain any clearer or worse? Thanks, Paz -----Original Message----- From: Max M [mailto:maxm@mxm.dk] Sent: Thursday, June 13, 2002 10:44 AM To: Paul Zwarts Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with Paul Zwarts wrote:
I tried your code out, but subTree('Folder') returns an attribute error and I cant find anything under 'subTree' search anywhere on zope.org.. Are you sure that's what it is?
You need to define a Python script called subTree ... see my code example.
I'd like to be able to call a document from the root of my site based on a list stored in a Session.
You are either talking nonsense, skipping several lines of thought, or I havn't understood a bit! Was your problem not that you wanted to get a list of all objects and subobjects in a folderish object? regards Max M
From: Max M [mailto:maxm@mxm.dk] Sent: Thursday, June 13, 2002 8:33 AM To: Paul Zwarts Cc: zope@zope.org Subject: Re: [Zope] nested dtml-with
Don't do recursion in dtml. It's a cardinal sin, and it will make your head explode.
Do it in a Python script instead.
untested::
def subTree(context, type=None): """ Returns the entire sub-branch below this recursively as a flat list """ children = context.objectValues(type) grandChildren = [] for child in children: grandChildren += child.subTree(type) return children + grandChildren
regards Max M
-- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Paul Zwarts wrote:
The trick is that I am currently in the root namespace. I tried ascending the tree with the code I pasted earlier, but it seems to just query all iterations from root, and of course this doesn't work.
You certainly did. And you are looking in the wrong direction for your solution... You need:: path = ['path', 'to', 'object'] obj = self.getPhysicalRoot().restrictedTraverse(path) All built in :-) regards Max M
participants (4)
-
Max M -
Paul Zwarts -
Paz -
Peter Sabaini