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.

    ^MyCustomClass allSubclasses
        (WAStringAttribute key: #bookingHost group: #servers).
        (WABooleanAttribute key: #fooWebServiceOn group: #webServices).
        (WAListAttribute key: #fooFrameworkWebServiceUrl group: #webServices; 
            options: self myClasses; 
        (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.

Comments (automatically disabled after 1 year)

Carl Gundel 3853 days ago

Thanks for this. I didn't even realize that I could do this sort of thing with Seaside.

Lidell 3850 days ago

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.

Ramon Leon 3850 days ago

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. [...]

Adi Azar 3645 days ago

Most of them about Smalltalk !?? Is it your favorite language?

Ramon Leon 3645 days ago

No, only two of them are about Smalltalk. Yes, it's my favorite language, because it's my favorite programming environment. It's what programming was meant to be.

Richard Eng 3624 days ago

There are at least ten books (maybe fifteen) about Ruby on Rails, but not a single one about Seaside. How come?

I'm trying to figure out how to use Seaside to develop a commercial website and there are no books to help me. There are several online tutorials but they are frankly too simple in their scope.

I'm almost tempted to give up Seaside/Smalltalk and turn to RoR. That would be a great shame...

Ramon Leon 3624 days ago

Seaside isn't that mainstream yet. If you aren't willing to get into the code itself and its comments, or hang out in the list asking questions and writing code, then it's not really the framework you're looking for. There are a few blogs, but most helpful is the mailing list itself. You do not however, want to make a real project your first Seaside app, you need to write some sample apps, toys, to teach you the framework.

about me|good books|popular posts|atom|rss