need global configuration file to mostly replace local ones
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Scribe2 |
New
|
Undecided
|
Unassigned |
Bug Description
Right now, we have a series of files named petabox-
where CENTER is the name of one of our scanning centers, such as toronto
or sfdowntown.
These files define the locations of software in the system.
They are also nearly identical, so that if we make a system-wide change
(typically to add the location of a program to invoke), all of them have to be edited.
What would be better would be to have a single configuration file, plus perhaps
some small customized versions for storing local information (such as time zone).
We might be able to do this by using xinclude
(see http://
all the common data in one file and xinclud'ing it.
Or perhaps we could change some of the code in Config.inc or setup.php.
Or we might pursue something else entirely.
Confirmed that we can use Xinclude with php DOMDocument objects. (SimpleXML doesn't support Xinclude, but if we want to work in SimpleXML, we can simply convert to DOMDocument, do the Xinclude, and convert back to SimpleXML.) Wasn't aware of Xinclude until now - thanks, Dan!
The only thing that's slightly tricky is that we need the Xinclude to resolve to multiple nodes (all the second-level elements in the included xml), so that the inherited values don't end up one level deeper in the resulting xml structure than the local ones.
Our scancenter config files look like:
<?xml version="1.0" encoding="UTF-8"?> scribe. archive. org</domain> domain> archive. org</www- domain>
<settings>
<domain>
<www-
...
</settings>
Let's say we have a shared petabox- sw-config- scancenters. xml file like the above, and we want to overlay it with with some location-specific values. Then we'd have a location-specific file, say petabox- sw-config- sfdowntown. xml, that would look like this:
<?xml version="1.0" encoding="UTF-8"?> sw-config- scancenters. xml#xpointer( /settings/ *)"/> name>PST< /timezone- name> value>- 0800</timezone- value>
<settings>
<xi:include href="petabox-
<timezone-
<timezone-
</settings>
When resolved, the <xi:include> element will be replaced with all the elements immediately below <settings> in petabox- sw-config- scancenters. xml. Without the xpointer, the <settings> element itself would be inserted, burying the intended info one level too deep.
And here's how to make the substitution happen:
$dom = new DOMDocument(); "sfdowntown. xml");
$dom->load(
$dom->xinclude();
Our DOMDocument now contains the merged values.
We could also take it one step further, and put elements that are in petabox- sw-config- us.xml (the cluster-node config file), as well as the scribe config files, in a base config file that's shared across both the cluster and scancenters. Let's say we call that petabox- sw-config- base.xml. Then we move all the common stuff to there from petabox- sw-config- us.xml and petabox- sw-config- scancenters. xml, replacing it with an xi:include element. The dependencies would look like this:
petabox- sw-config- sfdowntown. xml => petabox- sw-config- scancenter. xml \
=> petabox- sw-config- base.xml
petabox- sw-config- us.xml /