[Zope] filename property of variable

Laurie Nason laurien@tiger.3dem.bioch.bcm.tmc.edu
Mon, 9 Jul 2001 15:42:31 -0500


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 )