[Zope] Removing part of a string (in an URL)
T. J. Mannos
MannosTJ@slcc.edu
Sat, 01 Jul 2000 01:01:01 -0600
Walter,
Try a little trick I use with _.string.split(). split() splits a string into two (or more) parts based on a delimiter. In this case, the delimiter could be any part of the URL directly to the left of /Zorba/busca/...
For example:
<dtml-var "_.string.split(url, ':8080')[1]">
This splits the URL into 'http://zorba.com.mx' (which you don't want) and '/Zorba/busca/Zorba/...' (which you do want). The [1] tells Zope to take only the second part, the part you want.
If you plan to make this code portable incase you switch servers or use a SiteRoot, I believe (and correct me if I'm wrong) you're safer using the 'BASE0' property for your delimiter. For example:
<dtml-var "_.string.split(url, BASE0)[1]">
Now, I don't know about the organizational problems that prevent you from dropping the /Zorba/busca, but I'd assume you would do the same thing, except replace "BASE0" with "BASE0 '/Zorba/busca'". I'm thinking, though, you'll eventually want to set up a separate server and a SiteRoot so that your web address will be http://zorba.com.mx/Zorba/cacharrito/prueba -- right?
- T.J.
<<< "Walter A. Aprile" <walter@ilce.edu.mx> 6/30 11:19p >>>
Hi,
more newbie questions, I am afraid. I have a ZCatalog result form
that boringly forms links this way:
<dtml-var "busca.getpath(data_record_id_)">
Due to the way my site is organized, the URL I get has an unwanted
part at the beginning. The part is always the same size, and the same string
in fact. How do I remove it ? For example, the URL is
http://zorba.com.mx:8080/Zorba/busca/Zorba/cacharrito/prueba
^
and I would like to cut it here |
and turn it into
/Zorba/cacharrito/prueba
The problem is that the URL above is still valid, but if I do another
search then the same /Zorba/busca gets added, and it gets longer and longer,
besides messing up my breadcrumb trail.
I tried using a regular expression method, but I do not really know
Python (not yet !), so it did not work.
Thank you very much
Walter
-- Vita brevis, ars longa, occasio celeris, experimentum periculosum,
judicium difficile. Attention: Un train peut en cacher un autre
-><- Eris aprueba este email ! -><- http://redescolar.ilce.edu.mx
_______________________________________________
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 )