Dale: let me know when you write this in the tutorial so that I can add something similar to the PBE chapter :) Thanks Mariano |
Mariano,
Sorry, they've been published ... GemTools is an example of conditionally loading OB if it is not present. Seaside30 has an example of loading extra packages if OB _is_ present. Dale ----- "Mariano Martinez Peck" <[hidden email]> wrote: | > | > I will try to put this up as a FAQ or include it in the tutorial. | > | > ConfigurationOfGemTools and ConfigurationOfSeaside30 will include | > working examples, but I am not quite ready to publish them in | > MetacelloRepository. | > | > | Dale: let me know when you write this in the tutorial so that I can | add | something similar to the PBE chapter :) | | Thanks | | Mariano |
Dale...is this thing of "Conditional loading" documented somewhere? I did a quick search in website and tutorial but without success.
Thanks in advance, Mariano On Mon, Feb 15, 2010 at 7:18 PM, Dale Henrichs <[hidden email]> wrote: Mariano, |
Mariano,
No I guess I haven't put anything up on the website ... presumably we coudl put up a FAQ: Here's a recent sample of doing conditional loading (in this case based upon a specific GemStone version): project ^ project ifNil: [ | projectAttributes gsVersion | "Bootstrap Metacello if it is not already loaded" self class ensureMetacello. "Construct Metacello project" project := (Smalltalk at: #MetacelloMCProject) new. projectAttributes := #(). ((gsVersion := System stoneVersionAt: 'gsVersion') beginsWith: '2.4') ifTrue: [ "needed to isolate the fix for Issue 129. The fix is needed for versions 2.4.4.1 and earlier" ((MetacelloVersionNumber fromString: gsVersion) < (MetacelloVersionNumber fromString: '2.4.4.2')) ifTrue: [ projectAttributes := #(#'gs2.4.4.1') ]]. project projectAttributes: projectAttributes. (Smalltalk at: #MetacelloVersionConstructor) on: self project: project. project] Versions and baselines can then use the #'gs2.4.4.1' attribute for conditionally loading code... Dale Mariano Martinez Peck wrote: > Dale...is this thing of "Conditional loading" documented somewhere? I > did a quick search in website and tutorial but without success. > > Thanks in advance, > > Mariano > > On Mon, Feb 15, 2010 at 7:18 PM, Dale Henrichs > <[hidden email] <mailto:[hidden email]>> wrote: > > Mariano, > > Sorry, they've been published ... GemTools is an example of > conditionally loading OB if it is not present. Seaside30 has an > example of loading extra packages if OB _is_ present. > > Dale > ----- "Mariano Martinez Peck" <[hidden email] > <mailto:[hidden email]>> wrote: > > | > > | > I will try to put this up as a FAQ or include it in the tutorial. > | > > | > ConfigurationOfGemTools and ConfigurationOfSeaside30 will include > | > working examples, but I am not quite ready to publish them in > | > MetacelloRepository. > | > > | > > | Dale: let me know when you write this in the tutorial so that I can > | add > | something similar to the PBE chapter :) > | > | Thanks > | > | Mariano > > |
Administrator
|
I tried to adapt the above to the latest #project template, but my custom attribute doesn't seem to get called. My #project looks like: ^ project ifNil: [ | constructor | "Bootstrap Metacello if it is not already loaded" (self class baseConfigurationClassIfAbsent: []) ensureMetacello. "Construct Metacello project" constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self. project := constructor project. isOmniBrowserLoaded := self class environment includesKey: #OBCodeBrowser. isOmniBrowserLoaded ifTrue: [ project projectAttributes: #(#'OB') ]. project loadType: #linear. "change to #atomic if desired" project ] The projectAttributes are set to #(#OB). And in my baseline, I have: spec for: #'OB' do: [ self halt.spec group: 'default' with: #('DeNigrisSetup-OB' ) ]. But "ConfigurationOfDeNigrisSetup project bleedingEdge record" shows: (linear load : linear load : 1.0-baseline [ConfigurationOfDeNigrisSetup] load : DeNigrisSetup-Core load : DeNigrisSetup-Pharo13) Thanks.
Cheers,
Sean |
Sean,
Try this version of #project: project ^ project ifNil: [ | constructor isOmniBrowserLoaded | self class ensureMetacello. project := MetacelloMCProject new. isOmniBrowserLoaded := self class environment includesKey: #OBCodeBrowser. isOmniBrowserLoaded ifTrue: [ project projectAttributes: #(#'OB') ]. MetacelloVersionConstructor on: self project: project. project ] The technicality (with the current API) is that when you define your own project attributes, you must _defer_ the creation of the project until you have defined the project attributes. Dale ----- Original Message ----- | From: "Sean P. DeNigris" <[hidden email]> | To: [hidden email] | Sent: Thursday, December 8, 2011 3:49:16 PM | Subject: [Metacello] Re: Conditional loading for OB examples | | | Dale Henrichs wrote | > | > Versions and baselines can then use the #'gs2.4.4.1' attribute for | > conditionally loading code... | > | | I tried to adapt the above to the latest #project template, but my | custom | attribute doesn't seem to get called. | | My #project looks like: | ^ project ifNil: [ | constructor | | "Bootstrap Metacello if it is not already loaded" | (self class baseConfigurationClassIfAbsent: []) ensureMetacello. | "Construct Metacello project" | constructor := (Smalltalk at: #MetacelloVersionConstructor) on: | self. | project := constructor project. | isOmniBrowserLoaded := self class environment includesKey: | #OBCodeBrowser. | isOmniBrowserLoaded ifTrue: [ project projectAttributes: #(#'OB') | ]. | project loadType: #linear. "change to #atomic if desired" | project ] | | The projectAttributes are set to #(#OB). | | And in my baseline, I have: | spec for: #'OB' do: [ self halt.spec group: 'default' with: | #('DeNigrisSetup-OB' ) ]. | | But "ConfigurationOfDeNigrisSetup project bleedingEdge record" shows: | (linear load : | linear load : 1.0-baseline [ConfigurationOfDeNigrisSetup] | load : DeNigrisSetup-Core | load : DeNigrisSetup-Pharo13) | | Thanks. | | -- | View this message in context: | http://forum.world.st/Re-Conditional-loading-for-OB-examples-tp1555203p4174833.html | Sent from the Metacello mailing list archive at Nabble.com. | |
Sean, do you think the chapter deserves an update with this issue?
On Fri, Dec 9, 2011 at 7:30 PM, Dale Henrichs <[hidden email]> wrote: Sean, -- Mariano http://marianopeck.wordpress.com |
On Dec 14, 3:52 pm, Mariano Martinez Peck <[hidden email]>
wrote: > Sean, do you think the chapter deserves an update with this issue? It definitely would've helped me, but you guys would know better about the common use cases. I seem to always end up in the dark corners, lol. Dale, would it be worth it to have the template create: ConfigurationOfMyProject>>project project ifNil: [ | constructor | "Bootstrap Metacello if it is not already loaded" (self class baseConfigurationClassIfAbsent: []) ensureMetacello. "Construct Metacello project" project := MetacelloMCProject new projectAttributes: self customProjectAttributes ]. constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self project: project. project loadType: #linear. "change to #atomic if desired" project ] ConfigurationOfMyProject>>customProjectAttributes "Edit to return any custom attributes e.g. for conditional loading" ^ #(). |
> ConfigurationOfMyProject>>customProjectAttributes
> "Edit to return any custom attributes e.g. for conditional loading" > > ^ #(). And maybe make the comment something like: "Edit to return a collection of any custom attributes e.g. for conditional loading: Array with: #'Condition1' with: #'Condition2" |
In reply to this post by Sean DeNigris
Sean,
Excellent suggestion! Dale ----- Original Message ----- | From: "Sean DeNigris" <[hidden email]> | To: "Metacello" <[hidden email]> | Sent: Thursday, December 22, 2011 3:00:21 PM | Subject: [Metacello] Re: Conditional loading for OB examples | | On Dec 14, 3:52 pm, Mariano Martinez Peck <[hidden email]> | wrote: | > Sean, do you think the chapter deserves an update with this issue? | | It definitely would've helped me, but you guys would know better | about | the common use cases. I seem to always end up in the dark corners, | lol. | | Dale, would it be worth it to have the template create: | ConfigurationOfMyProject>>project | | project ifNil: [ | constructor | | "Bootstrap Metacello if it is not already loaded" | (self class baseConfigurationClassIfAbsent: []) ensureMetacello. | "Construct Metacello project" | project := MetacelloMCProject new projectAttributes: self | customProjectAttributes ]. | constructor := (Smalltalk at: #MetacelloVersionConstructor) on: | self | project: project. | project loadType: #linear. "change to #atomic if desired" | project ] | | ConfigurationOfMyProject>>customProjectAttributes | "Edit to return any custom attributes e.g. for conditional loading" | | ^ #(). | |
Free forum by Nabble | Edit this page |