~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/server/server_cgi.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - CGI pseudo Server
 
4
 
 
5
    This is not really a server, it is just so that CGI stuff (the real
 
6
    server is likely Apache or IIS or some other std. CGI server) looks
 
7
    similar to what we have for Twisted and standalone server.
 
8
 
 
9
    Minimal usage:
 
10
 
 
11
        from MoinMoin.server.server_cgi import CgiConfig, run
 
12
 
 
13
        class Config(CgiConfig):
 
14
            pass
 
15
 
 
16
        run(Config)
 
17
 
 
18
    See more options in CgiConfig class.
 
19
 
 
20
    @copyright: 2006 MoinMoin:ThomasWaldmann
 
21
    @license: GNU GPL, see COPYING for details.
 
22
"""
 
23
 
 
24
from MoinMoin.server import Config
 
25
from MoinMoin.request import request_cgi
 
26
 
 
27
# Server globals
 
28
config = None
 
29
 
 
30
# ------------------------------------------------------------------------
 
31
# Public interface
 
32
 
 
33
class CgiConfig(Config):
 
34
    """ CGI default config """
 
35
    name = 'moin'
 
36
    properties = {}
 
37
 
 
38
    # Development options
 
39
    hotshotProfile = None # e.g. "moin.prof"
 
40
 
 
41
 
 
42
def run(configClass):
 
43
    """ Create and run a Cgi Request
 
44
 
 
45
    See CgiConfig for available options
 
46
 
 
47
    @param configClass: config class
 
48
    """
 
49
 
 
50
    config = configClass()
 
51
 
 
52
    if config.hotshotProfile:
 
53
        import hotshot
 
54
        config.hotshotProfile = hotshot.Profile(config.hotshotProfile)
 
55
        config.hotshotProfile.start()
 
56
 
 
57
    request = request_cgi.Request(properties=config.properties)
 
58
    request.run()
 
59
 
 
60
    if config.hotshotProfile:
 
61
        config.hotshotProfile.close()
 
62
 
 
63