From: Alex F. <al...@fi...> - 2011-11-24 18:40:48
|
Dear all, I have absolutely no idea whether or not there is anybody on this list, or if they are whether or not they are interested in things webmacro, so I might be talking to myself, but here goes... First off, I've found a bug. Lets consider the following block of code: #templet $test { Original: $value <br /> #set $value = $value + 1 Incremented: $value <br /> } #eval $test using { "value": 1 } You run this in a servlet and it does what you would expect, ie: Original: 1 Incremented: 2 However if you reload the page shortly afterwards then you get the slightly surprising: Original: 2 Incremented: 3 which is much less what you would expect. I've been doing some initial poking around and from what I can see the problem is roughly along the lines of: - the parser compiles the {"value": 1} into a Map and then caches this - the EvalDirective passes this very same Map into the Context that is used to evaluate the $test templet - the $test templet makes changes to it's Context which then changes the cached compiled version of {"value": 1} - the next time we invoke $test, we pass in what we assume is the compiled version of {"value": 1}, but it actually now contains {"value": 2} If one leaves a pause between reloads and the caching engine discards the cached parsed templates then the value returns back to 1. Now obviously, the EvalDirective should be taking a shallow copy of the params before setting this as the Map that is backing the Context that is used to evaluate $test. I've mocked this up in user space so that I can invoke: #eval $test using $Vars.copyMap({ "value": 1 }) and I get the expected behaviour, ie the value doesn't increment between reloads. So I'm going to patch EvalDirective to sort this out which brings me onto my second point. I've been doing a bit of playing around with webmacro myself and I've got a clone of the git repository that Guy Bolton-King took of the sourceforge CVS repository and this is sitting at https://github.com/alex-fiennes/webmacro This has been a gentle experiment so far because I haven't found anything that is actually broken yet, but come this bug then I suspect that I might well start using my branch for production stuff rather than just playing around with ideas. Who else other than me is still using webmacro and should I just continue to work on my github branch and move forwards? Failing that, do people want me to backport changes across to sourceforge? Stuff that I have been initially working on in github is: - removing the dependencies on the EDU.oswego.cs.dl.util.concurrent packages and using the java concurrent packages - adding in generics declarations as required so that the package will compile cleanly against modern java. What I am planning to work on is: - adding in support for invoking varargs methods from inside templates - a certain amount of refactoring to use more of google guava libraries as appropriate - better error reporting on nested templet invocations If people want to let me know whether or not any of this is of interest to anyone then we can work out how to move forwards. If I don't hear back from anyone then I will assume that everyone has moved on to new pastures and I will just continue down the path outlined above. Alex -- Alex Fiennes email: al...@fi... mobile: +44 (0)7813 832662 office: +44 (0)1875 823 310 |