Hi, I`m trying to delete some objects(folders/files), but I`m having some problems with sequence-... I`m trying to use manage_delObjects()... I made a list of sequence-item with a <dtml-in "Folder.objectValues()">, can I pass this list like an argument to manage_delObjects? Like <dtml-call "manage_delObjects(list)"> I think I a little confused with <sequence-..>, when I make a list like that (objectValues of a folder), do I have the object in <sequence-item>? If I make sequence-var-title, is it going to return the title? --> Because it`s giving error. Or I just have the id and I have to make _.getitem(sequence-item).title? I tryed to compare the sequence-item variable and returned error too... : <dtml-if "sequence-item=='test'"> By. ________________________________________________ Don't E-Mail, ZipMail! http://www.zipmail.com/
After Dark wrote:
Hi, I`m trying to delete some objects(folders/files), but I`m having some problems with sequence-...
I`m trying to use manage_delObjects()... I made a list of sequence-item with a <dtml-in "Folder.objectValues()">, can I pass this list like an argument to manage_delObjects? Like <dtml-call "manage_delObjects(list)">
I think I a little confused with <sequence-..>, when I make a list like that (objectValues of a folder), do I have the object in <sequence-item>? If I make sequence-var-title, is it going to return the title? --> Because it`s giving error. Or I just have the id and I have to make _.getitem(sequence-item).title?
I tryed to compare the sequence-item variable and returned error too... : <dtml-if "sequence-item=='test'">
By.
You have run into a classic problem that has burned many a thread. The name "sequence-item" is not a valid Python variable name, so it must be accessed indirectly when in an expression using the syntax _['sequence-item']. This is hopefully going to be fixed soon in a future release. So, to do your comparison you would need: <dtml-if expr="_['sequence-item'] == 'test'"> As for manage_delObjects, it takes a sequences of strings as its argument. These strings are the ids of the objects to delete. objectValues returns objects, not strings. However, objectIds returns the ids as a sequence of strings. So, you could delete all instances of a particular type of object in a folder like so: <dtml-call expr="manage_delObjects(objectIds('meta type'))"> If you want to make an arbitrary list, you would probably do better using a python script, as DTML is not well suited to logic, such as sequence manipulation. Here's an example: del_list = [] for ob in context.objectValues('meta type'): if ...insert your comparison here...: del_list.append(ob.id) if del_list: context.manage_delObjects(del_list) Calling this script in the context of the folder containing the objects, would find the objects to delete and obliterate them. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
----- Original Message ----- From: "After Dark" <afterz@zipmail.com> To: <zope@zope.org> Sent: Friday, April 06, 2001 10:42 AM Subject: [Zope] dtml-in --> sequence
Hi, I`m trying to delete some objects(folders/files), but I`m having some problems with sequence-...
Remember, when you put an argument in quotes like <dtml-if expr="myvar == '1'">, the stuff in quotes is a python expression. So, in python, "sequence-item" is actually trying to subtract item from sequence. Whenever you are dealing with sequence-item, sequence-key, sequence-whatever, in a python expression, you need to do this: _['sequence-item'] _['sequence-key'] and so on...
I`m trying to use manage_delObjects()... I made a list of sequence-item with a <dtml-in "Folder.objectValues()">, can I pass this list like an argument to manage_delObjects? Like <dtml-call "manage_delObjects(list)">
Considering the above, you could right it like this (untested): <dtml-in "Folder.objectValues()"> <dtml-call "manage_delObjects(_['sequence-item'])"> </dtml-in>
I think I a little confused with <sequence-..>, when I make
Don't feel bad, you aren't the only one.
a list like that (objectValues of a folder), do I have the object in <sequence-item>? If I make sequence-var-title, is it going to return the title? --> Because it`s giving error. Or I just have the id and I have to make _.getitem(sequence-item).title?
yes, when you use <dtml-in> to loop over objects, sequence-item is the actual object ie (untested): <dtml-in "Folder.objectValues()"> <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P> </dtml-in> Hope this helps... Andrew Williams
I made this, but gave the following error: string object does not have id atribute... <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P> Because I need the id from sequence-item, I tryed _['sequence-var-id'] but didn`t work. I even tryed _.getitem(['sequence-item']).id Do you know how to make it works? By. On Fri, 6 Apr 2001 10:59:08 -0400 "Andrew Williams" <ajwms@hotmail.com> wrote:
----- Original Message ----- From: "After Dark" <afterz@zipmail.com> To: <zope@zope.org> Sent: Friday, April 06, 2001 10:42 AM Subject: [Zope] dtml-in --> sequence
Hi, I`m trying to delete some objects(folders/files),
but
I`m having some problems with sequence-...
Remember, when you put an argument in quotes like <dtml-if expr="myvar == '1'">, the stuff in quotes is a python expression. So, in python, "sequence-item" is actually trying to subtract item from sequence.
Whenever you are dealing with sequence-item, sequence-key, sequence-whatever, in a python expression, you need to do this: _['sequence-item'] _['sequence-key'] and so on...
I`m trying to use manage_delObjects()... I made a list
of
sequence-item with a <dtml-in "Folder.objectValues()">, can I pass this list like an argument to manage_delObjects? Like <dtml-call "manage_delObjects(list)">
Considering the above, you could right it like this (untested): <dtml-in "Folder.objectValues()"> <dtml-call "manage_delObjects(_['sequence-item'])"> </dtml-in>
I think I a little confused with <sequence-..>, when I
make
Don't feel bad, you aren't the only one.
a list like that (objectValues of a folder), do I have the object in <sequence-item>? If I make sequence-var-title, is it going to return the title? --> Because it`s giving error. Or I just have the id and I have to make _.getitem(sequence-item).title?
yes, when you use <dtml-in> to loop over objects, sequence-item is the actual object ie (untested):
<dtml-in "Folder.objectValues()"> <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P> </dtml-in>
Hope this helps...
Andrew Williams
________________________________________________ Don't E-Mail, ZipMail! http://www.zipmail.com/
After Dark wrote:
I made this, but gave the following error: string object does not have id atribute... <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P>
Because I need the id from sequence-item, I tryed _['sequence-var-id'] but didn`t work. I even tryed _.getitem(['sequence-item']).id
Do you know how to make it works?
By.
You are sooo close. You cannot use _['sequence-item'].id because _[] calls the object if it is callable, which results in a string for DTML objects. If you are in a dtml-in loop, there is no need to dereference sequence-item explicitly, dtml-in already puts all of its attributes on the namespace inside the loop. <dtml-in "Folder.objectValues()"> <P>Object ID = <dtml-var name="id"></P> </dtml-in> will suffice, however it is overkill, the following is more efficient: <dtml-in "Folder.objectIds()"> <P>Object ID = <dtml-var name="sequence-item"></P> </dtml-in> -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
----- Original Message ----- From: "After Dark" <afterz@zipmail.com> To: "Andrew Williams" <ajwms@hotmail.com>; "After Dark" <afterz@zipmail.com>; <zope@zope.org> Sent: Friday, April 06, 2001 12:04 PM Subject: Re: [Zope] dtml-in --> sequence
I made this, but gave the following error: string object does not have id atribute... <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P>
ok.. that means what you are getting back from your <dtml-in ..> is a string; strings don't have id objects.
Because I need the id from sequence-item, I tryed _['sequence-var-id'] but didn`t work. I even tryed _.getitem(['sequence-item']).id
Do you know how to make it works?
Check out the API Reference for more info; List of objects in current folder returning objects (sequence-item is the actual object): <dtml-in "objectValues()"> The ID of this object is: <dtml-var expr="_['sequence-item'].id"> </dtml-in> List of objects in current folder returning id (sequence-item is a string containing the objects id): <dtml-in "objectIds()"> ID=<dtml-var expr="_['sequence-item']"> </dtm-in> Now, sequence-item in the first example is a reference to an actual object; sequence-item in the second example is a string containing the id. If you already have the object, you don't need do perform a _.getitem() *However* if you only have the string with the object name (ie: id), then you need to perform a _.getitem() Does this help? Andrew
----- Original Message ----- From: "After Dark" <afterz@zipmail.com> To: "Andrew Williams" <ajwms@hotmail.com>; "After Dark" <afterz@zipmail.com>; <zope@zope.org> Sent: Friday, April 06, 2001 12:04 PM Subject: Re: [Zope] dtml-in --> sequence
List of objects in current folder returning objects (sequence-item is the actual object):
<dtml-in "objectValues()"> The ID of this object is: <dtml-var expr="_['sequence-item'].id"> </dtml-in>
sorry, lack of sleep and a killer headache is affecting my thinking skills. The above should read: <dtml-in "objectValues()"> The ID of this object is <dtml-var id> </dtml-in> Andrew
Thanks, I think with all of that, hardly someone will need to ask about it again in this list... a very good class! By. On Fri, 6 Apr 2001 12:45:57 -0400 "Andrew Williams" <ajwms@hotmail.com> wrote:
----- Original Message ----- From: "After Dark" <afterz@zipmail.com> To: "Andrew Williams" <ajwms@hotmail.com>; "After Dark" <afterz@zipmail.com>; <zope@zope.org> Sent: Friday, April 06, 2001 12:04 PM Subject: Re: [Zope] dtml-in --> sequence
List of objects in current folder returning objects (sequence-item is the actual object):
<dtml-in "objectValues()"> The ID of this object is: <dtml-var expr="_['sequence-item'].id"> </dtml-in>
sorry, lack of sleep and a killer headache is affecting my thinking skills. The above should read:
<dtml-in "objectValues()"> The ID of this object is <dtml-var id> </dtml-in>
Andrew
________________________________________________ Don't E-Mail, ZipMail! http://www.zipmail.com/
Try this ! I used it to dislay images from a certain folder ! <dtml-in expr="FolderName.objectValues()"> -- Gets the items from the folder ! <dtml-var sequence-item> -- Shows (in my case the images) <dtml-var title> -- The title <dtml-var id> -- And your ID </dtml-in> Greetings, Menno -----Oorspronkelijk bericht----- Van: zope-admin@zope.org [mailto:zope-admin@zope.org]Namens After Dark Verzonden: Friday, April 06, 2001 6:04 PM Aan: Andrew Williams; After Dark; zope@zope.org Onderwerp: Re: [Zope] dtml-in --> sequence I made this, but gave the following error: string object does not have id atribute... <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P> Because I need the id from sequence-item, I tryed _['sequence-var-id'] but didn`t work. I even tryed _.getitem(['sequence-item']).id Do you know how to make it works? By. On Fri, 6 Apr 2001 10:59:08 -0400 "Andrew Williams" <ajwms@hotmail.com> wrote:
----- Original Message ----- From: "After Dark" <afterz@zipmail.com> To: <zope@zope.org> Sent: Friday, April 06, 2001 10:42 AM Subject: [Zope] dtml-in --> sequence
Hi, I`m trying to delete some objects(folders/files),
but
I`m having some problems with sequence-...
Remember, when you put an argument in quotes like <dtml-if expr="myvar == '1'">, the stuff in quotes is a python expression. So, in python, "sequence-item" is actually trying to subtract item from sequence.
Whenever you are dealing with sequence-item, sequence-key, sequence-whatever, in a python expression, you need to do this: _['sequence-item'] _['sequence-key'] and so on...
I`m trying to use manage_delObjects()... I made a list
of
sequence-item with a <dtml-in "Folder.objectValues()">, can I pass this list like an argument to manage_delObjects? Like <dtml-call "manage_delObjects(list)">
Considering the above, you could right it like this (untested): <dtml-in "Folder.objectValues()"> <dtml-call "manage_delObjects(_['sequence-item'])"> </dtml-in>
I think I a little confused with <sequence-..>, when I
make
Don't feel bad, you aren't the only one.
a list like that (objectValues of a folder), do I have the object in <sequence-item>? If I make sequence-var-title, is it going to return the title? --> Because it`s giving error. Or I just have the id and I have to make _.getitem(sequence-item).title?
yes, when you use <dtml-in> to loop over objects, sequence-item is the actual object ie (untested):
<dtml-in "Folder.objectValues()"> <P>Object ID = <dtml-var expr="_['sequence-item'].id"></P> </dtml-in>
Hope this helps...
Andrew Williams
________________________________________________ Don't E-Mail, ZipMail! http://www.zipmail.com/ _______________________________________________ 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 )
Hi, Menno Brandsen wrote:
Try this !
I used it to dislay images from a certain folder !
<dtml-in expr="FolderName.objectValues()"> -- Gets the items from the folder ! <dtml-var sequence-item> -- Shows (in my case the images) <dtml-var title> -- The title <dtml-var id> -- And your ID </dtml-in>
You could use <dtml-var tag> to display the images. This allows more control if you want to override some attributes: <dtml-var "tag(alt='my picture here')"> Regards Tino
participants (5)
-
After Dark -
Andrew Williams -
Casey Duncan -
Menno Brandsen -
Tino Wildenhain