Metacello - advanced conditional elements

0 views
Skip to first unread message

Dale Henrichs

unread,
May 27, 2009, 3:22:44 PM5/27/09
to montice...@googlegroups.com
It seems that I do my best thinking in the shower...

This morning in the shower, I started thinking about how pier would be handled in Metacello. The interesting bit for pier is that it hasn't been ported to Seaside2.9 yet and when it is ported to Seaside2.9, it is likely that there will be 2.8 and 2.9 specific packages.

If someone is interested in loading, say, Pier '1.2', the code that is loaded will differ depending upon whether seaside2.8 or seaside2.9 is loaded and if no seaside is loaded, a (version specific) dependency must be created on either 2.8 or 2.9...

For the sake of discussion, lets just say that Pier-Model-lr.323 is to be loaded if seaside2.8 is already installed and Pier-Model.29-lr.324 is to be loaded if seaside2.9 is already installed and if Seaside is not installed, then Seaside2.8 will be installed by default (since right now seaisde2.9 is in alpha).

So the #platformAttributes for PRVersionMap would look something like:

platformAttributes

| att |
att := super platformAttributes asOrderedCollection.
self seaside29Installed
ifTrue: [ att add: #seaside29 ]
ifFalse: [
self seaside28Installed
ifTrue: [ att add: #seaside28 ]
ifFalse: [
att add: #seaside28. "the default"
att add: #noSeaside ]].
^att

In other words, if seaside29 is installed, the attribute list will include just #seaside29. If seaside29 is not installed, then the attribute list will include #seaside28 (the default seaside) and if seaside28 isn't installed, the attribute list will also include #noSeaside, which will cause a dependency for Seaside to be included.

Ignoring the common packages and groups that might be associated with Pier the following methods would be used to complement the attribute list:

packages120ss29
<packageVersions: '1.2' attributes: #seaside29>

^(MetacelloPackagesSpec for: self)
addPackage: 'Pier-Model' file: 'Pier-Model.29-lr.324';
addRepository: 'http://source.lukas-renggli.ch/pier' type: 'http';
yourself

packages120ss28
<packageVersions: '1.2' attributes: #seaside28>

^(MetacelloPackagesSpec for: self)
addPackage: 'Pier-Model' file: 'Pier-Model.lr.323';
addRepository: 'http://source.lukas-renggli.ch/pier' type: 'http';
yourself

groups120noSS
<groups: '1.2' attribute: #noSeaside >

^(MetacelloGroupsSpec for: self)
addFeature:
((MetacelloGroupSpec for: self)
groupName: 'core'
description: '';
addMember:
((MetacelloVersionMapSpec for: self)
versionMapClass: 'WAVersionMap';
version: '2.8.3';
loadList: #();
packagesSpec:
((MetacelloPackagesSpec new)
addFile: 'Seaside-VersionMap-dkh.7';
addRepository: 'http://seaside.gemstone.com/ss/test';
yourself);
yourself

I have to say that I am liking the use of attributes for handling conditional elements...especially the ability to conditionally include a dependency ...

A particular project can be very specific about analyzing the state of the existing image and load the correct code....

Dale

Reply all
Reply to author
Forward
0 new messages