<?xml version="1.0"?>
<!-- RSS generated by Radio UserLand v8.0.8 on Mon, 14 Apr 2003 18:41:48 GMT -->
<rss version="2.0">
	<channel>
		<title>Dave Seidel: Code</title>
		<link>http://radio.weblogs.com/0100130/categories/code/</link>
		<description>Free software.</description>
		<copyright>Copyright 2003 Dave Seidel</copyright>
		<lastBuildDate>Mon, 14 Apr 2003 18:41:48 GMT</lastBuildDate>
		<docs>http://backend.userland.com/rss</docs>
		<generator>Radio UserLand v8.0.8</generator>
		<managingEditor>http://subhonker6.userland.com/staticSiteStats/mail?usernum=0100130</managingEditor>
		<webMaster>http://subhonker6.userland.com/staticSiteStats/mail?usernum=0100130</webMaster>
		<category domain="http://www.weblogs.com/rssUpdates/changes.xml">rssUpdates</category> 
		<skipHours>
			<hour>1</hour>
			<hour>2</hour>
			<hour>3</hour>
			<hour>17</hour>
			<hour>22</hour>
			<hour>4</hour>
			<hour>0</hour>
			<hour>23</hour>
			</skipHours>
		<cloud domain="radio.xmlstoragesystem.com" port="80" path="/RPC2" registerProcedure="xmlStorageSystem.rssPleaseNotify" protocol="xml-rpc"/>
		<ttl>60</ttl>
		<item>
			<title>Radio buglet and patch</title>
			<link>http://radio.weblogs.com/0100130/categories/code/2003/03/07.html#a160</link>
			<description>&lt;em&gt;[I &lt;a href=&quot;http://groups.yahoo.com/group/radio-userland/message/28326&quot;&gt;posted &lt;/a&gt; the original version of this to the Radio Userland mailing list.]&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
&lt;ol start=&quot;0&quot;&gt;
&lt;li&gt;I recently found a bug in the htmlControlStartup callback while
figuring out how to tell the Radio app to use my own background HTML
file instead of the one supplied in
&amp;lt;RadioInstallFolder&amp;gt;/Appearance/html/background.html.&lt;/li&gt;
&lt;li&gt;What I did: I wrote an HTML file called myBackground.html and put it
in the same folder as background.html.  Then I wrote a script called workspace.myBackground and added its address to user.callbacks.htmlControlStartup.  I based this on the fact that all other entries in user.callbacks.* are addresses. Here&apos;s my script:
&lt;pre&gt;
on myBackground(url) {
    local (appFolder = file.folderFromPath(Frontier.getProgramPath()));
    local (pc = file.getPathChar());
    local (appearanceFolder = appFolder + &quot;Appearance&quot; + pc);
    local (htmlFolder = appearanceFolder + &quot;html&quot; + pc);
    local (myBackground = htmlFolder + &quot;myBackground.html&quot;);
    local (myURL = file.fileToUrl(myBackground));
    url^ = myUrl;
    return true
}
&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;What I expected to happen: After stopping and restarting Radio, and opening the application, I expected to see my background.&lt;/li&gt;
&lt;li&gt;What actually happened: I saw Radio&apos;s default background as usual.&lt;/li&gt;
&lt;li&gt;The workaround: I found that I had to put my actual script, rather than its address, into user.callbacks.htmlControlStartup in order for my script to be called and take effect.&lt;/li&gt;
&lt;li&gt;The source of the problem: Scripts in
user.callbacks.htmlControlStartup are called by
system.callbacks.htmlControlStartup.  I compared the callback code there with callback code in other system.callbacks scripts, and found that there was some missing code.  Here&apos;s the loop in htmlControlStartup:
&lt;pre&gt;
for adrScript in @user.callbacks.htmlControlStartup {
    try {
        if adrScript^ (@url) {
            return (url)
        }
    }
}
&lt;/pre&gt;
Here&apos;s the equivalent loop in system.callbacks.opExpand:
&lt;pre&gt;
for adrscript in @user.callbacks.opExpand {
    try {
        while typeOf (adrScript^) == addressType {
            adrScript = adrScript^
        };
        if adrscript^ () {
            return (true)
        }
    }
}
&lt;/pre&gt;
Clearly, the while loop that dereferences the address of the user
callback script is missing in htmlControlStartup.&lt;/li&gt;
&lt;li&gt;The fix: I have a patched version system.callbacks.htmlControlStartup available for download 
&lt;a href=&quot;http://radio.weblogs.com/0100130/radio/callbacks.htmlControlStartup.ftsc&quot;&gt;here&lt;/a&gt;. I have tested it and it seems to work fine.  It would be great if [UserLand] would examine this to make sure it&apos;s right, and if so, make it generally available.&lt;/li&gt;
&lt;/ol&gt;
</description>
			<guid>http://radio.weblogs.com/0100130/categories/code/2003/03/07.html#a160</guid>
			<pubDate>Fri, 07 Mar 2003 16:32:01 GMT</pubDate>
			<comments>http://www.pycs.net/system/comments.py?u=100130&amp;amp;p=160</comments>
			</item>
		<item>
			<title>Finally, download links</title>
			<link>http://radio.weblogs.com/0100130/categories/code/2003/03/02.html#a152</link>
			<description>Finally, with the help of Andy Fragen, I got the &lt;a href=&quot;http://radio.weblogs.com/0100130/2003/03/02.html#a151&quot;&gt;macro&lt;/a&gt; working to add download links to the sidebar.</description>
			<guid>http://radio.weblogs.com/0100130/categories/code/2003/03/02.html#a152</guid>
			<pubDate>Sun, 02 Mar 2003 19:00:52 GMT</pubDate>
			<comments>http://www.pycs.net/system/comments.py?u=100130&amp;amp;p=152</comments>
			</item>
		<item>
			<title>Radio: macro frustration</title>
			<link>http://radio.userland.com/discuss/msgReader$23338</link>
			<description>&lt;em&gt;I just posted this to the &lt;a href=&quot;http://radio.userland.com/discuss/msgReader$23338&quot;&gt;Radio discussion list&lt;/a&gt;, but I&apos;m also posting it here, in hopes that someone will be able to help me out.&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
I&apos;m having a strange problem with macros.  I created a new file (based on some code that Lawrence or someone posed on this list last year) in my Macros folder called myLinks.txt.  The purpose of the macro is to insert the contents of a file called #links.txt into a rendered page, so that I can have custom links on a per-category basis.  Here&apos;s what the file looks like (hope this doesn&apos;t get too munged when I post it):&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;
on myLinks()
&amp;#123;
    local (categoryPath, path = user.radio.prefs.wwwfolder, s = &quot;&amp;nbsp;&quot;);
    if defined(categoryName)
    &amp;#123;
        categoryPath = weblogData.categories.[categoryName].fileName;
        path = path + &quot;\\categories\\&quot; + categoryPath + &quot;\\#links.txt&quot;;
        if file.exists(path)
        &amp;#123;
            s = &quot;&amp;lt;!-- &quot; + path + &quot; --&gt;\n&quot; + string(file.readWholeFile(path));
        &amp;#125;
    &amp;#125;
    else
    &amp;#123;
        path = path + &quot;\\#links.txt&quot;;
        if file.exists(path)
        &amp;#123;
            s = &quot;&amp;lt;!-- &quot; + path + &quot; --&gt;\n&quot; + string(file.readWholeFile(path));
        &amp;#125;
    &amp;#125;
    return s;
&amp;#125;;
&lt;/pre&gt;
&lt;br&gt;
Then, it my home page template, I added &amp;lt;%myLinks()%&gt;.  But what I got in the rendered page was&lt;br&gt;
&lt;br&gt;
[Macro error: Can&apos;t call the script because the name &quot;myLinks&quot; hasn&apos;t been defined.]&lt;br&gt;
&lt;br&gt;
As a test, I took a macro I that I&apos;m already using succesfully (called subs() in the file subs.txt), copied it to a new file in the Macros folder called subs2.txt and edited the file to rename the routine to subs2(), then used the macro in a test page.  But I got a similar error:&lt;br&gt;
&lt;br&gt;
[Macro error: Can&apos;t call the script because the name &quot;subs2&quot; hasn&apos;t been defined.]&lt;br&gt;
&lt;br&gt;
I must be doing something wrong, but what?  The files are all valid UserTalk code, AFAIK.  All the files in my Macros directory have the same permissions and attributes (I&apos;m on Win2K).&lt;br&gt;
&lt;br&gt;
Any ideas?&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;em&gt;Update&lt;/em&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://radio.weblogs.com/0001017/&quot;&gt;Andy Fragen&lt;/a&gt;, no slouch when it comes to Radio scripting, &lt;a href-&quot;http://radio.userland.com/discuss/msgReader$23341?y=2003&amp;m=3&amp;d=2&quot;&gt;suggests&lt;/a&gt; a workaround, which is to place the script into the workspace table and call it with &amp;lt;% workspace.myLinks() %&gt;.  This works fine &amp;mdash; thanks, Andy!.  But I&apos;d still like to understand why it didn&apos;t work the other way.</description>
			<guid>http://radio.weblogs.com/0100130/categories/code/2003/03/02.html#a151</guid>
			<pubDate>Sun, 02 Mar 2003 15:44:40 GMT</pubDate>
			<comments>http://www.pycs.net/system/comments.py?u=100130&amp;amp;p=151</comments>
			</item>
		<item>
			<title>filestats.py 1.2</title>
			<link>http://www.superluminal.com/dave/code/filestats.py</link>
			<description>Put up version &lt;a href=&quot;http://www.superluminal.com/dave/code/filestats.py&quot;&gt;1.2&lt;/a&gt; of filestats.  The only change here is that it will detect a non-conforming server log (i.e, not in the Apache &amp;quot;combined&amp;quot; format), tell the user, and quit without writing a useless output file.  Thanks to &lt;a href=&quot;http://www.pocketsoap.com/weblog&quot;&gt;Simon Fell&lt;/a&gt; for reporting this, even though this doesn&apos;t really solve his problem &amp;mdash; he wants to be able to process IIS log files.  I&apos;m considering writing a file conversion routine to handle this.</description>
			<guid>http://radio.weblogs.com/0100130/categories/code/2003/02/24.html#a144</guid>
			<pubDate>Mon, 24 Feb 2003 14:53:02 GMT</pubDate>
			<comments>http://www.pycs.net/system/comments.py?u=100130&amp;amp;p=144</comments>
			</item>
		<item>
			<title>filestats 1.1</title>
			<link>http://www.superluminal.com/dave/code/filestats.py</link>
			<description>I just uploaded &lt;a href=&quot;http://www.superluminal.com/dave/code/filestats.py&quot;&gt;filestats.py version 1.1&lt;/a&gt; to fix some stupid stuff in 1.0 -- it wouldn&apos;t run unless the dns.cache file already existed.</description>
			<guid>http://radio.weblogs.com/0100130/categories/code/2003/02/20.html#a139</guid>
			<pubDate>Thu, 20 Feb 2003 12:33:58 GMT</pubDate>
			<comments>http://www.pycs.net/system/comments.py?u=100130&amp;amp;p=139</comments>
			</item>
		<item>
			<title>filestats</title>
			<link>http://www.superluminal.com/dave/code/filestats.py</link>
			<description>I have just uploaded version 1.0 of a specialized web server log analysis program called &lt;a href=&quot;http://www.superluminal.com/dave/code/filestats.py&quot;&gt;filestats&lt;/a&gt;.  Not a big deal, but it does something that Analog and Webalizer doesn&apos;t do, AFAIK.  Given a list of one or more files on a server, filestats builds a report that shows who (i.e., what client machines) have accessed those files, by referer (the default) or by UserAgent.  So, for example, if you&apos;d like to see who is downloading your RSS feed, grouped by referer, you would say something like this (except all on one line):&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;
python filestats -i access_log
                 -o feedstats.opml
                 -s &lt;a href=&quot;http://www.example.com&quot;&gt;http://www.example.com&lt;/a&gt;
                 -f /weblog/rss.xml
&lt;/pre&gt;
&lt;br&gt;
To see the same data, but grouped by UserAgent, just add the switch &quot;-a&quot;.&lt;br&gt;
&lt;br&gt;
I decided to use &lt;a href=&quot;http://www.opml.org/spec&quot;&gt;OPML&lt;/a&gt; as the output format, because I use Radio and ActiveRenderer, which gives me editing, rendering, and publishing without any extra work.  And besides, filestats produces hierarchical data, so using an outline format just makes sense.&lt;br&gt;
&lt;br&gt;
It&apos;s written in Python and relies on Mark Nottingham&apos;s very useful &lt;a href=&quot;http://www.mnot.net/python/WebLog/&quot;&gt;Weblog&lt;/a&gt; package.&lt;br&gt;
&lt;br&gt;
I&apos;m publishing it under the Creative Commons &lt;a href=&quot;http://creativecommons.org/licenses/by/1.0&quot;&gt;Attribution License&lt;/a&gt;, which (as I understand it) means that it&apos;s free for any use, commercial or non-commercial, and can be modified or derived from, you just have to give me credit.&lt;br&gt;
&lt;br&gt;
I&apos;m open to suggestions and bug reports. &quot;;-&gt;&quot;</description>
			<guid>http://radio.weblogs.com/0100130/categories/code/2003/02/20.html#a138</guid>
			<pubDate>Thu, 20 Feb 2003 12:30:59 GMT</pubDate>
			<comments>http://www.pycs.net/system/comments.py?u=100130&amp;amp;p=138</comments>
			</item>
		</channel>
	</rss>
