Creating a WordPress Plugin

It wasn’t planned that way, but it turned out that I had to write a WordPress plugin myself to solve a problem. I want to have a Google Web Toolkit application run inside my blog. No big deal, but I couldn’t accomplish one tiny detail. GWT applications need a meta tag with the name gwt:module in the page header section. How do I manage to get this meta tag up there whenever a post includes a GWT application?

First, I looked for help where all the WordPress plugins/meta are listed. None of them seems to solve my problem. To be honest, I only looked at a few, so I really don’t know if I’ve overlooked the one I need. One Meta plugin came quite close to what I want, but it was for description and keywords only. Except that, it would have been perfect. So I took its idea and modified it.

You have to use WordPress’ custom fields for storing the gwt:module meta tags. Just create a new custom field when you create or edit a post. The key should be set to gwt:module, and the value should be the path and name of your GWT module. The plugin then collects all gwt:module meta tags for all posts on the page and puts them in the header section of the page.

Creating a custom field for a GWT-module

In case you want to use this plugin yourself, you can download the WordPress plugin for creating gwt:module meta tags from this web site.

Later today, I will write a post that actually has a GWT application included.

Comments (1)

Programming editors

Everybody who is programming is using one or more of them. My favorite programming editor is Epsilon from Lugaru Software Ltd., and that since 1996. It’s around since 1984. Although my first version was for DOS, Windows, and OS/2, I used it primarily under DOS for writing C programs. I started in 1978 with a BASIC dialect and 8080/Z80 assembler on a SORD M200 computer. I wasn’t thinking about what editor to use back then, because there was no choice. I had to use the one that came with this SORD computer. A little later I switched to C and then C++, followed by Java in 1996. There will be something after Java, but I can’t see it yet. It’s not so much the programming language itself that keeps me, but the Java platform.

Screenshot from Epsilon editor under Windows

Epsilon is an Emacs clone, but unlike Emacs, which can be extended with Lisp code, Epsilon uses a C-like language called EEL (Epsilon extension language). As you can see from the list of programming languages I’m sufficient familiar with, Lisp isn’t on it, but C is. Although this short enumeration of programming languages isn’t complete, I haven’t used any of the others for a substantial amount of time. It’s important for me, that Epsilon is programmable in a language I’m fluent in.

There’s one exception to my otherwise consistent use of Epsilon. When it comes to Java programming, I’m using Eclipse most of the time. Not always, because some things I still do with Epsilon, but most of the things are a little easier within Eclipse.

During the time I worked with Epsilon, I observed a strange thing: some programmers (even brilliant ones) worked with editors that are not supporting them well with their work. Even when shown alternative editors that would support them much more, they gave up early on learning the features of the new tool. Instead, they spend hours writing some small utility programs for tasks that are possible within minutes for editors like Epsilon. Instead of investing the time in learning a new tool, they spend much more time with fixing the shortcomings of the editors they were used to.

Don’t get me wrong, Epsilon is not a panacea for everything, and I’m gone the minute I find something better. But in the past 10 years, I haven’t.

Comments

Problem with Oracle

While operating synformation together with an Oracle database (prior to version 10g), the following error can occur during page compilation:

FATAL ERROR IN TWO-TASK SERVER: error = 12571
ksedmp: internal or fatal error

This error is logged by Oracle in the user dump trace files. After this error has occurred, no more pages can be compiled. From the ACU client software, it looks like the system is locked up. Only a restart of the synformation server software will help temporarily.

Page compilation within synformation is triggered by altering a block or a page template. The error can be easily reproduced by first altering a page template or a global block, directly followed by altering a local block. This almost always has the consequence that the ACU client software locks up. It’s not possible to compile pages from other ACU clients after this error has occurred. The error can be forced also by changing global and local blocks from different ACU clients.

Since such an error hasn’t been observed on other databases, I assume that it’s a problem only for Oracle databases prior to version 10g. Apparently, the error can be prevented if a certain foreign key is dropped. I recommend that everyone who runs synformation on an Oracle database prior to 10g deletes this key. Executing the following statement will fix the problem:

ALTER TABLE "SYN_PAGE_SECTIONS"
DROP CONSTRAINT "FK_PAGE_SECTIONS_BLOCK_ID" CASCADE;

Deleting this key has no side effects on the operation of the system.

I know that error 12571 hints to a network timeout. It seems strange that dropping a foreign key constraint fixes the problem, but I’ve tried hard to find a fix that feels more logical. Everything else I tried did not fix the problem. I’m not really satisfied with the solution, in part because synformation has a heavily normalised data model, and this fix breaks the beauty. I guess I’ve to live with that. Maybe someone else knows something to ease my pain?

Comments

