Problem

I was facing the following scenario: a plone site with 2 addresses: one for the public and one for the administration. The site was using qPloneComments which has a mechanism for mail notification. However given that the comments where approved on the admin site the public users where receiving emails containing that private address inside because the templates in qPloneComments are using obj/absolute_url.

Solution

This is a very quick fix to modify these templates in order to use relative urls and a known public url for the site thus allowing the url to work for the public users. Here is the rejected_comment_template.pt before:

...<br></br>Your comment on <tal:x tal:replace="obj/absolute_url"/> did not receive<br></br>approval. Please direct any questions or concerns to <tal:x replace="options/mfrom"/>.<br></br>...<br></br>

and after:

...<br></br>Your comment on <tal:x tal:replace="python:'http://www.len.ro/'+obj.absolute_url(relative=1).replace('len/','',1)"/> did not receive<br></br>approval. Please direct any questions or concerns to <tal:x replace="options/mfrom"/>.<br></br>...<br></br>

It works by using obj.absolute_url(relative=1) to get the absolute url and the a string method to remove other preffix.

The files I had to change are:

  • approve_comment_template.pt
  • rejected_comment_template.pt
  • notify_comment_template.pt
  • reply_notify_template.pt
  • published_comment_template.pt