Hi guys, I have a page of multiple upload file boxes - the name of each one is generated on the fly so I don't know what the name will be when I get to the dtml method to upload the images. I also don't know how many of them will actually have an image to upload. Hence, after much trawling through previous posts I found the following code to check to see if the user has actually selected a file to upload: <dtml-if "newimage.filename"> How do I use this with 'sequence-item'? I have tried: <dtml-if "_['sequence-item'].filename"> Any ideas? Laurie Nason Baylor College of Medicine Houston TX 77030
Can you have other form variables besides the upload boxes? Can there be more than one on a page with the same name? Tom P [Laurie Nason]
I have a page of multiple upload file boxes - the name of each one is generated on the fly so I don't know what the name will be when I get to the dtml method to upload the images. I also don't know how many of them will actually have an image to upload. Hence, after much trawling through previous posts I found the following code to check to see if the user has actually selected a file to upload:
<dtml-if "newimage.filename">
How do I use this with 'sequence-item'?
I have tried:
<dtml-if "_['sequence-item'].filename">
Any ideas?
There are no other form variables besides these on this form - and the name is actually the name of a ZClass instance, in which I wish to create my image file. One in each instance. Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 11:21 AM To: Zope Subject: Re: [Zope] filename property of variable Can you have other form variables besides the upload boxes? Can there be more than one on a page with the same name? Tom P [Laurie Nason]
I have a page of multiple upload file boxes - the name of each one is generated on the fly so I don't know what the name will be when I get to the dtml method to upload the images. I also don't know how many of them will actually have an image to upload. Hence, after much trawling through previous posts I found the following code to check to see if the user has actually selected a file to upload:
<dtml-if "newimage.filename">
How do I use this with 'sequence-item'?
I have tried:
<dtml-if "_['sequence-item'].filename">
Any ideas?
_______________________________________________ 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 )
Laurie, I think this might be what you want. At least, it will let you access each (unknown) form variable by name and get its value. The slightly odd expression "_[_['sequence-item']]" gives you the value because the variable name is sequence-item, if you do it like this. <dtml-in "REQUEST.form.keys()"> <!-- Show <name>:<value> --> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <!-- Apply "if" test to see if variable has a value --> <dtml-if "_[_['sequence-item']]"> (passed "if" test)</dtml-if><br> </dtml-in> Try that on your form and see if it shows you the filled-in values. It does on my test form. If you can render them, you ought to be able to do anything else you want. Cheers, Tom P [Laurie Nason]
There are no other form variables besides these on this form - and the
name
is actually the name of a ZClass instance, in which I wish to create my image file. One in each instance.
Laurie
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 11:21 AM To: Zope Subject: Re: [Zope] filename property of variable
Can you have other form variables besides the upload boxes? Can there be more than one on a page with the same name?
Tom P
[Laurie Nason]
I have a page of multiple upload file boxes - the name of each one is generated on the fly so I don't know what the name will be when I get to the dtml method to upload the images. I also don't know how many of them will actually have an image to upload. Hence, after much trawling through previous posts I found the following code to check to see if the user has actually selected a file to upload:
<dtml-if "newimage.filename">
How do I use this with 'sequence-item'?
I have tried:
<dtml-if "_['sequence-item'].filename">
Any ideas?
I tried this and it doesn't differentiate between ones where the user has entered a file to upload and ones where they haven't. I really need to be able to call the .filename method to see if it has one - but _['sequence-item'].filename doesn't like the fact that the _['sequence-item'] returns a string (thanks Casey again on a different post!) rather than the object itself. What I would like to be able to do is to call <dtml-if expr="_.getitem(sequence-item).filename"> But you can't escape the sequence-item again due to the fact that it returns a string...AARRGGHHH!!! Any ideas??? Laurie #B^( -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 12:46 PM To: Zope Subject: Re: [Zope] filename property of variable Laurie, I think this might be what you want. At least, it will let you access each (unknown) form variable by name and get its value. The slightly odd expression "_[_['sequence-item']]" gives you the value because the variable name is sequence-item, if you do it like this. <dtml-in "REQUEST.form.keys()"> <!-- Show <name>:<value> --> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <!-- Apply "if" test to see if variable has a value --> <dtml-if "_[_['sequence-item']]"> (passed "if" test)</dtml-if><br> </dtml-in> Try that on your form and see if it shows you the filled-in values. It does on my test form. If you can render them, you ought to be able to do anything else you want. Cheers, Tom P [Laurie Nason]
There are no other form variables besides these on this form - and the
name
is actually the name of a ZClass instance, in which I wish to create my image file. One in each instance.
Laurie
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 11:21 AM To: Zope Subject: Re: [Zope] filename property of variable
Can you have other form variables besides the upload boxes? Can there be more than one on a page with the same name?
Tom P
[Laurie Nason]
I have a page of multiple upload file boxes - the name of each one is generated on the fly so I don't know what the name will be when I get to the dtml method to upload the images. I also don't know how many of them will actually have an image to upload. Hence, after much trawling through previous posts I found the following code to check to see if the user has actually selected a file to upload:
<dtml-if "newimage.filename">
How do I use this with 'sequence-item'?
I have tried:
<dtml-if "_['sequence-item'].filename">
Any ideas?
_______________________________________________ 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 )
I'm a little lost. When I tried it, I got a non-empty string for each file input field that had a filename, and there was an empty string for each one where the user hadn't entered anything. Isn't that what you want? That way, you can test to see if anything was entered. Let me show you what I was testing. Here is my form, with two file-type inputs: <html> <form action='see_request2 '> <input type='file' name='file1'><br> <input type='file' name='file2'><br> <input type='submit' value='Try It'> </form> </html> Here's my handling form, see_request2: <html> <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <dtml-if "_[_['sequence-item']]"> (passed if)</dtml-if><br> </dtml-in> </html> Here's the result, copied for the screen, where I entered "aaa" for the first file name and nothing for the 2nd file name: file1:aaa (passed if) file2: You see, it DOES differentiate between the fields where the user entered a filename and those where the user didn't. Isn't that what you want? If not, I need more clarification. I'm probably assuming something without realizing. Better show us a (shortened) sample of the form, at least. Tom P [Laurie Nason]
I tried this and it doesn't differentiate between ones where the user has entered a file to upload and ones where they haven't. I really need to be able to call the .filename method to see if it has one - but _['sequence-item'].filename doesn't like the fact that the _['sequence-item'] returns a string (thanks Casey again on a different post!) rather than the object itself. What I would like to be able to do is to call <dtml-if expr="_.getitem(sequence-item).filename">
But you can't escape the sequence-item again due to the fact that it returns a string...AARRGGHHH!!!
Any ideas???
OK - here is my input form <dtml-in "PARENTS[0].objectValues(['Specimen'])" sort="specimenid"> <dtml-var sequence-item> <input type="file" name="<dtml-var id>" value="Add image to this specimen"><br> </dtml-in> And here is my handling form: <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var expr="_[_['sequence-item']]"><br> <dtml-if "_[_['sequence-item']]"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-call expr="manage_addProduct['ExtFile'].manage_addExtImage(id='test',file=REQUEST .form[_['sequence-item']], create_prev=1, permission_check=1)"> </dtml-with> </dtml-if> </dtml-in> When I run this I get the html source as Specimen_288:<Specimen instance at 893b520><br> Specimen_289:<Specimen instance at 8874568><br> Specimen_291:<Specimen instance at 8936fb8><br> Specimen_290:<Specimen instance at 86d6868><br> Specimen_293:<Specimen instance at 89d9fe0><br> Specimen_292:<Specimen instance at 88c22c8><br> Specimen_286:<Specimen instance at 893b5e0><br> Specimen_287:<Specimen instance at 87fc188><br> Hope this helps! Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 1:42 PM To: Zope Subject: Re: [Zope] filename property of variable I'm a little lost. When I tried it, I got a non-empty string for each file input field that had a filename, and there was an empty string for each one where the user hadn't entered anything. Isn't that what you want? That way, you can test to see if anything was entered. Let me show you what I was testing. Here is my form, with two file-type inputs: <html> <form action='see_request2 '> <input type='file' name='file1'><br> <input type='file' name='file2'><br> <input type='submit' value='Try It'> </form> </html> Here's my handling form, see_request2: <html> <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <dtml-if "_[_['sequence-item']]"> (passed if)</dtml-if><br> </dtml-in> </html> Here's the result, copied for the screen, where I entered "aaa" for the first file name and nothing for the 2nd file name: file1:aaa (passed if) file2: You see, it DOES differentiate between the fields where the user entered a filename and those where the user didn't. Isn't that what you want? If not, I need more clarification. I'm probably assuming something without realizing. Better show us a (shortened) sample of the form, at least. Tom P [Laurie Nason]
I tried this and it doesn't differentiate between ones where the user has entered a file to upload and ones where they haven't. I really need to be able to call the .filename method to see if it has one - but _['sequence-item'].filename doesn't like the fact that the _['sequence-item'] returns a string (thanks Casey again on a different post!) rather than the object itself. What I would like to be able to do is to call <dtml-if expr="_.getitem(sequence-item).filename">
But you can't escape the sequence-item again due to the fact that it returns a string...AARRGGHHH!!!
Any ideas???
_______________________________________________ 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 )
Laurie Nason wrote:
OK - here is my input form <dtml-in "PARENTS[0].objectValues(['Specimen'])" sort="specimenid"> <dtml-var sequence-item> <input type="file" name="<dtml-var id>" value="Add image to this specimen"><br> </dtml-in>
And here is my handling form: <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var expr="_[_['sequence-item']]"><br> <dtml-if "_[_['sequence-item']]"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-call expr="manage_addProduct['ExtFile'].manage_addExtImage(id='test',file=REQUEST .form[_['sequence-item']], create_prev=1, permission_check=1)"> </dtml-with> </dtml-if> </dtml-in>
When I run this I get the html source as
Specimen_288:<Specimen instance at 893b520><br> Specimen_289:<Specimen instance at 8874568><br> Specimen_291:<Specimen instance at 8936fb8><br> Specimen_290:<Specimen instance at 86d6868><br> Specimen_293:<Specimen instance at 89d9fe0><br> Specimen_292:<Specimen instance at 88c22c8><br> Specimen_286:<Specimen instance at 893b5e0><br> Specimen_287:<Specimen instance at 87fc188><br>
Hope this helps! Laurie
Maybe try: <input type="file" name="<dtml-var id>:ignore_empty" value="Add image to thisspecimen"><br> which should not return any empty file fields. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
[Casey Duncan]
Maybe try:
<input type="file" name="<dtml-var id>:ignore_empty" value="Add image to thisspecimen"><br>
which should not return any empty file fields.
Well, this suggestion finally got me to look for a complete list of all these field qualifiers. By searching on the Zope site for "ignore_empty", I found one solitary page that has a list that looks complete. Now I can use something besides ":list" Thanks. Tom P
OK, I think we're making progress. Will you post the html form AS RECEIVED BY THE USER'S BROWSER? You have already posted the dtml for the form, now let's see the rendered form. Also, the "html source" that you show below - is it what you see on the screen when the form handler runs? Because if looks like the page is finding Speciman objects of the same name as the form variables - maybe from earlier runs? Maybe that could be stopped by using ONLY (I forget if it's upper or lower case): <dtml-with "REQUEST.form" ONLY> <dtml-in keys()> <!-- and so on --> </dtml-in> </dtml-with> Cheers, Tom P [Laurie Nason]
OK - here is my input form <dtml-in "PARENTS[0].objectValues(['Specimen'])" sort="specimenid"> <dtml-var sequence-item> <input type="file" name="<dtml-var id>" value="Add image to this specimen"><br> </dtml-in>
And here is my handling form: <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var expr="_[_['sequence-item']]"><br> <dtml-if "_[_['sequence-item']]"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-call
expr="manage_addProduct['ExtFile'].manage_addExtImage(id='test',file=REQUEST
.form[_['sequence-item']], create_prev=1, permission_check=1)"> </dtml-with> </dtml-if> </dtml-in>
When I run this I get the html source as
Specimen_288:<Specimen instance at 893b520><br> Specimen_289:<Specimen instance at 8874568><br> Specimen_291:<Specimen instance at 8936fb8><br> Specimen_290:<Specimen instance at 86d6868><br> Specimen_293:<Specimen instance at 89d9fe0><br> Specimen_292:<Specimen instance at 88c22c8><br> Specimen_286:<Specimen instance at 893b5e0><br> Specimen_287:<Specimen instance at 87fc188><br>
Hope this helps! Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 1:42 PM To: Zope Subject: Re: [Zope] filename property of variable
I'm a little lost. When I tried it, I got a non-empty string for each file input field that had a filename, and there was an empty string for each one where the user hadn't entered anything. Isn't that what you want? That way, you can test to see if anything was entered.
Let me show you what I was testing. Here is my form, with two file-type inputs:
<html> <form action='see_request2 '> <input type='file' name='file1'><br> <input type='file' name='file2'><br> <input type='submit' value='Try It'> </form> </html>
Here's my handling form, see_request2:
<html> <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <dtml-if "_[_['sequence-item']]"> (passed if)</dtml-if><br> </dtml-in> </html>
Here's the result, copied for the screen, where I entered "aaa" for the first file name and nothing for the 2nd file name:
file1:aaa (passed if) file2:
You see, it DOES differentiate between the fields where the user entered a filename and those where the user didn't.
Isn't that what you want? If not, I need more clarification. I'm probably assuming something without realizing. Better show us a (shortened) sample of the form, at least.
Tom P
[Laurie Nason]
I tried this and it doesn't differentiate between ones where the user has entered a file to upload and ones where they haven't. I really need to be able to call the .filename method to see if it has one - but _['sequence-item'].filename doesn't like the fact that the _['sequence-item'] returns a string (thanks Casey again on a different post!) rather than the object itself. What I would like to be able to do is to call <dtml-if expr="_.getitem(sequence-item).filename">
But you can't escape the sequence-item again due to the fact that it returns a string...AARRGGHHH!!!
Any ideas???
_______________________________________________ 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 )
OK tried the REQUEST.form only etc. It still doesn't differentiate between a file box filled in and one not filled in. Also in answer to your question - there are Specimen objects with these names and they are in the same folder as the method is executing in. OK so here is my take on what is happening - the method is running and when the _[_['sequence-item']] runs it looks up in the current context (REQUEST is always last in the aquisition path) and finds the specimen objects and returns them rather than the file object I want to upload - I guess that I can put an extra piece of information in the name of the file box on the form and then strip it out when I want to add the image to the specimen. If I use the only syntax, I then will not have access to the Specimen that I wish to add the image to. Is this going to be the easiest way of achieving my goal??? Laurie PS Thanks for all your help! -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 2:58 PM To: Laurie Nason; Zope Subject: Re: [Zope] filename property of variable OK, I think we're making progress. Will you post the html form AS RECEIVED BY THE USER'S BROWSER? You have already posted the dtml for the form, now let's see the rendered form. Also, the "html source" that you show below - is it what you see on the screen when the form handler runs? Because if looks like the page is finding Speciman objects of the same name as the form variables - maybe from earlier runs? Maybe that could be stopped by using ONLY (I forget if it's upper or lower case): <dtml-with "REQUEST.form" ONLY> <dtml-in keys()> <!-- and so on --> </dtml-in> </dtml-with> Cheers, Tom P [Laurie Nason]
OK - here is my input form <dtml-in "PARENTS[0].objectValues(['Specimen'])" sort="specimenid"> <dtml-var sequence-item> <input type="file" name="<dtml-var id>" value="Add image to this specimen"><br> </dtml-in>
And here is my handling form: <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var expr="_[_['sequence-item']]"><br> <dtml-if "_[_['sequence-item']]"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-call
expr="manage_addProduct['ExtFile'].manage_addExtImage(id='test',file=REQUEST
.form[_['sequence-item']], create_prev=1, permission_check=1)"> </dtml-with> </dtml-if> </dtml-in>
When I run this I get the html source as
Specimen_288:<Specimen instance at 893b520><br> Specimen_289:<Specimen instance at 8874568><br> Specimen_291:<Specimen instance at 8936fb8><br> Specimen_290:<Specimen instance at 86d6868><br> Specimen_293:<Specimen instance at 89d9fe0><br> Specimen_292:<Specimen instance at 88c22c8><br> Specimen_286:<Specimen instance at 893b5e0><br> Specimen_287:<Specimen instance at 87fc188><br>
Hope this helps! Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 1:42 PM To: Zope Subject: Re: [Zope] filename property of variable
I'm a little lost. When I tried it, I got a non-empty string for each file input field that had a filename, and there was an empty string for each one where the user hadn't entered anything. Isn't that what you want? That way, you can test to see if anything was entered.
Let me show you what I was testing. Here is my form, with two file-type inputs:
<html> <form action='see_request2 '> <input type='file' name='file1'><br> <input type='file' name='file2'><br> <input type='submit' value='Try It'> </form> </html>
Here's my handling form, see_request2:
<html> <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <dtml-if "_[_['sequence-item']]"> (passed if)</dtml-if><br> </dtml-in> </html>
Here's the result, copied for the screen, where I entered "aaa" for the first file name and nothing for the 2nd file name:
file1:aaa (passed if) file2:
You see, it DOES differentiate between the fields where the user entered a filename and those where the user didn't.
Isn't that what you want? If not, I need more clarification. I'm probably assuming something without realizing. Better show us a (shortened) sample of the form, at least.
Tom P
[Laurie Nason]
I tried this and it doesn't differentiate between ones where the user has entered a file to upload and ones where they haven't. I really need to be able to call the .filename method to see if it has one - but _['sequence-item'].filename doesn't like the fact that the _['sequence-item'] returns a string (thanks Casey again on a different post!) rather than the object itself. What I would like to be able to do is to call <dtml-if expr="_.getitem(sequence-item).filename">
But you can't escape the sequence-item again due to the fact that it returns a string...AARRGGHHH!!!
Any ideas???
_______________________________________________ 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 )
OK Finally - have solved the mystery..... I was correct about zope finding the instance of my specimen class - so I renamed my text box as 'image_<dtml-var id>', then used this full name to refer to the file box. Consequently when I refer to the file box in the handler I can use the .filename to check if there is a file name entered. <dtml-in expr="REQUEST.form.keys()"> Updating: <dtml-var sequence-item>:<dtml-var expr="_[_['sequence-item']]"><br> <dtml-if "_[_['sequence-item']].filename"> <<<-----This line now works!!!! <dtml-with "_.getitem((_['sequence-item'])[6:])"> <<<-----This gets my specimen id back <dtml-call expr="manage_addProduct['ExtFile'].manage_addExtImage(id='test',file=REQUEST .form[_['sequence-item']], create_prev=1, permission_check=1)"> </dtml-with> </dtml-if> </dtml-in> So aquisition wins again! And Laurie has a few more grey hairs.....and a couple of bruises on his head... and a dent on his desk...and fewer brain cells for next time it strikes!!!! Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Laurie Nason Sent: Monday, July 09, 2001 3:43 PM To: Thomas B. Passin; Laurie Nason; Zope Subject: RE: [Zope] filename property of variable OK tried the REQUEST.form only etc. It still doesn't differentiate between a file box filled in and one not filled in. Also in answer to your question - there are Specimen objects with these names and they are in the same folder as the method is executing in. OK so here is my take on what is happening - the method is running and when the _[_['sequence-item']] runs it looks up in the current context (REQUEST is always last in the aquisition path) and finds the specimen objects and returns them rather than the file object I want to upload - I guess that I can put an extra piece of information in the name of the file box on the form and then strip it out when I want to add the image to the specimen. If I use the only syntax, I then will not have access to the Specimen that I wish to add the image to. Is this going to be the easiest way of achieving my goal??? Laurie PS Thanks for all your help! -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 2:58 PM To: Laurie Nason; Zope Subject: Re: [Zope] filename property of variable OK, I think we're making progress. Will you post the html form AS RECEIVED BY THE USER'S BROWSER? You have already posted the dtml for the form, now let's see the rendered form. Also, the "html source" that you show below - is it what you see on the screen when the form handler runs? Because if looks like the page is finding Speciman objects of the same name as the form variables - maybe from earlier runs? Maybe that could be stopped by using ONLY (I forget if it's upper or lower case): <dtml-with "REQUEST.form" ONLY> <dtml-in keys()> <!-- and so on --> </dtml-in> </dtml-with> Cheers, Tom P [Laurie Nason]
OK - here is my input form <dtml-in "PARENTS[0].objectValues(['Specimen'])" sort="specimenid"> <dtml-var sequence-item> <input type="file" name="<dtml-var id>" value="Add image to this specimen"><br> </dtml-in>
And here is my handling form: <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var expr="_[_['sequence-item']]"><br> <dtml-if "_[_['sequence-item']]"> <dtml-with "_.getitem(_['sequence-item'])"> <dtml-call
expr="manage_addProduct['ExtFile'].manage_addExtImage(id='test',file=REQUEST
.form[_['sequence-item']], create_prev=1, permission_check=1)"> </dtml-with> </dtml-if> </dtml-in>
When I run this I get the html source as
Specimen_288:<Specimen instance at 893b520><br> Specimen_289:<Specimen instance at 8874568><br> Specimen_291:<Specimen instance at 8936fb8><br> Specimen_290:<Specimen instance at 86d6868><br> Specimen_293:<Specimen instance at 89d9fe0><br> Specimen_292:<Specimen instance at 88c22c8><br> Specimen_286:<Specimen instance at 893b5e0><br> Specimen_287:<Specimen instance at 87fc188><br>
Hope this helps! Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Thomas B. Passin Sent: Monday, July 09, 2001 1:42 PM To: Zope Subject: Re: [Zope] filename property of variable
I'm a little lost. When I tried it, I got a non-empty string for each file input field that had a filename, and there was an empty string for each one where the user hadn't entered anything. Isn't that what you want? That way, you can test to see if anything was entered.
Let me show you what I was testing. Here is my form, with two file-type inputs:
<html> <form action='see_request2 '> <input type='file' name='file1'><br> <input type='file' name='file2'><br> <input type='submit' value='Try It'> </form> </html>
Here's my handling form, see_request2:
<html> <dtml-in "REQUEST.form.keys()"> <dtml-var sequence-item>:<dtml-var "_[_['sequence-item']]"> <dtml-if "_[_['sequence-item']]"> (passed if)</dtml-if><br> </dtml-in> </html>
Here's the result, copied for the screen, where I entered "aaa" for the first file name and nothing for the 2nd file name:
file1:aaa (passed if) file2:
You see, it DOES differentiate between the fields where the user entered a filename and those where the user didn't.
Isn't that what you want? If not, I need more clarification. I'm probably assuming something without realizing. Better show us a (shortened) sample of the form, at least.
Tom P
[Laurie Nason]
I tried this and it doesn't differentiate between ones where the user has entered a file to upload and ones where they haven't. I really need to be able to call the .filename method to see if it has one - but _['sequence-item'].filename doesn't like the fact that the _['sequence-item'] returns a string (thanks Casey again on a different post!) rather than the object itself. What I would like to be able to do is to call <dtml-if expr="_.getitem(sequence-item).filename">
But you can't escape the sequence-item again due to the fact that it returns a string...AARRGGHHH!!!
Any ideas???
_______________________________________________ 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 )
participants (3)
-
Casey Duncan -
Laurie Nason -
Thomas B. Passin