Puakma: Under the hood

I'm Brendon Upson, jack-of-all-trades, master of one or two. I'm talking about life running a small ISV tackling business issues and leaping technology hurdles in a single bound.

webWise Network Consultants is based in Sydney, Australia and develops the groundbreaking Tornado Server technology.


Filed under: by Brendon Upson on 2006-09-29

We have set up a pod on www.podmatcher.com for those interested in Tornado development. We will meet online at 9pm each Tuesday (Sydney time) to discuss all things Tornado. This is your chance to talk directly to other Tornado developers and get some direct answers to any questions you may have. Registration is free, so even if you're only vaguely interested there's some great developers involved who I am sure will pass on a pearl or two of wisdom!

Further to this, I was looking at using skype as the conversation meduim (which will we will probably do for the first chat). Unfortunately there are some serious logistical issues when using skype in an "organised" multi user chat, eg someone needs to know all the skype ids to conference everyone in - and everyone needs skype. So, in order to solve this going forward I have been working on an ajax chat ap. This will hopefully be soon integrated into podmatcher and it will be a case of going to podmatcher, logging in and clicking on the link to open the chat.

Next time I'll talk about the mechanics of how a browser-based chat system works. 

UPDATE: Thanks Marcin! Here's the link to a "skypecast" https://skypecasts.skype.com/skypecasts/skypecast/detailed.html?id_talk=39727  

Tornado is not just CRUD

Filed under: by Brendon Upson on 2006-09-19

For a long time now there has been various debates about the amount of "effort" required to build a web app in the different frameworks/languages. It has only been in the last couple of weeks that I am beginning to understand the real power of Tornado. Sure, we've been saying for *ages* it's perfect for complex, database driven web apps - but what does that mean?

Ruby this, ruby that is all we seem to hear these days. But Ruby (on rails) is all about CRUD . Create, Read, Update, Delete. All projects seem to start out like this and on the surface all you need is a framework to manipulate the data in the database. All those whizz bang demos show Ruby is brilliant at this. The reality is somewhat different. Everything we have built with Tornado to date has started out fairly simply then the clients have asked for more and more. The biggest area of complexity is security. Clients always want to lock down who can see and do what with a particular ROW in a database. To do this, the framework needs to be able to access the data and the decide on a complex set of business rules if the current user should be able to CRUD the record and even hide certain parts of the data from the user.

A recent project is for forecasting costs of construction jobs (eg bridges, roads etc worth millions of dollars). The security is simple and complex. A certain group of people can create new jobs in the system and assign project managers. Those project managers can update only their projects. Area managers can view and update jobs in their area. Management can view reports for all jobs but not change any data. A plain role based security model would just be unweildly for this project. We'd need a new role for every job and with (over time) hundred of jobs in the system, very complicated to administer. Instead the framework looks at the data and decides if the current user should have access or not.

CRUD is fine, but if you are developing web apps that are true applications (rather than a simplified way of CRUDing data) Tornado is certainly worth a look. 

Making pages on the fly

Filed under: by Brendon Upson on 2006-09-05

From time to time web programmers need to make parts of pages, particularly in this ajaxian age we are now in. Today's task was: On a page, allow a user to search through an LDAP directory (Microsoft ActiveDirectory) to select user names. Since AD could hold thousands of users and we would have to troll through their X500 Names in the list, eg "CN=Brendon Upson/CN=Users/DC=wnc/DC=net/DC=au", just providing a combo box of names was not so good.

The solution was a text field to type a partial name in, some ajax code to call some server-side logic to perform the search, then insert the names into a combo box. I really didn't want to code my own combo box manually - it's possible but a pain - I have better things to do. So instead I use some inbuilt Tornado to do the heavy lifting for me:

String sSlashNames[] = doLDAPSearch();
String sList = "<P@List name="UserName" style="width: 600px;" @P>";        
HTMLDocumentItem hdi = new HTMLDocumentItem(ActionDocument, sList);        
ActionDocument.setItemChoices("UserName", sSlashNames);

In this way I can use a standard Tornado p-tag and just set the values which are stored as a String array (sList). The last call to write(); sends the html code for the combo box back to the browser. The best part (better than if I had coded it by hand!) is that if the client decides tomorrow they'd rather see a row of checkboxes, I just change "<P@List" to "<P@Checkbox".

"Bollocks!" I hear you say. "I bet querying AD is a killer pile of code". Not any more. The new LDAPQuery object (in the puakma.util package) makes it very easy:

LDAPQuery ldap = new LDAPQuery(sURL, sSearchBase, sBindMethod, sUserName, sPassword);
String sNames[] = ldap.makeChoicesArray(sQuery, new String[]{"distinguishedName"}, null);

2 lines of code :-) Tornado rocks!