2 # -*- coding: utf-8 -*-
7 ##################################################
13 import builtins as builtin
15 import __builtin__ as builtin
16 from os.path import getmtime, exists
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
29 from m_librarian.translations import translations
30 from views.layout import layout
32 ##################################################
34 VFFSL=valueFromFrameOrSearchList
35 VFSL=valueFromSearchList
38 __CHEETAH_version__ = '3.1.0'
39 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
40 __CHEETAH_genTime__ = 1528718535.673384
41 __CHEETAH_genTimestamp__ = 'Mon Jun 11 15:02:15 2018'
42 __CHEETAH_src__ = 'list_books.tmpl'
43 __CHEETAH_srcLastModified__ = 'Mon Jun 11 15:02:00 2018'
44 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
46 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
48 'This template was compiled with Cheetah version'
49 ' %s. Templates compiled before version %s must be recompiled.'%(
50 __CHEETAH_version__, RequiredCheetahVersion))
52 ##################################################
55 class list_books(layout):
57 ##################################################
58 ## CHEETAH GENERATED METHODS
61 def __init__(self, *args, **KWs):
63 super(list_books, self).__init__(*args, **KWs)
64 if not self._CHEETAH__instanceInitialized:
66 allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
67 for k,v in KWs.items():
68 if k in allowedKWs: cheetahKWArgs[k] = v
69 self._initCheetahInstance(**cheetahKWArgs)
72 def body(self, **KWS):
76 ## CHEETAH: generated from #def body at line 6, col 1.
77 trans = KWS.get("trans")
78 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
79 trans = self.transaction # is None unless self.awake() was called
81 trans = DummyTransaction()
83 else: _dummyTrans = False
84 write = trans.response().write
85 SL = self._CHEETAH__searchList
86 _filter = self._CHEETAH__currentFilter
88 ########################################
89 ## START - generated method body
92 _v = VFFSL(SL,"title",True) # u'$title' on line 7, col 5
93 if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 7, col 5.
97 if VFFSL(SL,"books_by_author",True): # generated from line 9, col 1
98 write(u''' <form action="/download/" method="POST" style="height: 80%">
99 <table style="width: 100%; height: 90%">
105 _ = VFFSL(SL,"getattr",False)(VFFSL(SL,"translations",True), 'ugettext', None) or VFFSL(SL,"translations.gettext",True)
106 for column in VFFSL(SL,"columns",True): # generated from line 15, col 3
107 write(u''' <td style="text-align: center">''')
109 _(VFFSL(SL,"column",True))
110 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"_",False)(VFFSL(SL,"column",True))) # u'$cgi.escape($_($column))' on line 16, col 36
111 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($_($column))')) # from line 16, col 36.
117 columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
118 for author in VFFSL(SL,"sorted",False)(VFFSL(SL,"books_by_author",True)): # generated from line 21, col 3
119 books = VFFSL(SL,"books_by_author",True)[VFFSL(SL,"author",True)]
120 for book in VFFSL(SL,"books",True): # generated from line 23, col 5
121 if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 24, col 5
122 series = VFFSL(SL,"book.series",True)
125 _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 27, col 16
126 if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 27, col 16.
129 _v = VFFSL(SL,"author",True) # u'$author' on line 28, col 3
130 if _v is not None: write(_filter(_v, rawExpr=u'$author')) # from line 28, col 3.
131 write(u''' \u2014 <i>
133 if VFFSL(SL,"book.series",True): # generated from line 29, col 3
134 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 30, col 1
135 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 30, col 1.
136 else: # generated from line 31, col 3
137 write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
138 write(u''' </i></b></td>
142 <td><input type=checkbox name=books value="''')
143 _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 38, col 46
144 if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 38, col 46.
147 for column in VFFSL(SL,"columns",True): # generated from line 39, col 3
148 if VFFSL(SL,"column",True) == 'ser_no': # generated from line 40, col 3
149 style = ' style="text-align: right; width: 5ex"'
150 else: # generated from line 42, col 3
153 _v = VFFSL(SL,"style",True) # u'$style' on line 45, col 6
154 if _v is not None: write(_filter(_v, rawExpr=u'$style')) # from line 45, col 6.
156 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(unicode(VFFSL(SL,"getattr",False)(VFFSL(SL,"book",True), VFFSL(SL,"column",True)) or '')) # u"$cgi.escape(unicode($getattr($book, $column) or ''))" on line 45, col 13
157 if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 45, col 13.
164 _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 51, col 16
165 if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 51, col 16.
166 write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
171 else: # generated from line 55, col 1
172 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>
175 ########################################
176 ## END - generated method body
178 return _dummyTrans and trans.response().getvalue() or ""
181 def writeBody(self, **KWS):
185 ## CHEETAH: main method generated for this template
186 trans = KWS.get("trans")
187 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
188 trans = self.transaction # is None unless self.awake() was called
190 trans = DummyTransaction()
192 else: _dummyTrans = False
193 write = trans.response().write
194 SL = self._CHEETAH__searchList
195 _filter = self._CHEETAH__currentFilter
197 ########################################
198 ## START - generated method body
201 ########################################
202 ## END - generated method body
204 return _dummyTrans and trans.response().getvalue() or ""
206 ##################################################
207 ## CHEETAH GENERATED ATTRIBUTES
210 _CHEETAH__instanceInitialized = False
212 _CHEETAH_version = __CHEETAH_version__
214 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
216 _CHEETAH_genTime = __CHEETAH_genTime__
218 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
220 _CHEETAH_src = __CHEETAH_src__
222 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
224 title = 'Список книг'
226 _mainCheetahMethod_for_list_books = 'writeBody'
228 ## END CLASS DEFINITION
230 if not hasattr(list_books, '_initCheetahAttributes'):
231 templateAPIClass = getattr(list_books,
232 '_CHEETAH_templateClass',
234 templateAPIClass._addCheetahPlumbingCodeToClass(list_books)
237 # CHEETAH was developed by Tavis Rudd and Mike Orr
238 # with code, advice and input from many other volunteers.
239 # For more information visit http://cheetahtemplate.org/
241 ##################################################
242 ## if run from command line:
243 if __name__ == '__main__':
244 from Cheetah.TemplateCmdLineIface import CmdLineIface
245 CmdLineIface(templateObj=list_books()).run()