[Zope] form/script problem

Tom Germaine tgermaine@upei.ca
Tue, 06 Aug 2002 10:21:24 -0300


Thanks, Yes, showFiles is a DTMLMethod and your positional 
parameters seemed to work, but now the error is: 
Error Type: KeyError
Error Value: avc
which refers to the showFiles Method which is as follows:

<html>
<head></head>
<body>
<h2>AVC files:</h2>

<dtml-call "REQUEST.set('expand_all',_.int(1))">
<dtml-tree avc branches_expr="objectValues(['Folder','DTML 
Document'])"  sort=id>

<dtml-if "meta_type=='Folder'">
  <dtml-if expr="title == ''">

  <dtml-else>
    <h3><dtml-var title ></h3>
  </dtml-if>
</dtml-if>

<dtml-if "meta_type=='DTML Document'"> 
  <dtml-if "title == ''">
  
  <dtml-else>
    <li><dtml-var id>::&nbsp;<A HREF="&dtml-absolute_url;" 
target=display>
    <dtml-var title></a></li>
  </dtml-if> 
</dtml-if>

</dtml-tree>
  
</body>
</html>
--------
This Method works perfectly well when called from a 
DTMLDocument, but somehow doesn't when called from the python 
script.

Any further suggestions greatly appreciated.

Tom


On 6 Aug 2002, at 10:54, Maik Jablonski wrote:

> hi,
> 
> ahhh I see... I think showFiles is a DMTLMethod. So you must pass the
> "positional" parameters.
> 
> you coded:
> 
>  >>>return context.avc.showFiles()
> 
> should be something like this:
> 
> return context.avc.showFiles(None,context.REQUEST)
> 
> does this help?
> 
> greetings, maik
> 
> Tom Germaine wrote:
> > Thanks, I tried your suggestion, inserting after the 'import string'
> > line, but I'm afaid the error messages remained the same.  Perhaps
> > the syntax for the REQUEST object is incorrect, but I don't know how
> > to correct it.  Further help required...
> > 
> > Tom Germaine
> > 
> > On 5 Aug 2002, at 15:31, Maik Jablonski wrote:
> > 
> > 
> >>hi,
> >>
> >>you would need something like this in your Python-Script to get
> >>hands on the REQUEST:
> >>
> >>request = container.REQUEST
> >>myfile=request.myfile
> >>fname=request.fname
> >>
> >>[you must get all your web-parameters over the REQUEST!]
> >>
> >>greetings, maik
> >>
> >>Tom Germaine wrote:
> >>
> >>>Hi All:
> >>>
> >>>I am trying to upload a file as a DTML Document with a form that
> >>>calls a python script which edits the filename and file ending and
> >>>then calles a dtml method to show all DTML documents in the avc
> >>>folder.  The form is: ------- <dtml-var standard_html_header>
> >>><h2>AVC Submit Form</h2> <p>Upload a file to AVC folder.</p>
> >>>
> >>><form action="uploadActionScript" method="post"
> >>>enctype="multipart/form-data">
> >>><p><input type="file" name="myfile" size="85"></p>
> >>><p>Title: &nbsp;<input type="text" name="mytitle" size="70"></p>
> >>><input type="submit"> </form>
> >>>
> >>><dtml-var standard_html_footer>
> >>>-------
> >>>and the python script is:
> >>>---------
> >>>import string
> >>>fname=string.split(myfile,'\\')[-1]
> >>>fname=string.split(fname,'.html')[0]
> >>>
> >>>context.avc.manage_addDTMLDocument(fname,mytitle)
> >>>return context.avc.showFiles()
> >>>-------
> >>>Everything  resides in a subdirectory of avc
> >>>When I test the script I get the error:
> >>> Error Type: NameError
> >>>Error Value: global name 'REQUEST' is not defined
> >>>
> >>>When I run the form I get the error:
> >>>FileUpload instance has no attribute 'split'
> >>>
> >>>I have tried variations of the script but cannot get around the
> >>>errors.  Any advice would be appreciated.
> >>>
> >>>Tom Germaine
> >>>
> >>>_______________________________________________
> >>>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 )
> >>
> >>-- 
> >>Maik Jablonski                 __o
> >>www.zfl.uni-bielefeld.de     _ \<_    Deutsche Zope User Group
> >>Bielefeld, Germany          (_)/(_)               www.dzug.org
> >>
> > 
> > 
> > 
> > 
> > ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> > Tom Germaine
> > System Administrator
> > UPEI Access Services
> > tgermaine@upei.ca
> > 566-0465
> > ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> > 
> > _______________________________________________
> > 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 )
> 
> -- 
> Maik Jablonski                 __o
> www.zfl.uni-bielefeld.de     _ \<_    Deutsche Zope User Group
> Bielefeld, Germany          (_)/(_)               www.dzug.org
>