Tech Notes
Tech Notes |
Using context can solve some multi-machine administration problems.
The information in this technote relates to taking advantage of the ZaphodsMap configuration system (http://www.ZaphodsMap.com) which is used by WebHub.
The global default context is used to override configuration settings on a per-machine basis. For WebHub, this is usually done for settings in the application-level config file which are forced to differ between the developer's computer and the production computer. A specific example would be: overriding the definition of AppRoot. (AppRoot is a string which is meant to be used at the beginning of static URLs, such as within an IMG tag, where on the production server the best practice is to start the URL with a / but on the development computer it might be convenient to start with the public domain name and thus avoid having dozens, or hundreds, of graphic image files on the development computer.)
In general, you should use Context in order to create one XML file for an application that will end up running on more than one machine and those machines use different directory structures. If you only have one machine, or all machines are identical, you should leave the global default context blank.
DefaultMapContext is a property of TZaphodsMap. You can set it using the ZMAdmin utility, or edit the ZMGlobal.xml file in the folder pointed to by the ZaphodsMap environment variable. Context can be any alphanumeric string. Context is case-sensitive. A ZMGlobal.xml file which sets the global default context to "demos" looks like this:
<ZMGlobalSettings>
<DefaultContext value="demos" />
<ZMGlobalSettings>
<IniCode>
<h1>Example Scenario</h1>
<ul>
<li> Machine A... at home ... does not have any logo files or other web site graphics ... context="home" </li>
<li> Machine B... at the data center ... live, production server ... public domain is www.mydomain.com ... context="live" </li>
</ul>
<h2>On Machine A</h2>
<IniCode>
<ZMGlobalSettings>
<DefaultContext value="home"/>
</ZMGlobalSettings>
<IniCode>
<h2>On Machine B:</h2>
<IniCode>
<ZMGlobalSettings>
<DefaultContext value="live"/>
</ZMGlobalSettings>
<IniCode>
<h2>Defining AppRoot</h2>
<IniCode>
<Application>
<Static>
<AppRoot value="http://www.mydomain.com/" context="home" />
<AppRoot value="/" context="live" />
</Static>
</Application>
Using AppRoot
This is how you would use AppRoot (with context) to display the company logo graphic:
<img src="(~Static.AppRoot~)images/logo.jpg" alt="company logo" />
The Point
By assigning a Context to each machine, you can share exactly the same application-level XML file between all machines.
Context is more flexible than the Windows "computer name", because you can put the same Context onto multiple machines on a LAN or WAN if you want to. For example, you might have several developers, each of whom use their own Context, and two production servers which share the same Context.
Version-Specific Notes
For WebHub Components v1.000 to v2.053
Feature formerly known as SetupID
This feature now called Context in ZaphodsMap was formerly known as SetupID in WebHub.
Running DynHelp.exe v1.2.0.6 on WebHub-v2.125 built by D14
Calc time: 172 ms

