Building a custom GUI to configure a template

Define a configuration file in XML

This example uses a XML configuration file that has the name <GUID>.xml where the GUID is that of the To Translator instance associated with the channel.

This is by no means the only possible choice. The configuration could be stored in a remote database for instance if you are dealing with a farm of Iguana servers.

The myconfig module provides a convenient interface to initialize and save to to this file. It’s layered over the more generic config module. This is the source to myconfig:


myconfig = {}

-- The Default configuration
local Config=[[
   sending_app='My Application' 

function myconfig.Get(ChannelGuid)
   if ChannelGuid then
      return config.Load(ChannelGuid, Config)   
   return config.File(config.TO, Config) 

You can see the module gives the default version of the configuration file.

For the web application to use this module it passes in the GUID of the Translator instance. For the channel itself the interface to obtain the configuration file is simpler. This screen shot shows it nicely:

In this context we can omit passing the GUID of the Translator instance since it picks it up automatically. By initializing the Config object outside of the main function it means we only read the configuration file once when the channel is started. This is more efficient.

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.