darkness

Friday, 25 October 2002

Working with TWiki

darkness @ 18:02:03

I started playing with setting up TWiki at work. TWiki is not really very pretty code. TWiki will not run under mod_perl using Apache::Registry, though supposedly using Apache::PerlRun is OK. I’m using the latter right now and it seems to be fine. TWiki’s authentication and access controls are supposedly quite advanced and still aren’t very good, IMHO. Sigh.

I ended up rewriting almost all of SessionPlugin.pm so it would not use globals, play nice with mod_perl, etc. Additionally, the TWiki beta I got (TWiki 2002-08-03 I think) was calling CGI::header() after which SessionPlugin would try to call CGI::header() too. If you look at CGI.pm you might notice:

$CGI::revision = '$Id: CGI.pm,v 1.49 2001/02/04 23:08:39 lstein Exp $';
$CGI::VERSION='2.752';

...

sub header {
    my($self,@p) = self_or_default(@_);
    my(@header);

    return undef if $self->{'.header_printed'}++ and $HEADERS_ONCE;

(I quoted the two lines from the top so you could see what version I’m using. Additionally, running Red Hat 7.2’s perl-5.6.1-26.72.3.) Maybe my version is just old, or maybe I missed something in the code where they fudge $HEADERS_ONCE to non-zero value, but it was annoying as shit to see SessionPlugin calling a method that, it seemed to me, it shouldn’t have been calling. (P.S.: CGI.pm is no beauty either.) I also had to patch TWiki.pm to trick CGI into thinking it wasn’t running in mod_perl before it calls the writeHeaderHandlers from plug-ins:

diff -ur misc/build/twiki-beta/lib/TWiki.pm twiki/lib/TWiki.pm
--- misc/build/twiki-beta/lib/TWiki.pm  Sun Aug  4 00:15:20 2002
+++ twiki/lib/TWiki.pm  Fri Oct 25 02:11:41 2002
@@ -290,6 +290,8 @@
     # of other types of page, with expiry time driven by page type.
     my( $pluginHeaders, $coreHeaders );
 
+    local ($CGI::MOD_PERL) = 0;
+
     if ($pageType eq 'edit') {
        # Get time now in HTTP header format
        my $lastModifiedString = formatGmTime(time, 'http');

For your perusal, my modified SessionPlugin.pm. Note that you still need all the other files from SessionPlugin.zip for this to work.

Now that I have SessionPlugin working, I can hit bin/login (distributed with SessionPlugin) from a browser, authenticate once, and it’ll stick with me for the rest of my session. Minor joy masking annoyance. I should write a good Wiki; we’ll just put that on the “to-do list”.

Now I’m working on a good way to edit Wiki pages from Emacs. There’s WikiRemote, but that seems to be unmaintained, and further I worry about being authenticated (which I require). At the bottom of WikiRemote you’ll notice the bit about using w3m and GnuClient (or emacsclient in my case, I hope) to edit text fields in w3m. w3m appears to do cookies and I hope HTTP basic auth, so this will probably be the first thing I’ll try. Another option is XmlRpcToWiki, but this doesn’t appear to use any authentication with TWiki, so I’d end up having to hack that up. Then I think I’d have to hack together some stuff into a mode, though thankfully xml-rpc.el exists.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress