Ok -- I checked in the code. In the refactored IteratorTag and subclasses, the approach I took to context-switching was this:
- When an IteratorTag starts iterating, we keep a reference to the current WikiContext in the private holding variable m_oldWikiContext. Then we clone m_wikiContext and assign the clone to m_wikiContext. Then, we stash the new (temporary) context in the request by calling WikiContextFactory.saveContext(). - When the IteratorTag finishes, we restore the old context by calling WikiContextFactory.saveContext() again with m_originalContext. - During iterations, the only thing that really changes is the WikiPage. So we just let subclasses mess with the temporary context; for example, calling setPage(). We do NOT clone it for every iteration; there is frankly no need to do this. - At all times, m_wikiContext retains the reference to the context being rendered, same as always. However, we strongly discourage subclasses from re-assigning this field; we let the parent IteratorTag do all of this. I think this is a pretty sensible approach. The most important aspect of the refactoring is that we "pull up" responsibility for context manipulation into IteratorTag. There is no longer a need for subclasses to re-assign m_wikiContext. There are a few small things that I still need to clean up, but for the most part I'm happy with how it turned out. Andrew On Fri, May 22, 2009 at 5:57 AM, Andrew Jaquith <[email protected]> wrote: > HAH! I found the bastard. It's a cloning issue. WikiActionBeanContext wasn't > cloning it's delegate DefaultWikiContext. > > Anyway, while I was at it, I refactored all of the iterator tags, whacking > about 2/3 of the code (rampant cut-n-paste jobs). What I'll check in later > will be lean, clean and documented. :) > > Andrew > > On May 21, 2009, at 14:20, Janne Jalkanen <[email protected]> wrote: > >> >> It's likely that there is overlap in these techniques :-) >> >> /janne, typing one-handedly >> >> On 21 May 2009, at 21:03, Andrew Jaquith wrote: >> >>>> My guess is that some of your other modifications are causing problems >>>> with >>>> the page names - on 2.8.x, the AttachmentsIteratorTag seems to be >>>> working >>>> perfectly. Or maybe I misunderstood your problem? >>> >>> Yep, no question about it. Something isn't working as intended. I'll >>> need to dig a bit to figure out what's going on. I'm going to be >>> looking at a few issues: when m_wikiContext is actually changed; when >>> ATTR_WIKICONTEXT is set, and when WikiContext.setPage() is called. Any >>> of these three activities could be where the problem lies. >>> >>> Andrew >> >
