Fix reversing URLs on Local Site with template caching turned on.

Review Request #4873 — Created Oct. 31, 2013 and submitted

Information

Review Board
release-1.7.x

Reviewers

Fix reversing URLs on Local Site with template caching turned on.

A while back on RBCommons, we hit a bug after enabling template caching
where URLs weren't reversing properly. Reversing would seem to work at
times, and at other times, the page would break due to a lookup failure.
In these cases, it was always failing to find a URL with local_site_name
in the kwargs.

This turns out to be due to a bug on our end, and not something due to
us overriding the url template tag.

When building the cached nodes and rendering the first time, all would
be well, but then we'd set url_node.kwargs to equal self.kwargs in our
custom template tag. Future renders would re-use the instances of our
tag, and therefore the kwargs and the url_node attributes. kwargs would
be populated with a 'local_site_name' key, and all would fail from there
on out.

We just need to copy our args/kwargs when setting url_node, and not
assign directly.

Tested locally with template caching and a local site. I was able to
reliably trigger the failures before this change. After, I couldn't
make it happen once.

david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...