Model-Glue:Unity "ActionPacks"

One critique I've heard about Model-Glue is that there's no easy way to create "modules" of functionality that can be "dropped in" to existing applications. I mean, wouldn't it be nice to write a forum app, and then just say "add this to my Model-Glue application?"

[Read more on Joe Rinehart's blog]

Well, there's a new tag in Model-Glue:Unity that allows just this: <include> as a child of <modelglue>. I've resisted it for a while, but I think that, when used properly, it could be a very nice addition to the framework.

This addition means that any ModelGlue.xml file can other ModelGlue.xml-format files, and that the "child" files can declare their own <controllers> and <event-handlers>.

Additionally, the Model-Glue XML "fragments" can use the <setting> tag to declare additional XML files to load into ColdSpring as well as additional directories to use as view mappings.

Example

This means that I could have a Wiki.xml "fragment" file declaring everything needed for a wiki:

<modelglue>
<config>
<!-- Add the wiki /views dir to the viewmappings -->
<setting name="viewMappings" setting="/mgwiki/views" />
</config>

<controller name="wikiController" type="mgwiki.WikiController">
<message-listener message="wiki.page" function="getPage" />
<!--- other listeners... --->
</controller>

<event-handlers>
<event-handler name="wiki.displayPage">
<broadcasts>
<message name="wiki.page" />
</broadcasts>
<views>
<include name="body" template="dspWikiPage.cfm" />
</views>
<results>
<result do="view.template" />
</results>
</event-handler>

<!--- More event handlers... --->
</event-handlers>
</modelglue>

Then, if I wanted to add Wiki functionality to any other Model-Glue application, I could change its ModelGlue.xml file to include the Wiki fragment:

<modelglue>
<include template="/mgwiki/config/Wiki.xml" />

<!--- Application stuff...--->
</modelglue>

Dangers of Includes

Doing this isn't without a danger: it's quite possible that an include would overwrite an existing event handler or controller. That's the reason I prefixed everything with "wiki" :).

"ActionPacks?"

I'm planning on releasing a few fragments in the publuc "2.0" Unity release that I'll be calling "ActionPacks." One will provide an easy to use, configurable e-mail service. Another will provide role-based and row-level security, user profile management, and user administration interfaces.

Because these "ActionPacks" don't require any change to the framework, and are really just Model-Glue XML fragments, anyone is free to contribute their own to the Model-Glue community. If anyone's interested in developing them, I'd be happy to help out where I can, and for select Action Packs (like maybe a forums app!), adding them to the Model-Glue distro itself.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
OK... is this technology still possible with 3.0? It seems like modules would be a good thing to me and you can include me in the group of developers who want to build modules. :)
# Posted By John Farrar | 6/23/09 9:18 AM
© 2018 Joe Rinehart
BlogCFC was created by Raymond Camden. This blog is running version 5.9.3.006.