Sunday, December 18, 2011

The Selection and Design of Templating in LedgerSMB 1.3

One of the key features of LedgerSMB 1.3 has been the move from the custom templating solution of LedgerSMB 1.2 (inherited from SQL-Ledger) to Template Toolkit.  This gives us more flexibility, better cross-language support since TT has been implemented for other languages as well, and the like.  However in practice in order to preserve these and avoid too close of a merging between business and presentation logic, we avoid some functions of TT, such as embedded Perl.  We also make have some specific approaches to how we invoke TT in order to avoid problems and help ensure standards compliance to the best of our ability.

The big problem that one runs into is the use of percents, which denote comments in LaTeX.  Leaving the percent signs in leads to parsing problems when testing templates.  So it became clear that since we wanted to re-use the same template logic for both UI and printed invoices the percent signs would have to go.

We settled on opening the tag with <?lsmb and closing it with ?>  The reason here is that this re-uses the SGML-standard "program instruction" tag syntax to ensure that validation can be run on the templates themselves.

A second thing we did was to add some template-specific functions.  These handle internationalization and number formatting.  Each of these has two forms:  a general form specific to the language or preferences of the template and a non-specific form, where the localization settings must be specified in the template.  This provides a consistent templating API for presentation of data, without mixing object behavior with the template layer itself.

The reason for these two forms is that there may be cases where number formatting must be specified in the template (such as when a check is printed), but there are others where user-specific settings should be used.  Similarly we want to specify a primary language with a template, but might want to translate strings into a second language (for example for bilingual receipts).

This gives us a general presentation API largely based on TT, but with differences which enable us to do whatever we need to do.  We had to rip out the old pagebreak handling and go instead to LaTeX longtables instead, which is probably a win anyway.

However one surprising use has come up, and that has been the ability to re-use the templating system in preparing database upgrade scripts which are then passed along to psql.

Saturday, December 3, 2011

MYGOSSCON Observations, and Notes on Open Source in South-East Asia

This week, I attended the Malaysian Government Open Source Software Convention (MYGOSSCON), promoting PostgreSQL and LedgerSMB to both public and private sector entities.  We had a simple booth and had approx 100 people stop by over the course of the two days.  We also talked with a wide range of other exhibitors and came away with a sense that we can expect great things in South-East Asia regarding Open Source.

It was immediately clear that PostgreSQL was a star technology at the conference, with a strong showing by EnterpriseDB and EnterpriseDB resellers.  We were the only project specializing in the "community edition" as EnterpriseDB calls it.  We had a lot of people stop by to talk about PostgreSQL and share success stories, answering questions about the differences between Oracle and PostgreSQL, between PostgreSQL and MySQL, and between EnterpriseDB and the official release version of PostgreSQL (I refuse to call it the "community version").  I was told that there would be few who knew databases, but while there were only a few database experts at the conference (which was to be expected) there were a lot of people who had a solid working knowledge of database systems generally and had lots of well-thought-out and valid questions.

Indeed people would see the other signs at our booth and keep walking... until they saw the big yellow banner with the blue, white, and black PostgreSQL logo on it and then walk right over.  We got questions that I knew the answer to, questions where my answers were slightly out of date (areas of Pg vs Oracle), and questions which I had not really prepared for at all (asking about Arabic support for PostgreSQL).  Unfortunately with the internet connections overloaded at the conference, I had to do the best I could, and promise follow-up as necessary.

One typically goes to trade shows expecting to build awareness for one's products and services with the idea that this will grow the market later.  In this case, however, we walked away with companies interested in hosting LedgerSMB, possible maintainers for other language translations, and a couple of actual, actionable sales leads.  We were extremely happy with the way things went.

However in addition to talking with civil servants and educators, an important undercurrent emerged in my discussions with purely private sector individuals (often other exhibitors):  open source is rapidly growing here in South-East Asia, particularly in the public sector.  The major limiting factor appears to be supply if individuals with relevant expertise and experience.  This is not to say that such people aren't available, but rather that demand significantly exceeds supply which is common in growing markets.  This isn't just the sorts of things we experienced first hand, caused by entities trying to reduce the amount that they spend primarily to Oracle, but instead part of a much larger trend, with governments in the region.

As I typically try to point out when advocating open source, the decision to prioritize open source isn't just about money, but rather the differences in dynamics surrounding money lead to a number of important benefits including a larger percentage of the money to launch a project going into the local economy, and the added flexibility that occurs when one does not need to worry about acquisition of software licenses in order to put data to a new use.  This leads to local power both economically and in terms of decision-making.  According to other consultants, this is not limited to the Malaysian government and other governments in the region are increasing their commitment to open source software.

All around South-East Asia, my sense is that there is a sense that open source will be a major economic asset to the region and something to be cultivated.  It is a good time to be in open source over here, but there has never been a better time (and probably never will be a better time) to be in open source databases.  PostgreSQL is, in particular, poised to start penetrating Oracle's home market, with projects like Gridsql and Postgres-xc reaching maturity.  I believe we are to the point where no corner of the market is safe any more, and where the adoption of an open source lifestyle for businesses and governments will become the norm rather than the exception.

I think that last sentence follows quite directly from open source database systems coming of age.  The large, multi-application database systems (DB2, Oracle, MS SQL, Terradata) represent the last major piece of IT infrastructure for which open source solutions were inadequate.  I say multi-application to differentiate from the "app-stack" approaches familiar to LAMP developers.  Typically here we are talking about heavily engineered databases designed to have a significant number of applications solving different issues, manipulating their data.  However, as this piece of infrastructure begins to fall to open source, then all the back-end software can be open source or in-house.  At this point, one has to ask whether one should simply bite the bullet and start migrating the front-end (desktop/laptop) devices as well.  Pushing Linux-based desktops in government and business would almost certainly have a cascading effect to consumer systems as well.

These are exciting times indeed.