Hi, <dtml-let article=absolute_url> <dtml-var article> </dtml-let> <a href="&dtml-absolute_url;"> more </a> With the code above I was able to display absolute_url through var article, but I was unable to slice the var article to extract out the text i needed with this code. <dtml-let article=absolute_url> <dtml-var expr="article[50:9]"> </dtml-let> <a href="&dtml-absolute_url;"> more </a> I need somebody to please help me out of this problem. Thanks. ===== Hamzat kamaldeen Ishola Dnet Systems Limited. 223 Ikorodu Road, Lagos. Nigeria. 234 1 7749381, 234 08033011305 --- If Mistake is an opportunity to see better, then it is not a problem but readiness to admit it. Sentimental decisions are not mistakes but failures !!! __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com
On Friday 09 August 2002 11:08 am, Sir K wrote:
Hi,
<dtml-let article=absolute_url> <dtml-var article> </dtml-let> <a href="&dtml-absolute_url;"> more </a>
With the code above I was able to display absolute_url through var article, but I was unable to slice the var article to extract out the text i needed with this code.
<dtml-let article=absolute_url> <dtml-var expr="article[50:9]">
The python slicing syntax is: stringvar[start:end] If start > end then you always get an empty string (unless end is negative which means "from the right").
</dtml-let> <a href="&dtml-absolute_url;"> more </a>
I need somebody to please help me out of this problem.
What is it you are trying to slice out of the URL, the name of the parent or something? Quite frankly the concept you have presented scares me ;^) There is likely a better way that doesn't involve slicing the URL. Please let us know what you are trying to do (rather than just throw broken code at us) and maybe we can help you better. -Casey
What is it you are trying to slice out of the URL, the name of the parent or something? Quite frankly the concept you have presented scares me ;^) There is likely a better way that doesn't involve slicing the URL.
Please let us know what you are trying to do (rather than just throw broken code at us) and maybe we can help you better.
-Casey
Thanks Casey, I made silly mistake by making start > end. I feel sorry for myself ! Anyway what I was trying to do is this; I have a DTML Method that search a Zcatalog to return all the Dtml Docs with id matching var mm. I was able to display the absolute_url of these Docs without any stress. Then there is need for me to get some of the Docs and display at least some paragraphs b4 pointing the absolute_url to the their details.These docs are inside subfolders which are in the same level as the DTML Method. So, what i was using the slicing for is to extract each subfolders name from absolute_url so that i can be able to point to them and call the particular DTML Doc. This is the code; <dtml-call "REQUEST.set('mm', ZopeTime().toZone('GMT+1').strftime('%d%m%y'))"> <dtml-in "Zcat_Index_Dtml_doc(mm=id)"> <dtml-if "mm==id"> <dtml-let article=absolute_url> <dtml-with "article[49:57]"> <dtml-var expr="_.getitem(mm,1)[0:400]">...<br> <a href="&dtml-absolute_url;"> more </a> </dtml-with> </dtml-let> </dtml-if> </dtml-in> Even with this I am still having ; Error Type: KeyError Error Value: 090802 But anytime I change <dtml-with "article[49:57]"> to <dtml-with "article1"> which is one the subfolders' name It displays only the DTML Doc 090802 in the article1 folder. I will be looking forward to your help. Thanks once again. ===== Hamzat kamaldeen Ishola Dnet Systems Limited. 223 Ikorodu Road, Lagos. Nigeria. 234 1 7749381, 234 08033011305 --- If Mistake is an opportunity to see better, then it is not a problem but readiness to admit it. Sentimental decisions are not mistakes but failures !!! __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com
Sir K wrote:
What is it you are trying to slice out of the URL, the name of the parent or something? Quite frankly the concept you have presented scares me ;^) There is likely a better way that doesn't involve slicing the URL.
Please let us know what you are trying to do (rather than just throw broken code at us) and maybe we can help you better.
-Casey
Thanks Casey,
I made silly mistake by making start > end. I feel sorry for myself !
Anyway what I was trying to do is this; I have a DTML Method that search a Zcatalog to return all the Dtml Docs with id matching var mm. I was able to display the absolute_url of these Docs without any stress. Then there is need for me to get some of the Docs and display at least some paragraphs b4 pointing the absolute_url to the their details.These docs are inside subfolders which are in the same level as the DTML Method.
So, the documents are being returned via a ZCatalog search? Try this: <dtml-call "REQUEST.set('mm', ZopeTime().toZone('GMT+1').strftime('%d%m%y'))"> <dtml-in "Zcat_Index_Dtml_doc(id=mm)"> <dtml-var expr="getObject[0:400]">...<br> <a href="&dtml-getURL;"> more </a> </dtml-in> ...note that this uses the getObject and getURL methods that ZCatalog search results normally have. cheers, Chris
--- Chris Withers <chrisw@nipltd.com> wrote:
So, the documents are being returned via a ZCatalog search? Try this:
<dtml-call "REQUEST.set('mm', ZopeTime().toZone('GMT+1').strftime('%d%m%y'))">
<dtml-in "Zcat_Index_Dtml_doc(id=mm)"> <dtml-var expr="getObject[0:400]">...<br> <a href="&dtml-getURL;"> more </a> </dtml-in>
...note that this uses the getObject and getURL methods that ZCatalog search results normally have.
Hi Chris, This is the error encountered when I tried it. Error Type: TypeError Error Value: unsliceable object Thanks for the support. ===== Hamzat kamaldeen Ishola Dnet Systems Limited. 223 Ikorodu Road, Lagos. Nigeria. 234 1 7749381, 234 08033011305 --- If Mistake is an opportunity to see better, then it is not a problem but readiness to admit it. Sentimental decisions are not mistakes but failures !!! __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com
Sir K wrote:
<dtml-var expr="getObject[0:400]">...<br> <a href="&dtml-getURL;"> more </a> </dtml-in>
This is the error encountered when I tried it.
Error Type: TypeError Error Value: unsliceable object
use <dtml-var expr="getObject()[0:400]"> instead. Chris
Sir K writes:
<dtml-let article=absolute_url> <dtml-var expr="article[50:9]"> Slicing in Python has the form "...[start_index:end_index]" and not "...[start_index:length_of_slice]".
"start_index" is included, "end_index" not, such that "end_index-start_index" gives the slice length. Dieter
participants (4)
-
Casey Duncan -
Chris Withers -
Dieter Maurer -
Sir K