Hi, I have a question. I really don't know how to solve this problem. I have <ul> <li tal:define="links python:{ 'Catalog/index.html':'Catalog', 'Users/index.html':'Users', 'Orders/index.html':'Orders'}" tal:repeat="item links/items"> <a href="" tal:attributes= "href string:${container/absolute_url}/${python:item[0]}" tal:content="python:item[1]">link name</a> </li> </ul> this is _of course_ not working because of ${python:item[0]}. It's illegal. But with this expression I want to show what I want to do: I want to add a python expression to a string. How can I do this??? Thanks, Ferhat __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--On 30. August 2006 04:18:53 -0700 Ferhat Ayaz <ferhatayaz@yahoo.com> wrote:
this is _of course_ not working because of ${python:item[0]}. It's illegal.
Why don't you use a tal:define inside the same tag to bind the value of this expression to a variable and use this variable inside tal:attributes instead? -aj
yes, you're right. With define it works. Below is the same code with define. Thank you. But now I have another problem (actually my main problem). For instance,if you click more and more on the link 'Catalog'. The URL grows up like http://localhost:8080/Site/Catalog/Catalog/Catalog/..../index.html How can I say that the Catalog folder is just under the Site folder? <ul> <li tal:define="links python:{ 'Catalog/index.html':'Catalog', 'Users/index.html':'Users', 'Orders/index.html':'Orders'}" tal:repeat="item links/items"> <a href="" tal:define="link python:item[0]" tal:attributes="href string:${container/absolute_url}/${link}" tal:content="python:item[1]">link name</a> </li> </ul> --- Andreas Jung <lists@zopyx.com> wrote:
--On 30. August 2006 04:18:53 -0700 Ferhat Ayaz <ferhatayaz@yahoo.com> wrote:
this is _of course_ not working because of ${python:item[0]}. It's illegal.
Why don't you use a tal:define inside the same tag to bind the value of this expression to a variable and use this variable inside tal:attributes instead?
-aj
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 30 Aug 2006, at 13:32, Ferhat Ayaz wrote:
yes, you're right. With define it works. Below is the same code with define. Thank you. But now I have another problem (actually my main problem). For instance,if you click more and more on the link 'Catalog'. The URL grows up like http://localhost:8080/Site/Catalog/Catalog/Catalog/..../index.html How can I say that the Catalog folder is just under the Site folder?
You're using relative paths, and that's bad. You should only ever use fully qualified paths, like "/path/to/item" instead of "to/item". jens -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFE9YY6RAx5nvEhZLIRApUVAKCbUe2UjZHET2FQUXQvZQnoFsF4cwCgnocs UhTnhhY2UcDG1jRNtkGVx4k= =smrZ -----END PGP SIGNATURE-----
but my site root is /Site and not /, which can be changed later. Should I define this as a variable, or is there a better way? thanks, Ferhat --- Jens Vagelpohl <jens@dataflake.org> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 30 Aug 2006, at 13:32, Ferhat Ayaz wrote:
yes, you're right. With define it works. Below is
the
same code with define. Thank you. But now I have another problem (actually my main problem). For instance,if you click more and more on the link 'Catalog'. The URL grows up like
http://localhost:8080/Site/Catalog/Catalog/Catalog/..../index.html
How can I say that the Catalog folder is just under the Site folder?
You're using relative paths, and that's bad. You should only ever use fully qualified paths, like "/path/to/item" instead of "to/item".
jens
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin)
iD8DBQFE9YY6RAx5nvEhZLIRApUVAKCbUe2UjZHET2FQUXQvZQnoFsF4cwCgnocs
UhTnhhY2UcDG1jRNtkGVx4k= =smrZ -----END PGP SIGNATURE----- _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 30 Aug 2006, at 14:40, Ferhat Ayaz wrote:
but my site root is /Site and not /, which can be changed later. Should I define this as a variable, or is there a better way?
Yes there is. Ditch hardcoded strings and ask the objects themselves for their path. So in your code you could say... Site.absolute_url() instead of "/" or "/Site", because it will do the right thing with virtual hosting. jens -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFE9YhMRAx5nvEhZLIRApbJAJ4x+iwpT68gyBIfpBCIQmRTrrJWgQCgpyH4 JIRjVtOC/Y8sCas6ffvDYRs= =UfE6 -----END PGP SIGNATURE-----
Thanks to all. Now I extracted the links to a python script like url = container.Site.absolute_url() return { url+'/Catalog/index.html': 'Catalog', url+'/Members/index.html': 'Members', url+'/Orders/index.html': 'Orders', }.items() and this works fine. index.html was just an example. I'll change the link names. But I'm still not so happy with this solution because I must change the line url = container.Site.absolute_url() to url = container.<my-site-root>.absolute_url() later after productive installation. Greets, Ferhat --- Jens Vagelpohl <jens@dataflake.org> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 30 Aug 2006, at 14:40, Ferhat Ayaz wrote:
but my site root is /Site and not /, which can be changed later. Should I define this as a variable, or is there a better way?
Yes there is. Ditch hardcoded strings and ask the objects themselves for their path. So in your code you could say...
Site.absolute_url()
instead of "/" or "/Site", because it will do the right thing with virtual hosting.
jens
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin)
iD8DBQFE9YhMRAx5nvEhZLIRApbJAJ4x+iwpT68gyBIfpBCIQmRTrrJWgQCgpyH4
JIRjVtOC/Y8sCas6ffvDYRs= =UfE6 -----END PGP SIGNATURE----- _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 30 Aug 2006, at 15:26, Ferhat Ayaz wrote:
Thanks to all. Now I extracted the links to a python script like
url = container.Site.absolute_url() return { url+'/Catalog/index.html': 'Catalog', url+'/Members/index.html': 'Members', url+'/Orders/index.html': 'Orders', }.items()
and this works fine. index.html was just an example. I'll change the link names. But I'm still not so happy with this solution because I must change the line
url = container.Site.absolute_url()
If you use the CMF or Plone there are other ways to get at the site URL without involving hardcoded object names. You can acquire the portal_url tool, calling it will give you the correct site url no matter what the site ID is. jens -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFE9ZPyRAx5nvEhZLIRAvFhAKCPeEwvleUej7R2860astL4u5dlfwCdEjqO 1DXZGcfdE69vDhlRC0D+Xrc= =TY35 -----END PGP SIGNATURE-----
--On Mittwoch, 30. August 2006 04:32 -0700 Ferhat Ayaz <ferhatayaz@yahoo.com> wrote:
yes, you're right. With define it works. Below is the same code with define. Thank you. But now I have another problem (actually my main problem). For instance,if you click more and more on the link 'Catalog'. The URL grows up like http://localhost:8080/Site/Catalog/Catalog/Catalog/..../index.html How can I say that the Catalog folder is just under the Site folder?
<ul> <li tal:define="links python:{ 'Catalog/index.html':'Catalog', 'Users/index.html':'Users', 'Orders/index.html':'Orders'}" tal:repeat="item links/items"> <a href="" tal:define="link python:item[0]" tal:attributes="href string:${container/absolute_url}/${link}" tal:content="python:item[1]">link name</a> </li> </ul>
Why don't you better use python script to prepare your search and results and use its return value (usually prepacked, preformattet data in lists and dictionaries) instead? Links to index.html are also extremly ugly. Why not just link to the container? Regards Tino Wildenhain
participants (4)
-
Andreas Jung -
Ferhat Ayaz -
Jens Vagelpohl -
Tino Wildenhain