A Bit On Seaside Configuration
For a full explanation of Seaside’s configuration abilities, see David Shaffer’s configuration tutorial, but for a quick simple explanation, here’s what I do.
Subclass WASystemConfiguration and add an attributes accessor to return an array of attributes, and define hard coded accessors for any defaults you’d like to set.
bookingHost
^'http://someRandomUrl'
fooWebServiceOn
^true
myClasses
^MyCustomClass allSubclasses
attributes
^{
(WAStringAttribute key: #bookingHost group: #servers).
(WABooleanAttribute key: #fooWebServiceOn group: #webServices).
(WAListAttribute key: #fooFrameworkWebServiceUrl group: #webServices;
options: self myClasses;
yourself).
(WANumberAttribute key: #barWebServiceUrl group: #webServices).
(WAStringAttribute key: #googleMapKey group: #thirdPartyServices).
(WAPasswordAttribute key: #serviceUserPassword group: #webServices)
}
That’s pretty much it, it’s simpler than the tutorials make it out to be for what you’ll be using most of the time. From any component you can access those values with a simple
self preferenceAt: #bookingHost
I doubt for most work you’ll ever need to know anything more than this. You can, when necessary, subclass WAConfigurationAttribute and create your own field types, when necessary, but it’s rare to need to do so.
at: "Simple File Based Application Configuration";
at: "Seaside and Smalltalk Interest Spreading";
at: "Turtles All the Way Down";
Thanks for this. I didn’t even realize that I could do this sort of thing with Seaside.
Thanks for providing this, Ramon.
I think it’s great that you provide these quick and illustrative examples for doing things in Seaside.
Keep up the good work, man.
PS: Not being very familiar with Squeak, I was at first puzzled by the #{} Squeak syntax for arrays in WASystemConfiguration>>attributes, but now that I see it, I think it’s a very good extension of Smalltalk. It solves several problems in the usual #() array initialization code.
Thanks, I prefer terseness myself, I figure so must plenty of others.
[...] A Bit On Seaside Configuration | A Squeak, Smalltalk, Seaside, Object Oriented Programming and Web Development Blog (tags: seaside) [...]
[...] I have used the code I got from Ramon Leon for my seaside application generator. I have extracted a createWelcomeMessageOn method, in which I will put some simple what to do next instructions. Next I want to automatically create a simple folder structure on the file system to hold the style sheets and implement the rest of the convention over configuration paradigm into the script. I am still looking for the standard conventions in seaside though. Just like in rails I want to have unittest classes and a fixture setup automatically created with my models. [...]