Nested snippets and SHtml.memoize

89 views
Skip to first unread message

David Whittaker

unread,
Apr 22, 2011, 1:31:47 PM4/22/11
to liftweb
I have 2 snippets, one which transforms my page header and another which executes on HTML inside the header and output a menu.  Both of these snippets transform HTML that needs to be re-rendered on login, so I decided to memoize them with SHtml.memoize.  Unfortunately, I'm finding that the template for the outter memo is getting overwritten by the template from the inner memo.  I looked at the code and I see that the captured template is stored in a RequestVar, and that the salt used is based on the stack trace when the memo is created.  I would expect that would be fine, each memoize call happens in a different method (although they are in the same object) which I would think would lead to a different stack, but regardless of what I expect I can see that the second memoize is somehow clobbering the first.  In the meantime I'm going to switch them to SHtml.idMemoizeTransform which doesn't use a RequestVar, but I'm interested in figuring out what's going on here and if it can be fixed.

David Pollak

unread,
Apr 23, 2011, 9:54:46 AM4/23/11
to lif...@googlegroups.com
On Fri, Apr 22, 2011 at 10:31 AM, David Whittaker <da...@iradix.com> wrote:
I have 2 snippets, one which transforms my page header and another which executes on HTML inside the header and output a menu.  Both of these snippets transform HTML that needs to be re-rendered on login, so I decided to memoize them with SHtml.memoize.  Unfortunately, I'm finding that the template for the outter memo is getting overwritten by the template from the inner memo.  I looked at the code and I see that the captured template is stored in a RequestVar, and that the salt used is based on the stack trace when the memo is created.  I would expect that would be fine, each memoize call happens in a different method (although they are in the same object) which I would think would lead to a different stack, but regardless of what I expect I can see that the second memoize is somehow clobbering the first.  In the meantime I'm going to switch them to SHtml.idMemoizeTransform which doesn't use a RequestVar, but I'm interested in figuring out what's going on here and if it can be fixed.

Please open a ticket with an example and assign it to me for 2.4-M1 (unless you want to take a crack at fixing it.)  I want to make sure we fix this one up,
 

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.



--
Lift, the simply functional web framework http://liftweb.net
Reply all
Reply to author
Forward
0 new messages