]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/books_by_author.py
Fix(web): Escape attributes values and texts
[m_librarian.git] / m_librarian / web / views / books_by_author.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4
5
6
7 ##################################################
8 ## DEPENDENCIES
9 import sys
10 import os
11 import os.path
12 try:
13     import builtins as builtin
14 except ImportError:
15     import __builtin__ as builtin
16 from os.path import getmtime, exists
17 import time
18 import types
19 from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
20 from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
21 from Cheetah.Template import Template
22 from Cheetah.DummyTransaction import *
23 from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
24 from Cheetah.CacheRegion import CacheRegion
25 import Cheetah.Filters as Filters
26 import Cheetah.ErrorCatchers as ErrorCatchers
27 from Cheetah.compat import unicode
28 import cgi
29 from views.layout import layout
30
31 ##################################################
32 ## MODULE CONSTANTS
33 VFFSL=valueFromFrameOrSearchList
34 VFSL=valueFromSearchList
35 VFN=valueForName
36 currentTime=time.time
37 __CHEETAH_version__ = '3.1.0'
38 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
39 __CHEETAH_genTime__ = 1527213181.482462
40 __CHEETAH_genTimestamp__ = 'Fri May 25 04:53:01 2018'
41 __CHEETAH_src__ = 'books_by_author.tmpl'
42 __CHEETAH_srcLastModified__ = 'Fri May 25 04:52:59 2018'
43 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
44
45 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
46     raise AssertionError(
47       'This template was compiled with Cheetah version'
48       ' %s. Templates compiled before version %s must be recompiled.'%(
49          __CHEETAH_version__, RequiredCheetahVersion))
50
51 ##################################################
52 ## CLASSES
53
54 class books_by_author(layout):
55
56     ##################################################
57     ## CHEETAH GENERATED METHODS
58
59
60     def __init__(self, *args, **KWs):
61
62         super(books_by_author, self).__init__(*args, **KWs)
63         if not self._CHEETAH__instanceInitialized:
64             cheetahKWArgs = {}
65             allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
66             for k,v in KWs.items():
67                 if k in allowedKWs: cheetahKWArgs[k] = v
68             self._initCheetahInstance(**cheetahKWArgs)
69         
70
71     def body(self, **KWS):
72
73
74
75         ## CHEETAH: generated from #def body at line 5, col 1.
76         trans = KWS.get("trans")
77         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
78             trans = self.transaction # is None unless self.awake() was called
79         if not trans:
80             trans = DummyTransaction()
81             _dummyTrans = True
82         else: _dummyTrans = False
83         write = trans.response().write
84         SL = self._CHEETAH__searchList
85         _filter = self._CHEETAH__currentFilter
86         
87         ########################################
88         ## START - generated method body
89         
90         write(u'''<h1>''')
91         _v = VFFSL(SL,"title",True) # u'$title' on line 6, col 5
92         if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 6, col 5.
93         write(u''' ''')
94         _v = VFFSL(SL,"author.fullname",True) # u'$author.fullname' on line 6, col 12
95         if _v is not None: write(_filter(_v, rawExpr=u'$author.fullname')) # from line 6, col 12.
96         write(u'''</h1>
97
98 ''')
99         if VFFSL(SL,"books",True): # generated from line 8, col 1
100             write(u'''  <form action="" method="POST" style="height: 80%">
101   <select multiple style="height: 90%">
102 ''')
103             series = None
104             for book in VFFSL(SL,"books",True): # generated from line 12, col 3
105                 if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 13, col 3
106                     if VFFSL(SL,"series",True) is not None: # generated from line 14, col 3
107                         write(u'''  </optgroup>
108 ''')
109                     series = VFFSL(SL,"book.series",True)
110                     write(u'''  <optgroup label="''')
111                     if VFFSL(SL,"book.series",True): # generated from line 19, col 3
112                         _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 20, col 1
113                         if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 20, col 1.
114                     else: # generated from line 21, col 3
115                         write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
116                     write(u'''">
117 ''')
118                 write(u'''  <option value="''')
119                 _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 26, col 18
120                 if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 26, col 18.
121                 write(u'''">''')
122                 _v = VFFSL(SL,"book.ser_no",True) # u'$book.ser_no' on line 26, col 28
123                 if _v is not None: write(_filter(_v, rawExpr=u'$book.ser_no')) # from line 26, col 28.
124                 write(u''' ''')
125                 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"book.title",True)) # u'$cgi.escape($book.title)' on line 26, col 41
126                 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($book.title)')) # from line 26, col 41.
127                 write(u'''</option>
128 ''')
129             write(u'''  </optgroup>
130   </select>
131   </form>
132 ''')
133         else: # generated from line 31, col 1
134             write(u'''  <p>\u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438!</p>
135 ''')
136         
137         ########################################
138         ## END - generated method body
139         
140         return _dummyTrans and trans.response().getvalue() or ""
141         
142
143     def writeBody(self, **KWS):
144
145
146
147         ## CHEETAH: main method generated for this template
148         trans = KWS.get("trans")
149         if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
150             trans = self.transaction # is None unless self.awake() was called
151         if not trans:
152             trans = DummyTransaction()
153             _dummyTrans = True
154         else: _dummyTrans = False
155         write = trans.response().write
156         SL = self._CHEETAH__searchList
157         _filter = self._CHEETAH__currentFilter
158         
159         ########################################
160         ## START - generated method body
161         
162         
163         ########################################
164         ## END - generated method body
165         
166         return _dummyTrans and trans.response().getvalue() or ""
167         
168     ##################################################
169     ## CHEETAH GENERATED ATTRIBUTES
170
171
172     _CHEETAH__instanceInitialized = False
173
174     _CHEETAH_version = __CHEETAH_version__
175
176     _CHEETAH_versionTuple = __CHEETAH_versionTuple__
177
178     _CHEETAH_genTime = __CHEETAH_genTime__
179
180     _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
181
182     _CHEETAH_src = __CHEETAH_src__
183
184     _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
185
186     title = 'Список книг автора'
187
188     _mainCheetahMethod_for_books_by_author = 'writeBody'
189
190 ## END CLASS DEFINITION
191
192 if not hasattr(books_by_author, '_initCheetahAttributes'):
193     templateAPIClass = getattr(books_by_author,
194                                '_CHEETAH_templateClass',
195                                Template)
196     templateAPIClass._addCheetahPlumbingCodeToClass(books_by_author)
197
198
199 # CHEETAH was developed by Tavis Rudd and Mike Orr
200 # with code, advice and input from many other volunteers.
201 # For more information visit http://cheetahtemplate.org/
202
203 ##################################################
204 ## if run from command line:
205 if __name__ == '__main__':
206     from Cheetah.TemplateCmdLineIface import CmdLineIface
207     CmdLineIface(templateObj=books_by_author()).run()
208
209