[Zope] Method reusability

Casey Duncan cduncan@kaivo.com
Mon, 09 Jul 2001 09:11:39 -0600


belen@netcom.no wrote:
> 
> Hello there,
> 
> I have a method I am using to download a page to a client:
> 
> <dtml-call "REQUEST.RESPONSE.setHeader('content-ype','application/octet-
> stream')">
> <dtml-call "REQUEST.RESPONSE.setHeader('Content-
> Disposition','Attachment; Filename='+document+'.html')">
> 
> <dtml-return "StepReport(_.None, TestID=TestID)">
> 
> But so far I have not found the way to make it reusable, since I have
> to hard code the parameters I am passing to the document. This means I
> have to have to create as many variations of the method as pages I want
> to download.  Now I cannot think of any way to make my method recognise
> or detect how many and which are the parameters I am receiving, since
> it might vary depending on the document that invokes the method.
> 
> <dtml-let param_1=param_1....... param_n=param_n >
> <dtml-var  "_['document']">
> </dtml-let>
> 
> <dtml-return "StepReport(_.None, param_1=param_1,....,
> param_n=param_n )">
> 
> Can someone help me please?
> 
> Thanks in advance,
> Belen
> 

I think this could quite easily be made into a single DTML method that
can be called on any document. You can pass all parameters to another
Method by passing the namespace variable "_" to it. Perhaps your method
could be something like:

<dtml-call
expr="RESPONSE.setHeader('content-type','application/octet-stream')">
<dtml-call expr="RESPONSE.setHeader('Content-Disposition','Attachment;
Filename=%s.html' % document)">
<dtml-return expr="StepReport(_.None, _)">

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>