~ubuntu-branches/ubuntu/intrepid/prewikka/intrepid

« back to all changes in this revision

Viewing changes to prewikka/templates/PropertiesChangeForm.py

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2007-04-11 14:41:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070411144109-2hh7zx3amwd27b4l
Tags: upstream-0.9.10
ImportĀ upstreamĀ versionĀ 0.9.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
 
 
4
 
 
5
 
 
6
##################################################
 
7
## DEPENDENCIES
 
8
import sys
 
9
import os
 
10
import os.path
 
11
from os.path import getmtime, exists
 
12
import time
 
13
import types
 
14
import __builtin__
 
15
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
 
16
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
 
17
from Cheetah.Template import Template
 
18
from Cheetah.DummyTransaction import DummyTransaction
 
19
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
 
20
from Cheetah.CacheRegion import CacheRegion
 
21
import Cheetah.Filters as Filters
 
22
import Cheetah.ErrorCatchers as ErrorCatchers
 
23
from prewikka.templates.ClassicLayout import ClassicLayout
 
24
 
 
25
##################################################
 
26
## MODULE CONSTANTS
 
27
try:
 
28
    True, False
 
29
except NameError:
 
30
    True, False = (1==1), (1==0)
 
31
VFFSL=valueFromFrameOrSearchList
 
32
VFSL=valueFromSearchList
 
33
VFN=valueForName
 
34
currentTime=time.time
 
35
__CHEETAH_version__ = '2.0rc7'
 
36
__CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 7)
 
37
__CHEETAH_genTime__ = 1166283667.9657021
 
38
__CHEETAH_genTimestamp__ = 'Sat Dec 16 16:41:07 2006'
 
39
__CHEETAH_src__ = 'prewikka/templates/PropertiesChangeForm.tmpl'
 
40
__CHEETAH_srcLastModified__ = 'Fri Dec 15 10:49:19 2006'
 
41
__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
 
42
 
 
43
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
 
44
    raise AssertionError(
 
45
      'This template was compiled with Cheetah version'
 
46
      ' %s. Templates compiled before version %s must be recompiled.'%(
 
47
         __CHEETAH_version__, RequiredCheetahVersion))
 
48
 
 
49
##################################################
 
50
## CLASSES
 
51
 
 
52
class PropertiesChangeForm(ClassicLayout):
 
53
 
 
54
    ##################################################
 
55
    ## CHEETAH GENERATED METHODS
 
56
 
 
57
 
 
58
    def __init__(self, *args, **KWs):
 
59
 
 
60
        ClassicLayout.__init__(self, *args, **KWs)
 
61
        if not self._CHEETAH__instanceInitialized:
 
62
            cheetahKWArgs = {}
 
63
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
 
64
            for k,v in KWs.items():
 
65
                if k in allowedKWs: cheetahKWArgs[k] = v
 
66
            self._initCheetahInstance(**cheetahKWArgs)
 
67
        
 
68
 
 
69
    def main_content(self, **KWS):
 
70
 
 
71
 
 
72
 
 
73
        ## CHEETAH: generated from #block main_content at line 3, col 1.
 
74
        trans = KWS.get("trans")
 
75
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
 
76
            trans = self.transaction # is None unless self.awake() was called
 
77
        if not trans:
 
78
            trans = DummyTransaction()
 
79
            _dummyTrans = True
 
80
        else: _dummyTrans = False
 
81
        write = trans.response().write
 
82
        SL = self._CHEETAH__searchList
 
83
        _filter = self._CHEETAH__currentFilter
 
84
        
 
85
        ########################################
 
86
        ## START - generated method body
 
87
        
 
88
        write('<form action="?" method="post">\n')
 
89
        for name, value in VFFSL(SL,"hiddens",True): # generated from line 5, col 1
 
90
            write('\t<input type="hidden" name="')
 
91
            _v = VFFSL(SL,"name",True) # '$name' on line 6, col 29
 
92
            if _v is not None: write(_filter(_v, rawExpr='$name')) # from line 6, col 29.
 
93
            write('" value="')
 
94
            _v = VFFSL(SL,"value",True) # '$value' on line 6, col 43
 
95
            if _v is not None: write(_filter(_v, rawExpr='$value')) # from line 6, col 43.
 
96
            write('"/>\n')
 
97
        write('        <table class="properties_change_table">\n')
 
98
        row_classes = ("table_row_even", "table_row_odd")
 
99
        cnt = 0
 
100
        for property in VFFSL(SL,"properties",True): # generated from line 11, col 2
 
101
            write('\t\t<tr class="')
 
102
            _v = VFFSL(SL,"row_classes",True)[VFFSL(SL,"cnt",True)%2] # '$row_classes[$cnt%2]' on line 12, col 14
 
