How to get the url without the domain part, using <dtml-in>?
Is it possible to return the absolute url without the domain/IP part, while in an iteration? With absolute_url I get this: http://100.0.0.1/folder0/folder1/folder2/current_object , and instead I'd like to have this: /folder0/folder1/folder2/current_object I tried the BASEPATH special variable, but it seems that it doesn't work within <dtml-in>. The other downside is that it needs an argument to get to know the nesting level of the object. Has anyone found a workaround? Thanks in advance, Ausum
I've just found a workaround based on a previous message by T.J. Mannos: <dtml-in "folder.objectItems()"> <dtml-let transitional_variable=absolute_url> <dtml-var "_.string.split(_.str(transitional_variable), ':8080')[1]" ><br> </dtml-let> </dtml-in> Given the fact that the port number is always present in the absolute_url variable (in Zope), it's convenient to use it as a string to delimit the needed part of the url. If this were not the case, I guess it's possible to use any part of the domain name close to the first slash after it. Ausum ----- Mensaje original ----- De: "Ausum" <augusto@artlover.com> Para: <zope@zope.org> Enviado: Martes, 06 de Marzo de 2001 08:12 p.m. Asunto: [Zope] How to get the url without the domain part, using <dtml-in>?
Is it possible to return the absolute url without the domain/IP part, while in an iteration? With absolute_url I get this:
http://100.0.0.1/folder0/folder1/folder2/current_object ,
and instead I'd like to have this:
/folder0/folder1/folder2/current_object
I tried the BASEPATH special variable, but it seems that it doesn't work within <dtml-in>. The other downside is that it needs an argument to get to know the nesting level of the object.
Has anyone found a workaround?
Thanks in advance,
Ausum
Given the fact that the port number is always present in the absolute_url variable (in Zope), it's convenient to use it as a string to delimit the needed part of the url. If this were not the case, I guess it's possible to use any part of the domain name close to the first slash after it.
Boy, that is pretty ugly. What if you move to a different port, or a different host? All of your DTML breaks? I think I'd use the standard urlparse module in an external method or PythonScript, if there isn't an even simpler way of doing it. --jfarr
I think you're right, Jonothan. A generic workaround would be this: <dtml-in "folder.objectItems()"> <dtml-let transitional_variable=absolute_url> <dtml-var "_.string.split(_.str(transitional_variable), BASE0)[1]" ><br> </dtml-let> </dtml-in> ...always based on T.J.'s message. Ausum ----- Mensaje original ----- De: "Jonothan Farr" <jfarr@real.com> Para: "Ausum" <webmaster@enjoyperu.com>; <zope@zope.org> Enviado: Martes, 06 de Marzo de 2001 09:50 p.m. Asunto: Re: [Zope] Solved: How to get the url without the domain...
Given the fact that the port number is always present in the absolute_url variable (in Zope), it's convenient to use it as a string to delimit the needed part of the url. If this were not the case, I guess it's possible to use any part of the domain name close to the first slash after it.
Boy, that is pretty ugly. What if you move to a different port, or a different host? All of your DTML breaks? I think I'd use the standard urlparse module in an external method or PythonScript, if there isn't an even simpler way of doing it.
--jfarr
From: "Jonothan Farr" <jfarr@real.com>
Boy, that is pretty ugly. What if you move to a different port, or a different host? All of your DTML breaks? I think I'd use the standard urlparse module in an external method or PythonScript, if there isn't an even simpler way of doing it.
I missed the start of the thread; Have you tried "absolute_url(1)"? Cheers, Evan @ digicool & 4-am
participants (3)
-
Ausum -
Evan Simpson -
Jonothan Farr