Notes from Joe Rineharts talk on Model Glue at Frameworks 2007. Instead of being a presentation on Actionpacks, Joe changed the topic to Model-Glue 2 in general with focus on how it’s changed with 1.1 to the new Unity release still in beta. Actionpacks are a term used to describe included ModelGlue.xml files. Instead of one single ModelGlue.xml that contains the entire application, additional configuration files can now be included easily enough by adding a line at the top level in a ModelGlue configuration file.
In that file if we want to set the view directory, overriding the default view directory used for only that ModelGlue.xml files included views. In his example, Joe uses an actionpack to provide an XML version of any list, or return error messages provided by the ORM. This pack should be available soon, and only took Joe a few hours. Coldspring Joe really likes Coldspring. Using this magical configuration framework you abstract the creation of objects and let Coldspring worry about how these objects are obtained. There is a single model
/ModelGlue/unity/config/Configuration.xml file that provides the Model-Glue version for all model glue sites on the server. If needed this file can be edited, but generally you’d want to overwrite specific objects on a per-object basis in the applications configuration file.
Coldspring can’t create developers yet, but it’s getting there. – Joe Rinehart
In Joe’s example for extending the framework, he creates a new object that extends the modelglue statebuilder. In this copy he changes the myself variable name to thyself as an example change. Within a single application, a copy of the model glue configuration is made, and the reference to the statebuilder object is changed to the custom object just made. In order to tell Model Glue to use this Configuration.xml file is used, a path in the index.cfm is uncommented and pointed to the location of our new configuration file. No model glue core files were changed in this process, but it was extended. ORM No, there is no built in ORM to the framework. Reactor and Transfer work well with Unity, that use the Reactor/Transfer abstract ORM adapter which does the calls. This allows model glue to use a set of internal functions to access whatever ORM is defined in the ModelGlue.xml file. The ORM specific functionality are in the ReactorAdapter and TransferAdapter objects. Scaffolding Joe goes over the history of how scaffolding was added to ModelGlue, as well as clearing up some misunderstandings about it. The XML for the scaffolding is written at compile time based on a collection of generator files. In the ScaffoldingConfig.xml file you wan define the ModelGlue XML that is created when a scaffold is run, as well as the different events that should be created and the views that to generate. One advantage of this model for scaffolding is that even if you’re using scaffolding you can add in your own methods, such as broadcasting messages to verify a user has permissions. Extending Model-Glue Joe goes over the example of wanting to delete objects without actually deleting them. For instance if you’re using the ModelGlue.GenericDelete methods in ModelGlue and decide you want to instead set an “IsDeleted” column to 1 in a database instead of removing the row. Instead of going into the code here, you can read Doug Hughes article on Extending Model-Glue via Coldspring.