File: HTMLBase.py

package info (click to toggle)
xen-3.0 3.0.3-0-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 31,772 kB
  • ctags: 70,362
  • sloc: ansic: 417,153; python: 28,855; asm: 23,892; sh: 5,157; makefile: 4,830; objc: 613; perl: 372; xml: 351
file content (53 lines) | stat: -rwxr-xr-x 1,401 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from xen.sv.util import *

class HTMLBase:

    isLeaf = True
 
    def __init__( self ):
        pass

    def render_POST( self, request ):
        self.perform( request )
        return self.render_GET( request )
        
    def render_GET( self, request ):
        pass
    
    def write_BODY( self, request ):
        pass
        
    def write_TOP( self, request ):
        pass
    
    def write_BOTTOM( self, request ):
        pass
    
    def get_op_method(self, op):
        """Get the method for an operation.
        For operation 'foo' looks for 'op_foo'.

        op	operation name
        returns method or None
        """
        op_method_name = 'op_' + op
        return getattr(self, op_method_name, None)
        
    def perform(self, req):
        """General operation handler for posted operations.
        For operation 'foo' looks for a method op_foo and calls
        it with op_foo(req). Replies with code 500 if op_foo
        is not found.

        The method must return a list when req.use_sxp is true
        and an HTML string otherwise (or list).
        Methods may also return a Deferred (for incomplete processing).

        req	request
        """
        op = req.args.get('op')
        if not op is None and len(op) == 1:
            op = op[0]
            op_method = self.get_op_method(op)
            if op_method:
                op_method( req )