Hello!
I wanted to ask how is possible to set a bundle to load the latest version of a prerequisite bundle without the version selection prompt. I know I can set a particular version number, but that means that every time I update my prerequisite bundle I have to re-set that number. I also saw that I can set the option from the store settings (settings -> store -> prerequisites), but I don't know if the users have that option checked. Is it possible for me to set it in my bundle? Thank you very much. Vanessa. |
You could possibly change the Store setting while loading your bundle,
but I would argue against it. The settings “belong” to the image owner, not you as the developer of a component. You could also include the bundle you (used to) prerequisite in your own bundle. This might, however, be wrong or feel unnatural. You might want to look at the versionSelectionBlock on packages/bundle. It is found in the “Properties” tab for bundles/packages. The "Prerequisite Version Selection" is a block where you can answer whether a candidate version for a parcel matches your prerequisite. I am unsure if it works for packages/bundles. Read “Source Code Management Guide” more details. Please reply here if you get it working. Note that this functionality had a bug in VisualWorks 7.3 and 7.3.1. Runar Jordahl blog.epigent.com _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Dear Vanessa and Runar,
>The "Prerequisite Version Selection" is a block >where you can answer whether a candidate version for a parcel matches >your prerequisite. > Runar, I suspect setting a prereq block will not alone do what Vanessa wishes because the block will be applied only _after_ the standard policy presents a list of versions and asks her to provide one. In other words, this will only accept or reject a version she chooses, it will not suppress the dialog which shows her all versions and asks her to choose one. Tio suppress the dialog, she must subclass BasicPrerequisitePolicy so that #getPrereq:from:version:for: applies the block to its fromList (which is in latest to earliest order so a detect: will work in her case). For example 1) Set an action block as Runar suggests, e.g. [:parcelOrPundleName :actualVersion :versionFilter | versionFilter isEmpty or: [versionFilter = actualVersion] This returns true whenever no actual version has been requested. Note that this will treat any already loaded item or any loadable parcel visible on the parcel path as acceptable. 2) Subclass BasicPrerequisitePolicy to e.g. LatestPrerequisitePolicy and override BasicPrerequisitePolicy>>getPrereq:from:version:for: e.g. LatestPrerequisitePolicy>>getPrereq: reqName from: pundleList version: reqVersion for: aPundle | actionBlock | actionBlock := CodeComponent asActionBlock: aPundle versionSelectionBlock. ^actionBlock isNil ifTrue: [super getPrereq: reqName from: pundleList version: reqVersion for: aPundle] ifFalse: [pundleList detect: [:eachPundle | (self isSatisfiedBy: eachPundle) and: [actionBlock value: reqName value: eachPundle version value: reqVersion]] ifNone: [super getPrereq: reqName from: pundleList version: reqVersion for: aPundle]] 3) Set it in your image Store.Policies prerequisitePolicy: LatestPrerequisitePolicy new I find this cluncky - anyone know a better way - but if I'm fed up clicking a lot of load-latest prereqs for some not-yet-parcelled project I'm working on, it seems to work. HTH Niall Ross _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Dear Niall and Runar,
Thank you very much for your answers. I tried Niall version of the solution and everything worked perfect. A few comments: - I did all the process (the three steps Niall wrote) of adding this LatestPrerequisitePolicy class and setting it as the Store.Policies prerequisitePolicy in the pre-read block of the bundle and then in the post-load I put everything back to normal. Is it somehow normal to load classes like this? I also moved it to the Spy bundle after the bundle is loaded. I find this a bit weird as I'm not sure this post-load block will be always executed. Does this happen? I think I'll have to put this class in a separate package any ways, but I'm still a bit worried for this class to be the Store.Policies prerequisitePolicy. - Once everything worked OK, I tried in a 7.7 image and didn't work: it still prompt me the option of selecting the version of Roassal. Any idea of why this can be happening? Thank you very much. Vanessa. On 05/30/2012 03:41 PM, Niall Ross wrote: > Dear Vanessa and Runar, > >> The "Prerequisite Version Selection" is a block >> where you can answer whether a candidate version for a parcel matches >> your prerequisite. >> > > Runar, I suspect setting a prereq block will not alone do what Vanessa > wishes because the block will be applied only _after_ the standard > policy presents a list of versions and asks her to provide one. In > other words, this will only accept or reject a version she chooses, it > will not suppress the dialog which shows her all versions and asks her > to choose one. > > Tio suppress the dialog, she must subclass BasicPrerequisitePolicy so > that #getPrereq:from:version:for: applies the block to its fromList > (which is in latest to earliest order so a detect: will work in her > case). For example > > 1) Set an action block as Runar suggests, e.g. > > [:parcelOrPundleName :actualVersion :versionFilter | > versionFilter isEmpty or: [versionFilter = actualVersion] > > This returns true whenever no actual version has been requested. Note > that this will treat any already loaded item or any loadable parcel > visible on the parcel path as acceptable. > > 2) Subclass BasicPrerequisitePolicy to e.g. LatestPrerequisitePolicy > and override > BasicPrerequisitePolicy>>getPrereq:from:version:for: > e.g. > > LatestPrerequisitePolicy>>getPrereq: reqName from: pundleList version: > reqVersion for: aPundle > | actionBlock | > actionBlock := CodeComponent asActionBlock: aPundle > versionSelectionBlock. > ^actionBlock isNil > ifTrue: [super getPrereq: reqName from: pundleList version: > reqVersion for: aPundle] > ifFalse: > [pundleList > detect: [:eachPundle | (self isSatisfiedBy: eachPundle) > and: > [actionBlock value: reqName value: eachPundle > version value: reqVersion]] > ifNone: [super getPrereq: reqName from: pundleList > version: reqVersion for: aPundle]] > > 3) Set it in your image > Store.Policies prerequisitePolicy: LatestPrerequisitePolicy new > > I find this cluncky - anyone know a better way - but if I'm fed up > clicking a lot of load-latest prereqs for some not-yet-parcelled > project I'm working on, it seems to work. > > HTH > Niall Ross > > . > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |