Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.upstream.getUpstreamSpec
on getUpstreamSpec (adrfile, adradrspec) {
<<Changes
<<10/22/01; 11:13:37 PM by JES
<<Change <account> and <email> to <usernum> when reading the file, for backward compatibility. If there's an error, log it to the events log, instead of doing a dialog.alert.
<<8/14/01; 1:23:09 PM by JES
<<If the spec is an xmlStorageSystem spec, and it has an email element instead of an account element, use email for account in the spec table.
<<6/23/01; 11:10:41 AM by DW
<<Return the address of an upstream spec table for the file.
<<For examples look in system.temp.radio.upstreamSpecCache.
<<Return false if we fail.
local (f = nameof (adrfile^), fname = file.filefrompath (f), atts);
radio.webServer.gatherAttributes (f, @atts);
if not defined (atts.upstream) { //no #upstream.xml file in folder or parent folder
return (false)};
local (fxml = atts.upstream);
adrfile^.baseUpstreamFolder = file.folderFromPath (fxml);
local (adrspec);
bundle { //set up the spec for the file
local (flread = true);
adrspec = @system.temp.radio.upstreamSpecCache.[fxml];
if defined (adrspec^) {
if file.modified (fxml) < adrspec^.timeLastRead {
flread = false}};
if flread {
try {
local (xmltext = string (file.readwholefile (fxml)), xstruct);
xml.compile (xmltext, @xstruct);
<<scratchpad.xstruct = xstruct
local (adrupstream = xml.getAddress (@xstruct, "upstream"));
new (tabletype, adrspec);
adrspec^.timeLastRead = clock.now ();
adrspec^.type = xml.getAttribute (adrupstream, "type")^;
for adrsub in adrupstream {
local (name = nameof (adrsub^));
if name beginswith "/" {
continue};
name = xml.convertToDisplayName (name);
if adrspec^.type == "xmlStorageSystem" { //8/14/01 JES: account, not email
if (name == "email") or (name == "account") {
name = "usernum"}};
adrspec^.[name] = adrsub^}}
<<adrspec^.password = user.radio.prefs.passwords.[adrspec^.passwordname]
else {
radio.log.add ("Read upstream spec", "Error: " + tryError, clock.ticks ());
return (false)}}};
adradrspec^ = adrspec;
return (true)}
<<bundle //test code
<<local (adrspec)
<<getUpstreamSpec (@user.radio.settings.files.["Backup:Radio UserLand:www:system:upstream:sh6:#upstream.xml"], @adrspec)
<<edit (adrspec)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.