manage_changeProperties in a loop
Suppose I have a list of existing folder objects and depending on their index in the list I want to set a property called 'rang'. I assumed you could something like this: <dtml-call "REQUEST.set('rangList','folder1;folder2;folder2')"> (normally the list comes from outside) <dtml-in " _.string.split(rangList,';')"> <dtml-with "_.getitem('sequence-item')"> <dtml-let index=sequence-index> <dtml-call "manage_changeProperties({'rang':index})"> </dtml-let> </dtml-with> </dtml-in> Any ideas or hints? Thanks Arno Gross, email: arno.gross@consotec.de
Arno Gross wrote:
Suppose I have a list of existing folder objects and depending on their index in the list I want to set a property called 'rang'.
I assumed you could something like this:
<dtml-call "REQUEST.set('rangList','folder1;folder2;folder2')"> (normally the list comes from outside)
<dtml-in " _.string.split(rangList,';')"> <dtml-with "_.getitem('sequence-item')">
Here, you're getting an item with the literal id 'sequence-item'. What you mean is to get the item with the id described by the variable sequence-item. So, use: <dtml-with "_.getitem(_['sequence-item'])"> Hope that helps. This really is a zope@zope.org question, not a zope-dev@zope.org question. Please do try to choose the appropriate list for the question. Thanks. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
If I try your suggestion wiht _.getitem(_['sequence-item']) (If I remember well this was the first I tried). <dtml-call "REQUEST.set('rangList','folder1;folder2;folder2')"> <dtml-in " _.string.split(rangList,';')"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-let index=sequence-index> <dtml-call "manage_changeProperties({'rang':index})"> </dtml-let> </dtml-with> </dtml-in> I get this error: File D:\packages\Zope\WEBSIT~3\lib\python\DocumentTemplate\DT_In.py, line 691, in renderwob (Object: _.string.split(rangList,';')) File D:\packages\Zope\WEBSIT~3\lib\python\DocumentTemplate\DT_With.py, line 133, in render (Object: _.getitem(_['sequence-item'])) File D:\packages\Zope\WEBSIT~3\lib\python\DocumentTemplate\DT_Util.py, line 337, in eval (Object: _.getitem(_['sequence-item'])) (Info: _) Still any hints. Thanks. On Tue, 16 Jan 2001, Steve Alexander wrote:
Arno Gross wrote:
Suppose I have a list of existing folder objects and depending on their index in the list I want to set a property called 'rang'.
I assumed you could something like this:
<dtml-call "REQUEST.set('rangList','folder1;folder2;folder2')"> (normally the list comes from outside)
<dtml-in " _.string.split(rangList,';')"> <dtml-with "_.getitem('sequence-item')">
Here, you're getting an item with the literal id 'sequence-item'.
What you mean is to get the item with the id described by the variable sequence-item. So, use:
<dtml-with "_.getitem(_['sequence-item'])">
Hope that helps.
This really is a zope@zope.org question, not a zope-dev@zope.org question. Please do try to choose the appropriate list for the question. Thanks.
-- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Arno Gross wrote:
If I try your suggestion wiht _.getitem(_['sequence-item']) (If I remember well this was the first I tried).
<dtml-call "REQUEST.set('rangList','folder1;folder2;folder2')"> <dtml-in " _.string.split(rangList,';')"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-let index=sequence-index> <dtml-call "manage_changeProperties({'rang':index})"> </dtml-let> </dtml-with> </dtml-in>
I get this error: File D:\packages\Zope\WEBSIT~3\lib\python\DocumentTemplate\DT_In.py, line 691, in renderwob (Object: _.string.split(rangList,';')) File D:\packages\Zope\WEBSIT~3\lib\python\DocumentTemplate\DT_With.py, line 133, in render (Object: _.getitem(_['sequence-item'])) File D:\packages\Zope\WEBSIT~3\lib\python\DocumentTemplate\DT_Util.py, line 337, in eval (Object: _.getitem(_['sequence-item'])) (Info: _)
Still any hints. Thanks.
Try this: <dtml-call expr="REQUEST.set('rangList','folder1;folder2;folder2')"> <dtml-in expr="_.string.split(rangList,';')"> <dtml-let folder="_[_['sequence-item']]" index="_['sequence-index']"> <dtml-call expr="folder.manage_changeProperties({'rang':index})"> </dtml-let> </dtml-in> Also, why are you passing the folder ids in a string like this? Where are these names coming from, a form? If so, there are ways to eliminate the whole string.split. Also, the code would not need to be this complex if the objects themselves can be passed instead of a delimited string of ids. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
On Wed, 17 Jan 2001, Casey Duncan wrote:
Try this: <dtml-call expr="REQUEST.set('rangList','folder1;folder2;folder2')"> <dtml-in expr="_.string.split(rangList,';')"> <dtml-let folder="_[_['sequence-item']]" index="_['sequence-index']"> <dtml-call expr="folder.manage_changeProperties({'rang':index})"> </dtml-let> </dtml-in>
Also, why are you passing the folder ids in a string like this? Where are these names coming from, a form?
Yes, the names are coming from a from where I can sort the folders for showing in the desired order. I know that I can use a list with a SELECTION tag. But will get only the selected options and I need all the options in the ordered sequence. Of course I could select programmatically all options before returning the form and then I could work the list. But how can I pass the objects instead of the string? Best wishes Arno Gross, arno.gross@consotec.de
If so, there are ways to eliminate the whole string.split. Also, the code would not need to be this complex if the objects themselves can be > passed instead of a delimited string of ids. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (3)
-
Arno Gross -
Casey Duncan -
Steve Alexander