Squeak Class Documentation category index | class index  
 
PWS
  category: Network-Pluggable Web Server
  superclass: Object
  subclasses:

PWS is the PluggableWebServer. Documentation for it can be found at
http://www.cc.gatech.edu/fac/mark.guzdial/squeak/pws/.

The PWS decouples the networking and HTTP translation roles of a Web Server
from the URL translation and CGI execution roles. The latter roles are
played by ServerActions.

To record a ServerAction for the PWS, use PWS link: key to: action. Key is
a string that will be parsed out of the incoming URL.

See PWS class howToStart.

PWS (and its associated files) are based on Georg Gollman's WebServer,
extended by Mark Guzdial. Those portions are copyright 1997 Georgia Tech
Research Corporation and are used with permission. Mark Guzdial's work on
PWS was funded in part by NSF grant REC-9550458.

instance methods
  Accessing
  fields
log
log:
message
message:
objectsInField:
peerName
reply:
url
userID

  Initializing
  clientName:
initializeFrom:
readRequest

  Processing
  decodeFields:
getReply
report:for:
unEscape:

class methods
  Backups
  addToBackupJob:

  HTTPcodes
  content:
contentHTML
crlf
crlfcrlf
notFound
redirectTo:
success
unauthorizedFor:

  Initializing
  checkVersion
howToStart
initialize
initializeAll

  ServerActions
  actions
link:to:

  Serving
  doBackupJobs
loopOnPort:loggingTo:
serve:
serveOnPort:loggingTo:
serveShowingErrorsOnPort:
shutDown
stopServer

instance methods
  Accessing top  
 

fields

Return the value of the instance variable 'fields'.


 

log

Return the value of the instance variable 'log'.


 

log:

Add to the log.


 

message

Return the value of the instance variable 'message'.


 

message:


 

objectsInField:

Extract the array of objects denoted by 'fieldName', return an empty array if there are none.


 

peerName

Return the requesting ipAddress


 

reply:

Send back part of the reply. If we are in roll forward mode just do nothing.


 

url


 

userID

Return the value of the instance variable 'userID'.


  Initializing top  
 

clientName:

Return the host name of the client connecting via the given socket. If the host name cannot be found, return a string representing that host's numeric IP address.


 

initializeFrom:

Initialize me from aSocket.


 

readRequest

Read the request and return an array of header and query.


  Processing top  
 

decodeFields:

Convert the form fields in aString to a query dictionary.


 

getReply

Generate a reply based on the action selected by the first word of the URL.


 

report:for:

Write an error report.


 

unEscape:

Convert escape sequences to their proper characters.


class methods
  Backups top  
 

addToBackupJob:

Stores blocks to be executed hourly at snapshot time.


  HTTPcodes top  
 

content:

Can also return image types


 

contentHTML


 

crlf


 

crlfcrlf


 

notFound


 

redirectTo:


 

success


 

unauthorizedFor:


  Initializing top  
 

checkVersion

This is Squeak 2.2. Make sure that the Server:swiki folder is the version for 2.2.


 

howToStart

To set up your new Swiki, you need a copy of the 'Server' folder
found at:
http://www.cc.gatech.edu/fac/mark.guzdial/squeak/pws/
Put the 'Server' folder into the folder that your image is in.

Modify this method to be a path to your Server folder, select it, and
choose fileItIn:
!ServerAction class methodsFor: 'System Services' stamp: 'tk 1/19/98 12:52'!
serverDirectory
^ 'Hard Disk:Squeak1.31:Server:'
! !

Then do:
PWS initializeAll.

To enable a new Swiki called OurOwnArea.
Make a folder named OurOwnArea in the Server folder. Then do:
SwikiAction setUp: 'OurOwnArea'.
(its main URL is http://thisMachine:80/OurOwnArea.1)

<<<<There has been a major change between Squeak 2.1 and 2.2. If you are reloading an existing Swiki for the first time in Squeak 2.2,
Do this instead of the normal reload.
SwikiAction new restore: 'myswiki'. '<- New line for each additional Swiki area'.
SwikiAction new restore: 'myswiki'. 'Case DOES matter in the name of Swiki here.'.
(PWS actions select: [ :action | action isKindOf: SwikiAction ])
do: [ :action | action fixAllLineEndings ].
PWS serveOnPort: 80 loggingTo: 'log.txt'.
(This to converts LineFeeds to CarriageReturns in all of your swiki data files. Only do this the first time!)
>>>>>

Suppose you already have a Swiki called 'myswiki'.
To start up:
SwikiAction new restore: 'myswiki'. '<- New line for each additional Swiki area'.
SwikiAction new restore: 'myswiki'. 'Case DOES matter in the name of Swiki here.'.
PWS serveOnPort: 80 loggingTo: 'log.txt'.

To stop the server:
PWS stopServer.

-----------------------
To purge a particular file of all except the latest version:
((PWS actions at: 'myswiki' asLowercase) urlmap atID: '3') condenseChanges.

To roll the entire wiki back to a previous time:


 

initialize

PWS initialize


 

initializeAll


  ServerActions top  
 

actions


 

link:to:


  Serving top  
 

doBackupJobs

This is just a wrapper so we don't have to restart the server loop when we add/remove jobs.


 

loopOnPort:loggingTo:

Loop forever handling HTTP requests. Run backup jobs periodically.


 

serve:

Respond to a request arriving on the given socket and return a string to be entered in the log file.


 

serveOnPort:loggingTo:

Start up the HTTP server loop for the given port number and log file.


 

serveShowingErrorsOnPort:

Start up the HTTP server loop for debugging! Operate in this
process, synchronously. Force errors to stop the server and show on the
screen..


 

shutDown

This message is sent on system shutdown to registered classes


 

stopServer

Shut down the server.