Hamzat, You want to use a ZCatalog for this instead of doing a "brute force search" by looping over a bunch of folders. Any DTML-only solution is likely to be too slow for your purposes. It should go something like this: Each document that your users save should be cataloged in a ZCatalog that has a FieldIndex on the getId method. Then when you want particular ones back, you should look up the documents you want by issuing a query something like "getId=mm" where mm is the id of the document(s) you are looking for. You will get a sequence of "result" (aka "brain") objects back from the Catalog query, each one of which you can use to look up the actual objects. Or you can use Catalog metadata on each brain to display results without actually obtaining the real objects (assuming you set up your Catalog to support this). For more information, please refer to the Zope Book "Searching and Cataloging" chapter. On Tue, 2002-05-28 at 09:45, Hamzat Kamal wrote:
Dear chris,
Hamzat, It'd be useful to be able to understand what this DTML is trying to do... it seems like you're just looping over objects trying to find one with a particular id. Is "num" passed in as a form variable
What the DTML does is to loop over the folders and DTML Documents in each folder, look for DTML Document which its id equal to variable mm and display part of the doc as well as setting path to the full doc.
No, "num" get it value from a method which has been called above this extracted code below.
I also don't see how the '<dtml-if "mm==test">' conditional could ever be true. I'm sure it works, but I'm not sure how. ;-)
yes, you are right but in the actual code that is running the object id is assign to test rather than the sequence-item as shown in the code below. What happened was that somebody advise that it is a serious programming error to have used 2 objectValues in the 2 loops that I should change the objectValues for the inner loop to objectIds, that it could be the cause of the problem.
<dtml-in "objectValues(['DTML Document'])">
That was when i have to change the id to sequence-item.
Can you please explain to me the effects of using objectValues and objectIds?
In any case, I think you probably want to use a ZCatalog for this kind of search. Brute-force search is a very expensive operation.
On Mon, 2002-05-27 at 11:50, hamzatk@3dresearch.com wrote:
that is a good example for trying to use DTML where it should not be used anymore.
i suggest you move this logic into a more appropriate kind of object, such as a python script.
jens
<dtml-in "news.objectValues(['Folder'])"> <dtml-let number=sequence-number path=id> <dtml-if expr="number < _.int(num)"> <dtml-in "objectValues(['DTML Document'])"> <dtml-try> <dtml-call "REQUEST.set('mm', ZopeTime().toZone('GMT+1').strftime('%d%m%y'))"> <dtml-let test=sequence-item> <dtml-if expr="mm==test"> <font face=arial size=-5> <dtml-var expr="_.getitem(mm,1)[0:400]">....<br> <a href="&dtml-ngrHome;news/&dtml-path;"> <img src="images/morex.gif" border="0" width="60" height="23"> </a><br> <dtml-if expr="number < _.int(num)-1"> <hr size="2" width="75%"> </dtml-if> </font> </dtml-if> </dtml-let> <dtml-except> </dtml-try> </dtml-in> </dtml-if> </dtml-let> </dtml-in>
Regards.
===== Hamzat kamaldeen Ishola Dnet Systems Limited. 223 Ikorodu Road, Lagos. Nigeria. 234 1 7749381, 234 08033011305 --- Making Mistake is not a problem but readiness to admit it. Sentimental decisions are not mistakes but failures !!! Mistake is an opportunity to see better !!!
__________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
_______________________________________________ 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 )