root/cherokee/trunk/admin/ModuleCommon.py

Revision 2281, 1.9 kB (checked in by alo, 1 month ago)

--

Line 
1 from Form import *
2 from Table import *
3
4 from ModuleHandler import *
5 from ModuleFile import *
6 from ModuleDirlist import *
7
8 NOTE_PATHINFO = "Allow extra tailing paths"
9 NOTE_DIRLIST  = "Allow to list directory contents"
10
11 HELPS = [
12     ('modules_handlers_common', "List & Send")
13 ]
14
15 class ModuleCommon (ModuleHandler):
16     PROPERTIES = ModuleFile.PROPERTIES + ModuleDirlist.PROPERTIES + [
17         'allow_pathinfo', 'allow_dirlist'
18     ]
19
20     def __init__ (self, cfg, prefix, submit_url):
21         ModuleHandler.__init__ (self, 'common', cfg, prefix, submit_url)
22
23         self._file    = ModuleFile    (cfg, prefix, submit_url)
24         self._dirlist = ModuleDirlist (cfg, prefix, submit_url)
25
26     def _op_render (self):
27         txt = ''
28
29         # Local properties
30         table = TableProps()
31         self.AddPropCheck (table, 'Allow PathInfo', '%s!allow_pathinfo'%(self._prefix), False, NOTE_PATHINFO)
32         self.AddPropCheck (table, 'Allow Directory Listing', '%s!allow_dirlist'%(self._prefix), True, NOTE_DIRLIST)
33
34         txt = '<h2>Parsing</h2>'
35         txt += self.Indent(table)
36        
37         # Copy errors to the modules,
38         # they may need to print them
39         self._copy_errors (self, self._file)
40         self._copy_errors (self, self._dirlist)
41
42         txt += self._file._op_render()
43         txt += self._dirlist._op_render()
44
45         return txt
46
47     def _op_apply_changes (self, uri, post):
48         self.ApplyCheckbox (post, '%s!allow_pathinfo'%(self._prefix))
49         self.ApplyCheckbox (post, '%s!allow_dirlist'%(self._prefix))
50
51         # Copy errors from the child modules
52         self._copy_errors (self._file,    self)
53         self._copy_errors (self._dirlist, self)
54
55         # Apply the changes
56         self._file._op_apply_changes (uri, post)
57         self._dirlist._op_apply_changes (uri, post)
58
59     def _copy_errors (self, _from, _to):
60         for e in _from.errors:
61             _to.errors[e] = _from.errors[e]
Note: See TracBrowser for help on using the browser.