The PATH_INFO is /kirmess/ or /kirmess/index_html depending on how you call the document. I'd like to have it always without the document name. How can I cut everything behind the last / in a string? Sven -- PGP-Key-ID: 0x881BF222
dunno about the regex but in python, this is simply : if s[-1] != "/" : s[:string.rfind(s, "/")] which i guess should be something like this : <dtml-if "s[-1]=='/'"> <dtml-call "REQUEST.set(s, s[:_.string.rfind(s, '/')])"> </dtml-if> where s is your path_info (which you sub straight into the above) not sure what you need this for but you might want to check URL1 also. chas
The PATH_INFO is
/kirmess/
or
/kirmess/index_html
depending on how you call the document. I'd like to have it always without the document name. How can I cut everything behind the last / in a string?
Sven
-- PGP-Key-ID: 0x881BF222
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
Hi chas, Friday, October 01, 1999, 8:10:30 PM, you wrote:
dunno about the regex but in python, this is simply :
if s[-1] != "/" : s[:string.rfind(s, "/")]
which i guess should be something like this :
<dtml-if "s[-1]=='/'"> <dtml-if "s[-1]!='/'"> ^ <dtml-call "REQUEST.set(s, s[:_.string.rfind(s, '/')])"> <dtml-call "REQUEST.set('s', s[:_.string.rfind(s, '/')])"> ^ ^ </dtml-if>
where s is your path_info (which you sub straight into the above)
Yes. Thank you. Works great.
not sure what you need this for but you might want to check URL1 also.
URL1 includes the domain, so for every "click" there will be a DNS-request (the common Browsers don't cache DNS, IIRC). I use this <!--#call "REQUEST.set('path',PATH_INFO)" --> <dtml-if "path[-1]!='/'"> <dtml-call "REQUEST.set('path',SCRIPT_NAME+path[:_.string.rfind(path, '/')])"> </dtml-if> <a href="<!--#path-->/">x</a> and no DNS-request is needed. Sven -- PGP-Key-ID: 0x881BF222
<dtml-call "REQUEST.set(s, s[:_.string.rfind(s, '/')])">
<dtml-call "REQUEST.set('s', s[:_.string.rfind(s, '/')])"> ^ ^
</dtml-if>
where s is your path_info (which you sub straight into the above)
Yes. Thank you. Works great.
not sure what you need this for but you might want to check URL1 also.
URL1 includes the domain, so for every "click" there will be a DNS-request (the common Browsers don't cache DNS, IIRC).
Sorry, this is news to me. Doesn't URL1 just include the SERVER_URL (ie. whatever was put in the query string url ?) I develop off line so DNS lookups are not possible and yet I use URL1 all the time. It seems far fetched that we'd have to do a DNS lookup for each request. Wait, couldn't you just do this : URL1[_.len(SERVER_URL) That would give you the PATH_INFO minus any trailing dtml methods or documents. chas
Sorry, I must have been on drugs when I posted this earlier :
URL1[_.len(SERVER_URL)
That would give you the PATH_INFO minus any trailing dtml methods or documents.
I meant : URL1[_.len(SERVER_URL)+1:] It's a sad day when I can't even copy/paste properly. Of course, this might be totally unrelated to what you're actually looking for but it'll give you "Level1/Level2" for either of the URLs "http://domain/Level1/Level2" or "http://domain/Level1/Level2/index_html" and that's what I thought you were asking for. If not, CTRL+D now. chas
participants (2)
-
chas -
Sven Kirmess