Thanks for the e-mail Seb. I am afraid I am still having problems here, so I
will show my code again, and hopefully you or someone else will be able to
help.

To recap : I am creating a news page and an interface to edit it using two
custom ZClasses, Article and Page. A Page object contains several Articles.
The following code is from a script that allows the user to delete an
Article from the Page. This method belongs to the Page class, so we are
currently in the scope of the Page. This script is supplied with the title
of a news article to be deleted, it should then delete the Article from the
Page and report back.

<dtml-var standard_header>
<!-- set this flag to null so I can tell if/when matching article found -->
<dtml-call "REQUEST.set('id_to_delete','NULL')">
<!-- retrieve the title of the article to delete -->
<dtml-let the_match="REQUEST['article_to_delete']">
<!-- start cycling through Articles looking for a match -->
<dtml-in objectValues>
  <dtml-with sequence-item>
  <dtml-with propertysheets>
  <dtml-with UAArticleClassPropertySheet>
  <!-- now we are looking at the properties of one of the Articles -->
  <dtml-if expr="article_title==the_match">
    <dtml-call "REQUEST.set('id_to_delete',title_or_id)">
    <!-- this is the point where we have located the article to delete.
Ideally we should delete it now, 
         but we are still in the scope of the property sheet -->
  </dtml-if>
  </dtml-with></dtml-with>
  <!-- now if we have found a match, we are back in the scope of the
objectValues of the Page, 
       so we want to do the deletion. -->
  <dtml-unless expr="REQUEST['id_to_delete']=='NULL'">
    <dtml-let the_id="REQUEST['id_to_delete']">
      <!-- this is the problem line -->
      <dtml-call "manage_delObjects(the_id)">
    </dtml-let>
  </dtml-unless>
</dtml-in>
<!-- this last bit just generates HTML to say if deletion done or article
not found -->
<dtml-if expr="REQUEST['id_to_delete']=='NULL'">
  <h2>Article not found</h2>
  <P>Could not find the article to delete.</P><P><A HREF=edit>Return to
maintenance page</A></P>
<dtml-else>
  <h2>Article not deleted</h2>
  <P>Deleted article '&dtml-the_match;' (id='&dtml-the_id;').</P><P><A
HREF=edit>Return to maintenance page</A></P>
</dtml-if>
</dtml-let>
<dtml-var standard_footer>
<!-- end of code -->

Basically I think I am somehow passing the wrong parameters to
manage_delObjects

The line
      <dtml-call "manage_delObjects(the_id)">
causes an error 'loop over non-sequence'

This made me think that the argument has to be a sequence so I tried
      <dtml-call "manage_delObjects('the_id')">
but this fails because as you say it looks for an object called the_id and I
need to pass in the value of the_id not the name of it.

Ideally I want to say
        <dtml-call "manage_delObjects(REQUEST['id_to_delete'])">
but again this fails to find the object.

Any ideas?

Thanks for helping,

Alex

> -----Original Message-----
> From: Seb Bacon [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 06, 2000 8:50 PM
> To: Bowyer, Alex; [EMAIL PROTECTED]
> Subject: RE: [Zope] Help wanted on Zope ZClasses/DTML please.
> 
> 
> 
> > I have worked out thanks to Seb's comments that the problem I
> > have with the
> > use of manage_delObjects is (I think) that I am passing in 
> the title or id
> > of the object to be deleted rather than the object itself.
> 
> Not quite... manage_delObjects takes a string which is the id 
> of the object
> to be deleted.  Your example
> 
>     <dtml-call "manage_delObjects('the_id')">
> 
> was passing a string 'the_id' to the method.  I might have 
> interpreted what
> you were trying to do wrongly, but I believe you actually 
> wanted to pass the
> _value_ of the_id.
> 
> > I want to put the object into the REQUEST so I can still 
> access it from a
> > different namespace - at the point I want to do the 
> deletion, my target
> > object is out of scope.
> 
> In fact you just have to put the correct string into the 
> REQUEST and then
> make sure you have the object you're trying to reference in 
> your current
> namespace, e.g. by using <dtml-with foo_namespace><dtml-var
> "manage_delObjects(the_id)"></dtml-with>.  If you need more 
> help, post the
> snippet you're working on again.
> 
> seb.
> 

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
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 )

Reply via email to