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 views.layout import layout
31 ##################################################
33 VFFSL=valueFromFrameOrSearchList
34 VFSL=valueFromSearchList
37 __CHEETAH_version__ = '3.1.0'
38 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
39 __CHEETAH_genTime__ = 1528670845.131662
40 __CHEETAH_genTimestamp__ = 'Mon Jun 11 01:47:25 2018'
41 __CHEETAH_src__ = 'books_by_author.tmpl'
42 __CHEETAH_srcLastModified__ = 'Mon Jun 11 01:47:23 2018'
43 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
45 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
47 'This template was compiled with Cheetah version'
48 ' %s. Templates compiled before version %s must be recompiled.'%(
49 __CHEETAH_version__, RequiredCheetahVersion))
51 ##################################################
54 class books_by_author(layout):
56 ##################################################
57 ## CHEETAH GENERATED METHODS
60 def __init__(self, *args, **KWs):
62 super(books_by_author, self).__init__(*args, **KWs)
63 if not self._CHEETAH__instanceInitialized:
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)
71 def body(self, **KWS):
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
80 trans = DummyTransaction()
82 else: _dummyTrans = False
83 write = trans.response().write
84 SL = self._CHEETAH__searchList
85 _filter = self._CHEETAH__currentFilter
87 ########################################
88 ## START - generated method body
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.
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.
99 if VFFSL(SL,"books",True): # generated from line 8, col 1
100 write(u''' <form action="/download/" method="POST" style="height: 80%">
101 <table style="width: 100%; height: 90%">
104 columns1 = VFFSL(SL,"len",False)(VFFSL(SL,"columns",True))+1
105 for book in VFFSL(SL,"books",True): # generated from line 13, col 3
106 if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 14, col 3
107 series = VFFSL(SL,"book.series",True)
110 _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 17, col 16
111 if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 17, col 16.
114 if VFFSL(SL,"book.series",True): # generated from line 18, col 3
115 _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 19, col 1
116 if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 19, col 1.
117 else: # generated from line 20, col 3
118 write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
119 write(u''' </i></b></td>
123 <td><input type=checkbox name=books value="''')
124 _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 27, col 46
125 if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 27, col 46.
128 for column in VFFSL(SL,"columns",True): # generated from line 28, col 3
130 _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 29, col 7
131 if _v is not None: write(_filter(_v, rawExpr=u"$cgi.escape(unicode($getattr($book, $column) or ''))")) # from line 29, col 7.
138 _v = VFFSL(SL,"columns1",True) # u'$columns1' on line 34, col 16
139 if _v is not None: write(_filter(_v, rawExpr=u'$columns1')) # from line 34, col 16.
140 write(u'''" style="text-align: center"><input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c"></td>
145 else: # generated from line 38, col 1
146 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>
149 ########################################
150 ## END - generated method body
152 return _dummyTrans and trans.response().getvalue() or ""
155 def writeBody(self, **KWS):
159 ## CHEETAH: main method generated for this template
160 trans = KWS.get("trans")
161 if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
162 trans = self.transaction # is None unless self.awake() was called
164 trans = DummyTransaction()
166 else: _dummyTrans = False
167 write = trans.response().write
168 SL = self._CHEETAH__searchList
169 _filter = self._CHEETAH__currentFilter
171 ########################################
172 ## START - generated method body
175 ########################################
176 ## END - generated method body
178 return _dummyTrans and trans.response().getvalue() or ""
180 ##################################################
181 ## CHEETAH GENERATED ATTRIBUTES
184 _CHEETAH__instanceInitialized = False
186 _CHEETAH_version = __CHEETAH_version__
188 _CHEETAH_versionTuple = __CHEETAH_versionTuple__
190 _CHEETAH_genTime = __CHEETAH_genTime__
192 _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
194 _CHEETAH_src = __CHEETAH_src__
196 _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
198 title = 'Список книг автора'
200 _mainCheetahMethod_for_books_by_author = 'writeBody'
202 ## END CLASS DEFINITION
204 if not hasattr(books_by_author, '_initCheetahAttributes'):
205 templateAPIClass = getattr(books_by_author,
206 '_CHEETAH_templateClass',
208 templateAPIClass._addCheetahPlumbingCodeToClass(books_by_author)
211 # CHEETAH was developed by Tavis Rudd and Mike Orr
212 # with code, advice and input from many other volunteers.
213 # For more information visit http://cheetahtemplate.org/
215 ##################################################
216 ## if run from command line:
217 if __name__ == '__main__':
218 from Cheetah.TemplateCmdLineIface import CmdLineIface
219 CmdLineIface(templateObj=books_by_author()).run()