As I do the work to add Atlas page models to Roller, I'd also like to refactor
the existing page model and context loading process to address a couple of
problems:

- Context loading process should not do unncessary work
- Context loading process and page models should not depend on Velocity

To accomplish this, I'm proposing that we:


1) establish a simple TemplateContext interface so page models can deal
with the Velocity Context in a generic way. Something simple like this:

  interface TemplateContext
     put(String s, Object o)
     Object get(String s)


2) we eliminate the ContextLoader class and make page models responsible
for loading the template context with the various globals that are associated
with the page model.


3) we create three different page models for our three different rendering
situations: weblog display, weblog entry/comments display and feed display.

First, all page models implement this interface because they're pluggable:

  interface PageModel
    getModelName()
    init(request, response, TemplateContext)

The WeblogPageModel becomes the new home for most of the code that was in
the old ContextLoader class, except for entry/comment and feed stuff.

  class WeblogPageModel implements PageModel
    Same as old PageModel class
    Init method loads TemplateContext (as ContextLoader once did)


The WeblogEntryPageModel extends WeblogPageModel because
entry/comments pages need the old PageModel methods. It's init method
calls super.init() and also loads comment specific values.

  WeblogEntryPageModel extends WeblogPageModel
    Init method loads TemplateContext with values needed for entry/comments

The FeedPageModel extends WeblogPageModel, because our feed templates (atom.vm
and rss.vm) depend on the old PageModel. The ContextLoader code that loaded
RSS values goes here.

  FeedPageModel extends WeblogPageModel
    Init method loads TemplateContext with values needed for feeds


4) change the PageServlet and FlavorServlet classes to load the appropriate
page models.

 class PageServlet
   if no weblog entry is specified
       Create page model specified by "weblogpagemodel.classname"
       put it into context
   else
       Create page model specified by "weblogentrypagemodel.classname"
       put it into context
   for each additional page model specified by current weblog
       Create page model
       put it into context

class FlavorServlet
   Create page model specified by "feedpagemodel.classname"
   put it into context


Thoughts, comments, objections?

- Dave

Reply via email to