A tool to extract, display, and update data

BY MIKE RICHARDSON, SHAWN GORDON

Rekall is a multiplatform, database-centric RAD (Rapid Application Development) IDE (Integrated Development Environment), similar in intention to Microsoft Access or Paradox. Rekall uses the popular Python scripting language to script objects, instead of something like AccessBasic. It was originally developed by theKompany.com, but in late 2003 it was changed to a dual-license GPL and commercial, very similar to what is available with Qt from Trolltech. The commercial license allows you to create closed-source distributable applications if you want to make a product to sell, for example.

Rekall can be built as a native KDE application, or as a Qt-only application that takes away a specific desktop dependency, thereby making it available for fans of alternative desktops. It’s also available for embedded Linux like the Sharp Zaurus, Microsoft Windows, and Mac OS X using Qt. By default Rekall comes with the ability to access XBase, MySQL, and PostgreSQL. There are optional modules for IBM’s DB2 and to utilize ODBC on both Linux and Windows; more on this later.

This article shows some of Rekall’s features, how it compares with Access, and how it can be used in application development.

What Rekall Is Not

First and foremost, Rekall is not a database. Unlike Access, which uses the Jet database engine to store information, Rekall does not have a preferred database engine. Instead, it tries to be database-agnostic and provide a default database that requires as little effort as possible by the user to set up, administer, and use – this is XBase. As previously mentioned, Rekall can currently use MySQL, PostgreSQL, and IBM’s DB2; it can also access ODBC data sources (both on Linux and Windows), and XBase (DB-IV) files via a SQL interface. Rekall attempts, so far as is possible, to hide the differences between these databases.

Rekall stores the definitions of objects – forms, reports, and so forth – either in files or in the local file system. The ability to store these objects in the database server means that it is very easy to roll out centralized applications; this is described in more detail later. On the other hand, storing definitions in files allows them to be easily copied or examined; since they are all stored in XML format, it is possible to view and edit them by hand. You could even write a script that dynamically creates a form or report.

Rekall is not, primarily, a general purpose RAD tool; rather, it is aimed at applications where there is a strong relationship between the data in the database and the forms and reports that display it. However, there is enough functionality to be able to create things like dialog boxes where they are needed.

What Rekall Is

Rekall is a RAD tool where you need to access a relational database such as MySQL or PostgreSQL. As such, it provides the normal sorts of things that you’d expect to find in such tools: forms and reports, and various supporting parts such as query generators and scripting. You can write Python scripts on widget events to customize the behavior of forms and such. Rekall is able to work with either a local or remote database, making it perfect for mobile devices. The following is an example of something that would be done in Rekall.

Say you make an appointment with the car dealer to bring your car to the shop. The day you arrive the attendant is there with his wireless mobile device running a Rekall application. He enters your name, finds your appointment record, and enters all the pertinent information. This information is immediately committed to the server over the wireless network and is now available at the terminal in the service bay.

An application like this could be written in almost no time, but if you’ve ever watched the massive manual process involved in an auto dealer’s taking in a car for service, you realize what a huge time saver it would be. This is just a simple example but should get you thinking, especially since there is no computing platform out there that is in any sort of common use that Rekall cannot run on.

Reusability

One of the nice things about designing dynamic Web sites is the ability to create components that can be reused. For instance, if the site uses Python you might implement a Python class that handles a simple input field; from this, there could be a derived class that handles read-only fields that display with blue text on a grey background. This is really useful when one day the boss says, “We want blue-on-grey changed to red-on-white” (and even more useful when the boss decides that was wrong, and can it go back to blue-on-grey). All that has to be changed is the one class.

This sort of thing is typically difficult in products like Access, but from release 2.2.0 (currently in development but available and quite stable) Rekall can do this.

First, a little bit of background. In Rekall, as in Access, objects like buttons and data controls (text fields, combo-boxes, and so on) have event functions that are called when an event occurs. The events depend on the object, but, for instance, a button has an On-Click event that is called when the user clicks the button. The event function is a script, written in Python, which does something; so, for example, a Next-Record button in a form would have a script that tells Rekall to move to the next record. Although Rekall can store scripts in separate script modules, it can also store the scripts “inside” the object, so if the object is moved around then the script follows it.

Rekall, from version 2.0.0, supports the idea of components. A component may be as simple as a button that the user clicks to move to the next record but can be much more complicated, containing multiple controls and associated event scripts. These components can be pasted into a form when the user needs them. In Rekall 2.2.0 this is extended to allow components to be linked as well as pasted; if a component that is linked is changed then it changes in all the forms that link it.

When the component is linked, properties of the component can be overridden. So, for instance, a component that displays text in the default color scheme can be overridden to display as blue-on-grey; this affects only the form that links the component, and not any other form. Not only this, but event scripts that are associated with the component can be overridden. So, if the component contains a button and the button has a script that is executed when the button is clicked, the form that links the component can provide a different script to be executed on the button click. More usefully, the overriding code can call the code in the component; this is a form of the inheritance that occurs in object-oriented languages.

You can think of a component being equivalent to a class in an object-oriented language. Since one component can link to another component, Rekall provides the equivalent of derived classes. A base component might contain a field that displays a database date-time value formatted in some particular way; a derived component would make the field read-only; and a further derivation might pop up a warning message if the user enters a record where the date is prior to the year 2000.

Rolling Out Applications

Because Rekall can save all its objects in the server database, it is very easy to make an application accessible from multiple clients. A Rekall “database” file (in the sense of an Access .mdb file) is no more than the information needed to access the server database – the host and database names, users, and passwords. This file is small – a few thousand bytes at most – and formatted in XML, and can easily be distributed. Once the user has this file set up, he or she can use Rekall to access the server database and from there use the forms and reports.

If changes are made to a form or report, users will see those changes the next time they access them. This contrasts with Access, where even if tables are stored on a server, it is still necessary to distribute the .mdb file with the form and report definitions. Clearly, if a change requires a more recent version of Rekall, then that will have to be distributed and installed – so it’s not as easy as providing distributed access via the Web and a browser – but the problem is considerably eased.

Another feature of Rekall that makes distributing applications easier is the idea of virtual printers. Suppose that you implement a Rekall application that is going to be installed at several clients. Suppose that in each case there will be three printers on the network: one to print general reports and such, one to produce output onto preprinted stationery, and one to print labels. The problem is that different clients will have different physical printers, and you don’t want users to have to choose which printer to use each time they produce a report or set of labels.

Rekall handles this using the notion of virtual printers. A report can be configured to print to a particular virtual printer, which is defined within the Rekall application. The virtual printer definition specifies the physical printer and other information: page size, orientation, and so forth. You would set up three virtual printers, one for each case, and associate the appropriate printer with each report. Then, when installing at the client, it is only necessary to change each of the three virtual printer definitions to match the physical printers. The reports themselves remain unchanged, however many of them there are.

Summary

Microsoft Access has become one of the most important applications in corporate America for power users, IT analysts, and many application developers. This has been a glaring gap in the Linux landscape outside of Rekall. There are various other projects that have started and stopped, and some are still in development, but none come to the level of maturity that Rekall has after years of continuous development.

Remember, your data is only as useful as your ability to get it back out again.