Tags:
create new tag
, view all tags

Feature Proposals » Some changes might be required in TWiki to run it under a PSGI engine

Summary

Current State: Developer: Reason: Date: Concerns By: Bug Tracking: Proposed For:
MergedToCore HaraldJoerg None 2015-04-02   Bugs:Item7633 KampalaRelease

Edit Form

TopicSummary:
CurrentState:
CommittedDeveloper:
ReasonForDecision:
DateOfCommitment:   Format: YYYY-MM-DD
ConcernRaisedBy:
BugTracking:
OutstandingIssues:
RelatedTopics:
InterestedParties:
ProposedFor:
TWikiContributors:
 

Motivation

As outlined in TWikiasPSGIapplication, running TWiki without an underlying "general purpose" webserver has some benefits. But though most of the stuff can be implemented as a contrib, some changes in the TWiki core might be necessary. This proposal asks for acceptance of forthcoming changes.

Description and Documentation

Most of the preparations have already been done by GilmarSantosJr, they just need to be picked up and finalized. Back in 2008, when TWikiStandAlone and EnginesAsContribs were discussed, PSGI (the specification) and Plack (the Perl modules) were not available, but today we can just build upon them.

Right now I found exactly one line in TWiki.pm which must be changed, and this change is harmless. However, I expect we'll discover more quirks soon: For a start, I haven't even looked at configure.

Examples

Impact

WhatDoesItAffect: Install

Implementation

-- Contributors: Harald Jörg - 2015-04-01

Discussion

Absolutely yes, good move.

TWiki already uses an undocumented $TWiki::cfg{Engine} configure setting. Possibly use a select for the engine in configure? There needs to be some discovery though, a script might run as a shell script or via http protocol.

-- Peter Thoeny - 2015-04-02

Oh, this makes me notice a bad idea of mine. I should keep the PSGI invocation scripts away from the bin directory where view and its companions live. Maybe $TWIKI_ROOT/psgi.

In detail: Yes, I've seen the configure setting. I am pretty sure that it ain't such a good idea to select the engine from a configure setting. It is rather the other way around: When TWiki reads the configuration, the environment has already been set up; it is the environment which dictates which engine must be used. The PSGI engine identifies itself in $TWiki::cfg{Engine} to the rest of the code, but this setting should only be used in case of emergency. Coming back to my rant about object lifetime in TurningTWikiUpsideDown: The engine is a per-request setting: We don't run configure each time before we run a shell script for our normally web-based TWiki!

The traditional TWiki scripts need discovery because they are double-purpose for CLI and CGI. However, there isn't much benefit from that. Instead of having the if (CGI) {...} else {...} mantra in each of the scripts, we could as well have two separate groups, one for CGI and one for CLI. Or one script twiki.cgi for CGI (we had this discussion a few years ago), and one twiki.sh for CLI, to be used like twiki.sh view [parameters], and developed with frameworks like CPAN:MooseX::App::Cmd. And while I am pretty sure too lazy to go for twiki.cgi, I might go for twiki.sh.

An anecdote from the past: You probably know that CGI.pm has command line capabilities as well. When I started with TWiki, I was quite familiar with the CLI syntax of CGI.pm. Therefore I decided to set $ENV{GATEWAY_INTERFACE} in my bash to a true value and have practically never used TWiki's CLI engine. smile

-- Harald Jörg - 2015-04-02

The changes needed in the core to get the PSGI engine running have been committed: In addition to the one line in TWiki.pm, a few changes had to be made to the configure modules, all of them pretty harmless. The setup is like this:

  • PSGI is available as a PSGIEngineContrib. This contrib also has a PARLoader module which enables TWiki to be bundled as a standalone application with CPAN:pp.
  • The code of bin/configure has been copied and adapted as needed for PSGI in a new Configure module within PSGIEngineContrib. With very few exceptions, all modules from lib/TWiki/Configure work without changes in both environments!
Therefore, I'm marking this as "merged to core."

-- Harald Jörg - 2015-06-22

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2015-06-22 - HaraldJoerg
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.