[Zope] dtml-with question

Marie Robichon robichon@esrf.fr
Fri, 23 Aug 2002 17:09:41 +0200


--=====================_6475789==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed


>
>hi,
>
>your error is in the dtml-with... myid is a string and not an object:
>
> > <dtml-call "manage_addFolder(myid, mytitle)">
> >
> > <dtml-with myid>
>
>so try something like this to get the object with id=myid:
>
><dtml-with "_.getattr(this(),myid)">
>
>-maik
>

Thanks but I seem to be getting an attribute error __getslice__ when I try 
to do this:

<dtml-let dictionaryvar="filescript(REQUEST)">
     <dtml-if "not dictionaryvar.has_key('file')">
         <dtml-call "RESPONSE.redirect('fileform?nofile=1')">
     <dtml-else>
       <dtml-let mytitle="dictionaryvar['title']" 
body="dictionaryvar['body']" myid="dictionaryvar['fid']" >
          <dtml-with "ContentHolder.createInObjectManager(myid,REQUEST)">
              <dtml-call 
"propertysheets.general.manage_changeProperties(title=mytitle)">
               <dtml-with "_.getattr(this(),myid)">
                  <dtml-call 
"manage_addProduct['PageTemplates'].manage_addPageTemplate('contents_html', 
mytitle, body)">
               <dtml-call "manage_addFolder('img','my images')">
               </dtml-with>
          </dtml-with>
       </dtml-let>
     </dtml-if>
</dtml-let>

and following Chris Withers advice and using a python script:

theDict = context.filescript(context.REQUEST)
mytitle = theDict['title']
body = theDict['body']
myid = theDict['fid']
dispatcher = context.manage_addProduct['ContentHolder']
dispatcher.manage_addContentHolder(myid,mytitle)
myproduct=context[myid]
myproduct.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html',mytitle,body)

I get an attribute error Error Type: AttributeError
Error Value: manage_addContentHolder

I know that it would be better to do a product that using zclasses and that 
is our next step but I would like to be able to get this working before I 
tackle that big step...

TIA

Marie


--=====================_6475789==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<blockquote type=cite class=cite cite><br>
hi,<br>
<br>
your error is in the dtml-with... myid is a string and not an
object:<br>
<br>
&gt; &lt;dtml-call &quot;manage_addFolder(myid, mytitle)&quot;&gt;<br>
&gt;<br>
&gt; &lt;dtml-with myid&gt;<br>
<br>
so try something like this to get the object with id=myid:<br>
<br>
&lt;dtml-with &quot;_.getattr(this(),myid)&quot;&gt;<br>
<br>
-maik<br>
<br>
</blockquote><br>
Thanks but I seem to be getting an attribute error __getslice__ when I
try to do this:<br>
<br>
&lt;dtml-let dictionaryvar=&quot;filescript(REQUEST)&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;dtml-if &quot;not
dictionaryvar.has_key('file')&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-call
&quot;RESPONSE.redirect('fileform?nofile=1')&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;dtml-else&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-let
mytitle=&quot;dictionaryvar['title']&quot;
body=&quot;dictionaryvar['body']&quot;
myid=&quot;dictionaryvar['fid']&quot; &gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-with
&quot;ContentHolder.createInObjectManager(myid,REQUEST)&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;dtml-call
&quot;propertysheets.general.manage_changeProperties(title=mytitle)&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;dtml-with &quot;_.getattr(this(),myid)&quot;&gt;&nbsp;&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;dtml-call
&quot;manage_addProduct['PageTemplates'].manage_addPageTemplate('contents_html',
mytitle, body)&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;dtml-call &quot;manage_addFolder('img','my images')&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;/dtml-with&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/dtml-with&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/dtml-let&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/dtml-if&gt;<br>
&lt;/dtml-let&gt;<br>
<br>
and following Chris Withers advice and using a python script:<br>
<br>
theDict = context.filescript(context.REQUEST)<br>
mytitle = theDict['title']<br>
body = theDict['body']<br>
myid = theDict['fid']<br>
dispatcher = context.manage_addProduct['ContentHolder']<br>
dispatcher.manage_addContentHolder(myid,mytitle)<br>
myproduct=context[myid]<br>
myproduct.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html',mytitle,body)<br>
<br>
I get an attribute error <b>Error Type: AttributeError<br>
Error Value: manage_addContentHolder<br>
<br>
I know that it would be better to do a product that using zclasses and
that is our next step but I would like to be able to get this working
before I tackle that big step...<br>
<br>
TIA<br>
<br>
Marie<br>
<br>
</b></html>

--=====================_6475789==_.ALT--