On Tue, May 11, 2004 at 01:04:12AM -0400, Daniel Lundin wrote:
> Good point. Maybe we should even have a config variable with a formatting
> string for the Subject-header.
That would be good.
> It's a bug and my bad. It's supposed to be project.url (as specified when
> running 'trac-admin foo initdb').
Thanks for fixing it.
> This is actually a [potential] issue with the Href class. The Href stuff
> should probably generate absolute paths for links instead of relative ones,
> making it more robust/portable. It would be nice to always rely on
> 'env.href.ticket(42)' always being a valid and useful URL no matter what
> context.
I added an env.abs_href in the attached patch, to avoid disturbing
much of everything. The method I use for constructing it is approved
for CGI environments at least:
<http://httpd.apache.org/docs-2.0/cgi_path.html>
I do not have a tracd installation so I don't know if it breaks
anything there.
--
=Nicholas Riley <njriley@uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
-------------- next part --------------
Index: trac/core.py
===================================================================
--- trac/core.py (revision 490)
+++ trac/core.py (working copy)
@@ -284,6 +284,15 @@
def init_request(self):
Request.init_request(self)
self.cgi_location = os.getenv('SCRIPT_NAME')
+ host = os.getenv('SERVER_NAME')
+ port = int(os.getenv('SERVER_PORT'))
+ if port == 80:
+ self.cgi_url = 'http://%s%s' % (host, self.cgi_location)
+ elif port == 443:
+ self.cgi_url = 'https://%s%s' % (host, self.cgi_location)
+ else:
+ self.cgi_url = 'http://%s:%d%s' % (host, port,
+ self.cgi_location)
self.remote_addr = os.getenv('REMOTE_ADDR')
self.remote_user = os.getenv('REMOTE_USER')
self.command = os.getenv('REQUEST_METHOD')
@@ -384,6 +393,7 @@
if not hasattr(env, 'href') or not env.href:
env.href = Href.Href(req.cgi_location)
+ env.abs_href = Href.Href(req.cgi_url)
authenticator = auth.Authenticator(database, req)
if path_info == '/logout':
Index: trac/Notify.py
===================================================================
--- trac/Notify.py (revision 490)
+++ trac/Notify.py (working copy)
@@ -163,7 +163,7 @@
self.newticket = newticket
self.ticket['description'] = wrap(self.ticket['description'],
self.COLS)
- self.ticket['link'] = self.env.href.ticket(tktid)
+ self.ticket['link'] = self.env.abs_href.ticket(tktid)
add_dict_to_hdf(self.ticket, self.hdf, 'ticket')
self.hdf.setValue('email.ticket_props', self.format_props())
self.hdf.setValue('email.ticket_body_hdr', self.format_hdr())
> Good point. Maybe we should even have a config variable with a formatting
> string for the Subject-header.
That would be good.
> It's a bug and my bad. It's supposed to be project.url (as specified when
> running 'trac-admin foo initdb').
Thanks for fixing it.
> This is actually a [potential] issue with the Href class. The Href stuff
> should probably generate absolute paths for links instead of relative ones,
> making it more robust/portable. It would be nice to always rely on
> 'env.href.ticket(42)' always being a valid and useful URL no matter what
> context.
I added an env.abs_href in the attached patch, to avoid disturbing
much of everything. The method I use for constructing it is approved
for CGI environments at least:
<http://httpd.apache.org/docs-2.0/cgi_path.html>
I do not have a tracd installation so I don't know if it breaks
anything there.
--
=Nicholas Riley <njriley@uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
-------------- next part --------------
Index: trac/core.py
===================================================================
--- trac/core.py (revision 490)
+++ trac/core.py (working copy)
@@ -284,6 +284,15 @@
def init_request(self):
Request.init_request(self)
self.cgi_location = os.getenv('SCRIPT_NAME')
+ host = os.getenv('SERVER_NAME')
+ port = int(os.getenv('SERVER_PORT'))
+ if port == 80:
+ self.cgi_url = 'http://%s%s' % (host, self.cgi_location)
+ elif port == 443:
+ self.cgi_url = 'https://%s%s' % (host, self.cgi_location)
+ else:
+ self.cgi_url = 'http://%s:%d%s' % (host, port,
+ self.cgi_location)
self.remote_addr = os.getenv('REMOTE_ADDR')
self.remote_user = os.getenv('REMOTE_USER')
self.command = os.getenv('REQUEST_METHOD')
@@ -384,6 +393,7 @@
if not hasattr(env, 'href') or not env.href:
env.href = Href.Href(req.cgi_location)
+ env.abs_href = Href.Href(req.cgi_url)
authenticator = auth.Authenticator(database, req)
if path_info == '/logout':
Index: trac/Notify.py
===================================================================
--- trac/Notify.py (revision 490)
+++ trac/Notify.py (working copy)
@@ -163,7 +163,7 @@
self.newticket = newticket
self.ticket['description'] = wrap(self.ticket['description'],
self.COLS)
- self.ticket['link'] = self.env.href.ticket(tktid)
+ self.ticket['link'] = self.env.abs_href.ticket(tktid)
add_dict_to_hdf(self.ticket, self.hdf, 'ticket')
self.hdf.setValue('email.ticket_props', self.format_props())
self.hdf.setValue('email.ticket_body_hdr', self.format_hdr())