The Trillionth Blog

Tenders

Posted in family by monty on January 21, 2009

Yesterday, we were driving in the car and Z said “My tenders are bugging me” as he fixed his groin area..  then he burst out laughing.  We all started laughing and asked him where he heard that.  Apparently a kid in his class calls his groin tenders.  Kids are funny.

Load Balancing Squeak

Posted in Smalltalk, geek by monty on January 15, 2009

This week I tried to follow the tips that Ramon gave out on his blog to load balance Squeak images behind Apache:

http://onsmalltalk.com/scaling-seaside-more-advanced-load-balancing-and-publishing

I had some problems getting it to work.  I tried everything I could think of and then finally contacted Ramon.  We chatted and in a few minutes I had everything working great.  I didn’t understand that his image launcher script should stay up once Apache launches it.  Once I got that.. everything fell into place.  

Now I am using his scheme at:

http://www.w6talent.com

Thanks Ramon for your blog post and your help!  As you can see his blog OnSmalltalk is now on my blog roll (list of links on my blog).

W6 Night Out

Posted in business, entertainment by monty on January 15, 2009

On Tuesday I went to eat at the Paladar restaurant in Woodmere.  It was fantastic.  The food was so damn good.  I nearly ate  myself sick.  We were having a night out with just the 3 W6 partners.  We are starting to add talent to the w6talent.com site now.  We just hung out and ate and chilled.  Good times.

Fun Saturday Night

Posted in entertainment, friends by monty on January 15, 2009

Last Saturday (4 days ago.. man time is just flying by) we had Bret and Mollie over to hang out.  They brought their Wii to play with and the kids loved that.  We played shut the box (D won twice), Monopoly (Mollie won) and Boggle (D won without it even being close).  It was a fun evening.

Http Smalltalk Server Pages

Posted in Smalltalk, geek by monty on January 9, 2009

I just posted the framework and example app to SqueakSource.com:

http://www.squeaksource.com/HttpSsp.html

I wrote some quick documentation on the wiki page.  Please let me know if you try it out.

Squeak Seaside Comanche VPS

Posted in geek by monty on January 6, 2009

I just wanted to give credit to the VPS hosting provider that I am using for my Squeak website.  I mentioned in on my blog earlier.  These guys have been great so far.  They fixed my mail server when I screwed it up.  They helped me get my vnc up and running when I had problems.  They have had the best support of any web hosting provider I have ever used (and I’ve used a bunch).  They are Fluid Hosting or Fluid VPS.

Skinny Smalltalk Server Pages In Squeak / Comanche

Posted in Smalltalk, geek by monty on January 5, 2009

I just built a skinny Smalltalk server pages framework in Squeak running behind Comanche to run the w6talent.com website.  

Architecture Overview

The site runs on a linux VPS.  It sits behind Apache and lets Apache serve up static files (css,  js,  images, etc).  Apache redirects requests to Comanche running in Squeak.  Apache only does the redirect when it doesn’t find a matching file on the filesystem:

RewriteCond /Squeak/%{REQUEST_URI} !-f

Thanks to Ramon Leon for all of his posts on the topics of Apache, proxying, loadbalancing and such for Seaside over at onsmalltalk.com

Inside Squeak

The framework is very simple.  It uses Comanche as the web server so hooking into Comanche was easy:

MyApplication>>start

| ma |
HttpService allInstances do: [:e | e unregister].
ma := ModuleAssembly core.
ma trackSessions.
ma sessionTimeout: 20.	"Sets the session timeout in minutes"
ma addPlug: [ :request | self handleRequest: request ].
self httpService: (HttpService startOn: 8080 named: 'MyApplication').
self httpService plug: ma rootModule.
self httpService setVerboseMode.

Now whenever a request comes in MyApplication>>handleRequest: gets called.  From here on I can do whatever I want.  

Smalltalk Server Pages

This framework is very similar to the one I created for wikiweb.com when I build that application years ago.  Back then there was no Comanche in Squeak so I wrote my own http server in VisualAge Smalltalk and build a smalltalk server pages framework.

In Squeak, I created a hierarchy of classes (MySspPage) that represents Smaltalk server pages.  Each page has a class side method #filename that returns the filename of the ssp file on disk.  Each file can contain code within tags:

<? self  renderSomething ?>  

When a page gets served up the code in those embedded tags gets evaluated and the result is printed in the tag’s place.  self inside these tags is an instance of the class with the same filename (MySspPage).

So, here is how I handle requests in MyApplication>>handleRequest:

handleRequest: request
| url cls inst |
url := request url.
(url notEmpty and: [url first = $/])
	ifTrue: [url := url copyFrom: 2 to: url size].
cls := self urlsHandled at: url ifAbsent: [^nil].
inst := cls new.
inst handleRequestExternal: request.
"So redirects work"
HttpResponse current
	ifNotNil: [^HttpResponse current].
^HttpResponse fromString: inst outputStream contents

All I do is look up the right class for the requested url, create an instance of it and then forward the request to that instance via #handleRequestExternal:.   The assumption is that that method will produce html in it’s outputStream or have already created a full response set in HttpResponse>>current.  Then comanche returns the response and tada, the page content is served.

Inside the hierarchy of MyServerPage there are helpful methods like:

#warn: aString – which returns a warning page

#goToPage: aClass – which will create a new instance of a ssp page class and render it’s page or do a redirect to that pages url depending on if it is a post or get request that is being replied to

MySspPage>>handleRequest is where each page can check for actions (if a form is posted or a url action is provided).  If it finds an action it handles it can do the right thing for  that specific action.  If no action is found that it handles then it will simply render itself (by replacing all <??> tags with the evaluated result asString).

I have also made some useful helper classes like:

MyFilename (similar to the Sport SpFilename or VW’s Filename class).

MyHtmlStream (has protocol similar to the html document in Seaside for generating html.. methods like #table:with: aBlock or #paragraph: aBlock)

Database

Right now the database is just a singleton that holds everything in memory and uses the SIXX framework to xml serialize each object to disk on save (and load all from disk on app startup).  As we get more models to use the site this part will have to change to either a MySQL database or maybe a Magma object database.

Seaside No More

Posted in Smalltalk, geek by monty on January 5, 2009

Over the holidays I used my time to redesign the w6talent.com website.  It was written in Seaside but it is now written in my own smalltalk server page framework (will post more info on that later) that uses Comanche as a front end in Squeak.

 I invested a fair amount of time in Seaside so let me take a minute to explain the things I liked and disliked about it:

Likes:

  • I absolutely love being able to do something like self confirm: while handling a request for something else.. This makes your code so much like normal Smalltalk code.
  • I absolutely love being able to work at the object level and associate blocks with certain actions on a web page.. so when save is clicked on a form you can just execute your block of code and not think about how it happened
  • I like that the framework has pretty good session management
  • I like that building stuff is pretty fast

Dislikes

  • It is a framework that makes some things very easy but other things harder
  • I hate what you have to do to have static urls
  • I like thinking of web pages as pages.. not forms on forms on forms.. It took me a while to get used to it but when I finally got used to it.. I still didn’t like it.  I really just want web pages to be pages
  • Session timeouts seems more abrupt than they would for an application that worked off of meaningful GET request urls that contain info about the information you are trying to get

So,   I stopped using Seaside but I get why some people love it.