If something goes wrong

When you build a software system, something can go wrong. You have to plan for that. It can be a programming error, an operator error, or a situation you haven’t planned for. I’m pretty sure you have seen web pages giving you cryptic error messages, thus indicating that something went wrong. In many cases, the given error message is useful for a programmer, but seldom for the average web user.

Fatal error:
Call to undefined function: some_function() in
/srv/domain.com/httpdocs/content/mytheme/header.php
on line 42

As a web user, what does this error message tell you? Maybe you can understand it. But can you do something about it? You can’t fix it, you’re left alone on finding your way out, it’s not helping you. Why then show it to you at all? The reason is, it wasn’t intended for you to see it. This error message is only useful for the developer. But he hasn’t planned for exactly this type of situation. Okay, it’s a programming error. But that you have to see this error in a form like this is lack of planning for this type of situation. Everybody knows or can understand that it’s not a good idea to have a web user look at a web page indicating an error like the one I showed you. But it’s still what happens in many cases. Why? Is it laziness on behalf of the developers, lack of good test cases, lack of imagination, lack of time or budget, or not enough knowledge? I think it’s a little of everything. The book Defensive Design for the Web from 37signals might tell you nothing a web developer should know already, but it contains a nice check list at the end to make sure he doesn’t forget to apply his knowledge.

To assist the developer in handling all not handled situations, synformation provides the mechanism of an error page that is called via forward() whenever a not handled error occurs. This error page is a normal synformation page with one exception: within the logic of the error page, you have access to an error object that holds all the information about the error. If you don’t define an error page within synformation, you’ll get something like the cryptic error shown above. It’s worse actually, because it might contain a Java stack trace because synformation runs on the Java platform.

I can only think of one reason to display a technical error message within the web page: the page is produced for the developer or tester. In all other cases, the user should see something more friendly, something that gives him some information on what to do next. He should not leave our web site in frustration. That’s why a typical synformation error page should contain logic like this:

<%%
$variable = getVariable("error");
if (null != $variable) {
    $msg = $error.toString();
    print S("X-ERROR-ERRORPAGE");
    // There's no need to send an email when an ACU can see the error
    if (isDevelopment() || getCurrentUser().isMemberOf("ACU")) {
%>
<div id="infobox" class="infobox-info">
<h1><%%= R("ERROR-PAGE-HEADING") %></h1>
<p><%%= $msg %></p>
</div>
<%%
    } else {
        print S("X-INFO-WHAT-NEXT");
        sendMail(R("ADDRESS"), R("SUBJECT"), R("TEXT") + $msg);
    }
} else {
    print S("PAGE-NOT-CALLABLE");
}
%>

I will explain this code snippet. First, we have to find out if an error object actually exists. If it does, the users gets a friendly hint in his language that an unexpected error has occurred and we’re really sorry about that. If we are in development mode, or the user has logged in and he is a developer, the actual error message is displayed, too. If we have a normal web user, a text with options on what to do next is presented. An email is then sent off to the development team with all the technical information needed to reproduce and fix the error. In case no error object exists, this page was called without having an error. Maybe somebody typed in the URL in his browser. We tell him in friendly language, that this page is not intended to be used like that. We can also display some information on what to do next - he is already on our page, so why not keep him.

We all know that things can go wrong. But we should all care more for having an actual plan installed, if that happens. I’m not perfect in this regard either, so this post might help me as a reminder.

Comments

A night at Frankfurt airport

Yesterday, I received a phone call from someone who asked me to meet aircraft N279WA in Frankfurt on a cargo mission. It came from Chicago and went back to Atlanta. This aircraft has been converted to a cargo plane only recently. And it has a new livery now.

Aircraft N279WA during push back from position F215

Before, it was a passenger aircraft. I knew it mostly from Air Mobility Command missions. On several occasions, I flew with it from the now defunct Rhein-Main AFB to Al Udeid AFB in Qatar. Most flights went thru Bahrain airport, because the commercial air carriers need a place to change crews and get catering. This is difficult to accomplish on some Air Force Bases, but certainly in Al Udeid. The AMC missions are still going on, but without this aircraft.

Empty main deck

While I was there, I took some pictures, one from the main deck after unloading of the inbound cargo. The main deck alone on this MD-11 can hold more than 150,000 lbs of cargo. Loading teams in Frankfurt regularly load an entire MD-11 cargo aircraft in 45 to 60 minutes.

Me in the cockpit

Here you can see a portion of the N279WA cockpit from that night, with me in the captains seat. Although I know how to read and use some of the instruments, I can barely fly an aircraft with Microsoft’s Flight Simulator. But then, this isn’t my job.

Comments (2)

« Previous entries · Next entries »