103
            if _v is not None: write(_filter(_v, rawExpr='$row_classes[$cnt%2]')) # from line 12, col 14.
 
104
            write('">\n\t\t\t<td>')
 
105
            _v = VFFSL(SL,"property.name",True) # '$property.name' on line 13, col 8
 
106
            if _v is not None: write(_filter(_v, rawExpr='$property.name')) # from line 13, col 8.
 
107
            write('</td>\n')
 
108
            if VFFSL(SL,"property.value",True): # generated from line 14, col 4
 
109
                if VFFSL(SL,"property.type",True) == 'checkbox': # generated from line 15, col 5
 
110
                    value = 'checked'
 
111
                else: # generated from line 17, col 5
 
112
                    value = "value=" + VFFSL(SL,"property.value",True)
 
113
            else: # generated from line 20, col 4
 
114
                value = ""
 
115
            write('\t\t\t<td><input type="')
 
116
            _v = VFFSL(SL,"property.type",True) # '$property.type' on line 23, col 21
 
117
            if _v is not None: write(_filter(_v, rawExpr='$property.type')) # from line 23, col 21.
 
118
            write('" name="')
 
119
            _v = VFFSL(SL,"property.parameter",True) # '$property.parameter' on line 23, col 43
 
120
            if _v is not None: write(_filter(_v, rawExpr='$property.parameter')) # from line 23, col 43.
 
121
            write('" ')
 
122
            _v = VFFSL(SL,"value",True) # '$value' on line 23, col 64
 
123
            if _v is not None: write(_filter(_v, rawExpr='$value')) # from line 23, col 64.
 
124
            write('/></td>\n\t\t</tr>\n')
 
125
            cnt += 1
 
126
        write('\t</table>\n\t<br/>\n\t<input type="submit" value="')
 
127
        _v = VFFSL(SL,"submit",True) # '$submit' on line 29, col 30
 
128
        if _v is not None: write(_filter(_v, rawExpr='$submit')) # from line 29, col 30.
 
129
        write('"/>\n</form>\n')
 
130
        
 
131
        ########################################
 
132
        ## END - generated method body
 
133
        
 
134
        return _dummyTrans and trans.response().getvalue() or ""
 
135
        
 
136
 
 
137
    def writeBody(self, **KWS):
 
138
 
 
139
 
 
140
 
 
141
        ## CHEETAH: main method generated for this template
 
142
        trans = KWS.get("trans")
 
143
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
 
144
            trans = self.transaction # is None unless self.awake() was called
 
145
        if not trans:
 
146
            trans = DummyTransaction()
 
147
            _dummyTrans = True
 
148
        else: _dummyTrans = False
 
149
        write = trans.response().write
 
150
        SL = self._CHEETAH__searchList
 
151
        _filter = self._CHEETAH__currentFilter
 
152
        
 
153
        ########################################
 
154
        ## START - generated method body
 
155
        
 
156
        write('\n')
 
157
        self.main_content(trans=trans)
 
158
        
 
159
        ########################################
 
160
        ## END - generated method body
 
161
        
 
162
        return _dummyTrans and trans.response().getvalue() or ""
 
163
        
 
164
    ##################################################
 
165
    ## CHEETAH GENERATED ATTRIBUTES
 
166
 
 
167
 
 
168
    _CHEETAH__instanceInitialized = False
 
169
 
 
170
    _CHEETAH_version = __CHEETAH_version__
 
171
 
 
172
    _CHEETAH_versionTuple = __CHEETAH_versionTuple__
 
173
 
 
174
    _CHEETAH_genTime = __CHEETAH_genTime__
 
175
 
 
176
    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
 
177
 
 
178
    _CHEETAH_src = __CHEETAH_src__
 
179
 
 
180
    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
 
181
 
 
182
    _mainCheetahMethod_for_PropertiesChangeForm= 'writeBody'
 
183
 
 
184
## END CLASS DEFINITION
 
185
 
 
186
if not hasattr(PropertiesChangeForm, '_initCheetahAttributes'):
 
187
    templateAPIClass = getattr(PropertiesChangeForm, '_CHEETAH_templateClass', Template)
 
188
    templateAPIClass._addCheetahPlumbingCodeToClass(PropertiesChangeForm)
 
189
 
 
190
 
 
191
# CHEETAH was developed by Tavis Rudd and Mike Orr
 
192
# with code, advice and input from many other volunteers.
 
193
# For more information visit http://www.CheetahTemplate.org/
 
194
 
 
195
##################################################
 
196
## if run from command line:
 
197
if __name__ == '__main__':
 
198
    from Cheetah.TemplateCmdLineIface import CmdLineIface
 
199
    CmdLineIface(templateObj=PropertiesChangeForm()).run()
 
200
 
 
201