[Zope] Re: Why doesn't this work?
2 From: Andreas Jung [EMAIL PROTECTED] - --On 8. Dezember 2006 10:38:25 -0800 Javier Subervi [EMAIL PROTECTED] wrote: html But when I try to make it work in an External Method like this: stuff = 'html\n' stuff = stuff + 'body\n' stuff = stuff + 'table width=100% align=center class=text border=3 cellspacing=5 bgcolor=#E694FE bordercolor=#D24BFA bordercolorlight=#DD77FB bordercolordark=#C512FAtrtd\n' stuff = stuff + 'span metal:use-macro=here/en-us/Quotes/10/macros/quote/spanbr /\n' stuff = stuff + 'div align=centerspan class=text\n' stuff = stuff + ' a href=All_Quotes.pt target=_topbShow me all the quotes!/b/a\n' stuff = stuff + '/span/div\n' stuff = stuff + '/td/tr/table\n' stuff = stuff + '/body\n' stuff = stuff + 'html\n' An external method is not a ZPT. The external method returns just HTML. Why and how should Zope treat interpret *something* inside the HTML generated by the external method as macro? If you want a macro, the called object has to be a ZPT - nothing else. - -aj If you want something different: you must instantiate a Pagetemplate inside your external method, add the content through the related API and let the pagetemplate render the content. But there is usually no need for such an approach. Somehow you're trying to do something the wrong way round. What I'm trying to do is change the line in question to this: stuff = stuff + 'span metal:use-macro=here/en-us/Quotes/' + `randrange(1, len(self.objectValues()), 1)` + '/macros/quote /spanbr /\n' So it generates a random number. Now, that's the easy scenario, and for that I originally had just a Page Template. However, next up I need to be able to accommodate another folder which requires: 1) walking the folder, opening each subfolder 2) creating a tuple of the folder (or numerical representation) plus the number of the quote 3) randomly choosing a quote from all the subfolders Ideas? Perhaps I should instantiate a page template in the ext. method. How would I do that? TIA, Javier Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Re: Why doesn't this work?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 - --On 8. Dezember 2006 11:55:18 -0800 Javier Subervi [EMAIL PROTECTED] wrote: 2 From: Andreas Jung [EMAIL PROTECTED] - --On 8. Dezember 2006 10:38:25 -0800 Javier Subervi [EMAIL PROTECTED] wrote: html But when I try to make it work in an External Method like this: stuff = 'html\n' stuff = stuff + 'body\n' stuff = stuff + 'table width=100% align=center class=text border=3 cellspacing=5 bgcolor=#E694FE bordercolor=#D24BFA bordercolorlight=#DD77FB bordercolordark=#C512FAtrtd\n' stuff = stuff + 'span metal:use-macro=here/en-us/Quotes/10/macros/quote/spanbr /\n' stuff = stuff + 'div align=centerspan class=text\n' stuff = stuff + ' a href=All_Quotes.pt target=_topbShow me all the quotes!/b/a\n' stuff = stuff + '/span/div\n' stuff = stuff + '/td/tr/table\n' stuff = stuff + '/body\n' stuff = stuff + 'html\n' An external method is not a ZPT. The external method returns just HTML. Why and how should Zope treat interpret *something* inside the HTML generated by the external method as macro? If you want a macro, the called object has to be a ZPT - nothing else. - -aj If you want something different: you must instantiate a Pagetemplate inside your external method, add the content through the related API and let the pagetemplate render the content. But there is usually no need for such an approach. Somehow you're trying to do something the wrong way round. What I'm trying to do is change the line in question to this: stuff = stuff + 'span metal:use-macro=here/en-us/Quotes/' + `randrange(1, len(self.objectValues()), 1)` + '/macros/quote /spanbr /\n' So it generates a random number. Now, that's the easy scenario, and for that I originally had just a Page Template. However, next up I need to be able to accommodate another folder which requires: 1) walking the folder, opening each subfolder 2) creating a tuple of the folder (or numerical representation) plus the number of the quote 3) randomly choosing a quote from all the subfolders You want to generate HTML as a result? You want to use to write ZPT! You want to call external functionalities? You create an external method and call it *from* your ZPT. That's the way to go. - -aj -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Darwin) iD8DBQFFecRlCJIWIbr9KYwRAu5lAKDZU/UTfisFbQ4HU9G5cSOAFigJsQCfWcFb WPZrh6JgQR/qJu2xVqATL/8= =vXTm -END PGP SIGNATURE- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: Why doesn't this work?
From: Andreas Jung [EMAIL PROTECTED] You want to generate HTML as a result? You want to use to write ZPT! You want to call external functionalities? You create an external method and call it *from* your ZPT. That's the way to go. okey dokey. Thanks, Javier Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now.___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )