Attachment 'remote.tac'
Download 1 """
2 serve remote wiki pages
3
4 run with twistd -y remote.tac
5 access the remote wiki on localhost:8080
6
7 """
8
9 remote_wiki = 'http://moinmoin.wikiwikiweb.de'
10
11 from twisted.application import internet, service
12 from twisted.protocols import http
13 from twisted.web import client
14
15 class RemoteRequest(http.Request):
16 def process(self):
17 """ Process request """
18 page = self.channel.factory.getPage(self.uri)
19 page.addErrback(lambda e: "Internal server error")
20 page.addCallback(lambda m: (self.write(m), self.finish()))
21
22 class RemoteChannel(http.HTTPChannel):
23 """ Create request for each connection """
24 requestFactory = RemoteRequest
25
26 class RemoteFactory(http.HTTPFactory):
27 protocol = RemoteChannel
28 def __init__(self, remote):
29 self.remote = remote
30
31 def getPage(self, uri):
32 """ Get page from remote wiki """
33 return client.getPage(self.remote + uri)
34
35 application = service.Application('remote', uid=1, gid=1)
36 factory = RemoteFactory(remote_wiki)
37 internet.TCPServer(8080, factory).setServiceParent(application)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.