]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(web:books): Поиск по названиям книг
authorOleg Broytman <phd@phdru.name>
Sat, 26 May 2018 17:20:20 +0000 (20:20 +0300)
committerOleg Broytman <phd@phdru.name>
Sat, 26 May 2018 17:22:49 +0000 (20:22 +0300)
docs-ru/news.rst
docs/news.rst
m_librarian/web/app.py
m_librarian/web/views/index.py
m_librarian/web/views/index.tmpl
m_librarian/web/views/list_books.py [new file with mode: 0644]
m_librarian/web/views/list_books.tmpl [new file with mode: 0644]
m_librarian/web/views/search_books.py [new file with mode: 0644]
m_librarian/web/views/search_books.tmpl [new file with mode: 0644]
m_librarian/web/views/search_books_form.py [new file with mode: 0644]
m_librarian/web/views/search_books_form.tmpl [new file with mode: 0644]

index 7bece3f00cea59c59939a6fe1c66389df288ba75..79f244705cc3836dc45e28d24cc11ff8b365411b 100644 (file)
@@ -1,6 +1,11 @@
 Новости
 =======
 
+Version 0.1.4 (2018-05-??)
+--------------------------
+
+* Поиск по названиям книг.
+
 Version 0.1.3 (2018-05-25)
 --------------------------
 
index 066f20853a042b33d641c0db94142f71ff7897a4..d28346e358b8284c211d4ba7c3a7748771ecdd20 100644 (file)
@@ -1,6 +1,11 @@
 News
 ====
 
+Version 0.1.4 (2018-05-??)
+--------------------------
+
+* Search by book's title.
+
 Version 0.1.3 (2018-05-25)
 --------------------------
 
index 2296d277bbe17f85d174e49615673176ecb484ae..19fca6c4254076abb46c3b6c23c66f54656de2c7 100644 (file)
@@ -8,7 +8,7 @@ from bottle import cheetah_view, redirect, request, route, static_file
 from m_librarian.config import get_config
 from m_librarian.db import Author, Book
 from m_librarian.download import download
-from m_librarian.search import search_authors
+from m_librarian.search import search_authors, search_books
 
 
 @route('/')
@@ -103,3 +103,37 @@ def download_books():
         return {
             'message': u'Не выбрано книг для сохранения.',
         }
+
+
+@route('/search_books', method='GET')
+def _search_books():
+    return redirect('/search_books/')
+
+
+@route('/search_books/', method='GET')
+@cheetah_view('search_books.tmpl')
+def search_books_get():
+    return {}
+
+
+@route('/search_books/', method='POST')
+@cheetah_view('list_books.tmpl')
+def search_books_post():
+    value = request.forms.get('search_books')
+    if not value:
+        return redirect('/search_books/')
+    value = decode(value)
+    search_type = request.forms.get('search_type')
+    if not search_type:
+        search_type = 'start'
+    case_sensitive = request.forms.get('case_sensitive')
+    if case_sensitive is None:
+        case_sensitive = _guess_case_sensitivity(value)
+    books = search_books(search_type, case_sensitive, {'title': value}, None,
+                         orderBy=('title',))
+    return {
+        'books': list(books),
+        'search_books': value,
+        'search_type': search_type,
+        'case_sensitive': case_sensitive,
+    }
index e039c2a5c2e82ad45f9ec393bc536e21e0576588..e066e53903a503b04f4006f865c9eadcd5b204c9 100644 (file)
@@ -27,6 +27,7 @@ import Cheetah.ErrorCatchers as ErrorCatchers
 from Cheetah.compat import unicode
 from views.layout import layout
 from views.search_authors_form import search_authors_form
+from views.search_books_form import search_books_form
 
 ##################################################
 ## MODULE CONSTANTS
@@ -36,10 +37,10 @@ VFN=valueForName
 currentTime=time.time
 __CHEETAH_version__ = '3.1.0'
 __CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
-__CHEETAH_genTime__ = 1522961823.924543
-__CHEETAH_genTimestamp__ = 'Thu Apr  5 23:57:03 2018'
+__CHEETAH_genTime__ = 1527354191.441549
+__CHEETAH_genTimestamp__ = 'Sat May 26 20:03:11 2018'
 __CHEETAH_src__ = 'index.tmpl'
-__CHEETAH_srcLastModified__ = 'Thu Apr  5 23:54:01 2018'
+__CHEETAH_srcLastModified__ = 'Sat May 26 20:03:09 2018'
 __CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -93,6 +94,13 @@ class index(layout):
         _v = VFFSL(SL,"search_authors_form",False)(searchList=VFFSL(SL,"searchList",True)) # u'$search_authors_form(searchList=$searchList)' on line 8, col 1
         if _v is not None: write(_filter(_v, rawExpr=u'$search_authors_form(searchList=$searchList)')) # from line 8, col 1.
         write(u'''
+
+<h1>\u041f\u043e\u0438\u0441\u043a \u043a\u043d\u0438\u0433</h1>
+
+''')
+        _v = VFFSL(SL,"search_books_form",False)(searchList=VFFSL(SL,"searchList",True)) # u'$search_books_form(searchList=$searchList)' on line 13, col 1
+        if _v is not None: write(_filter(_v, rawExpr=u'$search_books_form(searchList=$searchList)')) # from line 13, col 1.
+        write(u'''
 ''')
         
         ########################################
index f8be6c70b4a751a3bfab8f4fe8821bbf634b64c8..a16ff1a06c5278114b8d67105caeca4b7f37713f 100644 (file)
@@ -6,4 +6,9 @@
 
 #from views.search_authors_form import search_authors_form
 $search_authors_form(searchList=$searchList)
+
+<h1>Поиск книг</h1>
+
+#from views.search_books_form import search_books_form
+$search_books_form(searchList=$searchList)
 #end def
diff --git a/m_librarian/web/views/list_books.py b/m_librarian/web/views/list_books.py
new file mode 100644 (file)
index 0000000..73af92b
--- /dev/null
@@ -0,0 +1,211 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+
+
+##################################################
+## DEPENDENCIES
+import sys
+import os
+import os.path
+try:
+    import builtins as builtin
+except ImportError:
+    import __builtin__ as builtin
+from os.path import getmtime, exists
+import time
+import types
+from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
+from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
+from Cheetah.Template import Template
+from Cheetah.DummyTransaction import *
+from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
+from Cheetah.CacheRegion import CacheRegion
+import Cheetah.Filters as Filters
+import Cheetah.ErrorCatchers as ErrorCatchers
+from Cheetah.compat import unicode
+import cgi
+from views.layout import layout
+
+##################################################
+## MODULE CONSTANTS
+VFFSL=valueFromFrameOrSearchList
+VFSL=valueFromSearchList
+VFN=valueForName
+currentTime=time.time
+__CHEETAH_version__ = '3.1.0'
+__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
+__CHEETAH_genTime__ = 1527354802.495612
+__CHEETAH_genTimestamp__ = 'Sat May 26 20:13:22 2018'
+__CHEETAH_src__ = 'list_books.tmpl'
+__CHEETAH_srcLastModified__ = 'Sat May 26 20:13:18 2018'
+__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
+
+if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
+    raise AssertionError(
+      'This template was compiled with Cheetah version'
+      ' %s. Templates compiled before version %s must be recompiled.'%(
+         __CHEETAH_version__, RequiredCheetahVersion))
+
+##################################################
+## CLASSES
+
+class list_books(layout):
+
+    ##################################################
+    ## CHEETAH GENERATED METHODS
+
+
+    def __init__(self, *args, **KWs):
+
+        super(list_books, self).__init__(*args, **KWs)
+        if not self._CHEETAH__instanceInitialized:
+            cheetahKWArgs = {}
+            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
+            for k,v in KWs.items():
+                if k in allowedKWs: cheetahKWArgs[k] = v
+            self._initCheetahInstance(**cheetahKWArgs)
+        
+
+    def body(self, **KWS):
+
+
+
+        ## CHEETAH: generated from #def body at line 5, col 1.
+        trans = KWS.get("trans")
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        write(u'''<h1>''')
+        _v = VFFSL(SL,"title",True) # u'$title' on line 6, col 5
+        if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 6, col 5.
+        write(u'''</h1>
+
+''')
+        if VFFSL(SL,"books",True): # generated from line 8, col 1
+            write(u'''  <form action="/download/" method="POST" style="height: 80%">
+  <div style="width: 100%; height: 90%">
+  <select multiple name="books" style="height: 100%">
+''')
+            series = None
+            for book in VFFSL(SL,"books",True): # generated from line 13, col 3
+                if VFFSL(SL,"book.series",True) != VFFSL(SL,"series",True): # generated from line 14, col 3
+                    if VFFSL(SL,"series",True) is not None: # generated from line 15, col 3
+                        write(u'''  </optgroup>
+''')
+                    series = VFFSL(SL,"book.series",True)
+                    write(u'''  <optgroup label="''')
+                    if VFFSL(SL,"book.series",True): # generated from line 20, col 3
+                        _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"series",True), 1) # u'$cgi.escape($series, 1)' on line 21, col 1
+                        if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($series, 1)')) # from line 21, col 1.
+                    else: # generated from line 22, col 3
+                        write(u'''\u0412\u043d\u0435 \u0441\u0435\u0440\u0438\u0439''')
+                    write(u'''">
+''')
+                write(u'''  <option value="''')
+                _v = VFFSL(SL,"book.id",True) # u'$book.id' on line 27, col 18
+                if _v is not None: write(_filter(_v, rawExpr=u'$book.id')) # from line 27, col 18.
+                write(u'''">''')
+                _v = VFFSL(SL,"book.ser_no",True) # u'$book.ser_no' on line 27, col 28
+                if _v is not None: write(_filter(_v, rawExpr=u'$book.ser_no')) # from line 27, col 28.
+                write(u''' ''')
+                _v = VFN(VFFSL(SL,"cgi",True),"escape",False)(VFFSL(SL,"book.title",True)) # u'$cgi.escape($book.title)' on line 27, col 41
+                if _v is not None: write(_filter(_v, rawExpr=u'$cgi.escape($book.title)')) # from line 27, col 41.
+                write(u'''</option>
+''')
+            write(u'''  </optgroup>
+  </select>
+  </div>
+  <div style="width: 100%; text-align: center">
+  <input type="submit" value="\u0421\u043a\u0430\u0447\u0430\u0442\u044c">
+  </div>
+  </form>
+''')
+        else: # generated from line 36, col 1
+            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>
+''')
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+
+    def writeBody(self, **KWS):
+
+
+
+        ## CHEETAH: main method generated for this template
+        trans = KWS.get("trans")
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+    ##################################################
+    ## CHEETAH GENERATED ATTRIBUTES
+
+
+    _CHEETAH__instanceInitialized = False
+
+    _CHEETAH_version = __CHEETAH_version__
+
+    _CHEETAH_versionTuple = __CHEETAH_versionTuple__
+
+    _CHEETAH_genTime = __CHEETAH_genTime__
+
+    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
+
+    _CHEETAH_src = __CHEETAH_src__
+
+    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
+
+    title = 'Список книг'
+
+    _mainCheetahMethod_for_list_books = 'writeBody'
+
+## END CLASS DEFINITION
+
+if not hasattr(list_books, '_initCheetahAttributes'):
+    templateAPIClass = getattr(list_books,
+                               '_CHEETAH_templateClass',
+                               Template)
+    templateAPIClass._addCheetahPlumbingCodeToClass(list_books)
+
+
+# CHEETAH was developed by Tavis Rudd and Mike Orr
+# with code, advice and input from many other volunteers.
+# For more information visit http://cheetahtemplate.org/
+
+##################################################
+## if run from command line:
+if __name__ == '__main__':
+    from Cheetah.TemplateCmdLineIface import CmdLineIface
+    CmdLineIface(templateObj=list_books()).run()
+
+
diff --git a/m_librarian/web/views/list_books.tmpl b/m_librarian/web/views/list_books.tmpl
new file mode 100644 (file)
index 0000000..9566e89
--- /dev/null
@@ -0,0 +1,39 @@
+#encoding utf-8
+#import cgi
+#extends views.layout
+#attr $title = 'Список книг'
+#def body
+<h1>$title</h1>
+
+#if $books
+  <form action="/download/" method="POST" style="height: 80%">
+  <div style="width: 100%; height: 90%">
+  <select multiple name="books" style="height: 100%">
+  #set $series = None
+  #for $book in $books
+  #if $book.series != $series
+  #if $series is not None
+  </optgroup>
+  #end if
+  #set $series = $book.series
+  <optgroup label="#slurp
+  #if $book.series
+$cgi.escape($series, 1)#slurp
+  #else
+Вне серий#slurp
+  #end if
+">
+  #end if
+  <option value="$book.id">$book.ser_no $cgi.escape($book.title)</option>
+  #end for
+  </optgroup>
+  </select>
+  </div>
+  <div style="width: 100%; text-align: center">
+  <input type="submit" value="Скачать">
+  </div>
+  </form>
+#else
+  <p>Не найдено ни одной книги!</p>
+#end if
+#end def
diff --git a/m_librarian/web/views/search_books.py b/m_librarian/web/views/search_books.py
new file mode 100644 (file)
index 0000000..2e8636b
--- /dev/null
@@ -0,0 +1,173 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+
+
+##################################################
+## DEPENDENCIES
+import sys
+import os
+import os.path
+try:
+    import builtins as builtin
+except ImportError:
+    import __builtin__ as builtin
+from os.path import getmtime, exists
+import time
+import types
+from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
+from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
+from Cheetah.Template import Template
+from Cheetah.DummyTransaction import *
+from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
+from Cheetah.CacheRegion import CacheRegion
+import Cheetah.Filters as Filters
+import Cheetah.ErrorCatchers as ErrorCatchers
+from Cheetah.compat import unicode
+from views.layout import layout
+from views.search_books_form import search_books_form
+
+##################################################
+## MODULE CONSTANTS
+VFFSL=valueFromFrameOrSearchList
+VFSL=valueFromSearchList
+VFN=valueForName
+currentTime=time.time
+__CHEETAH_version__ = '3.1.0'
+__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
+__CHEETAH_genTime__ = 1527354048.738532
+__CHEETAH_genTimestamp__ = 'Sat May 26 20:00:48 2018'
+__CHEETAH_src__ = 'search_books.tmpl'
+__CHEETAH_srcLastModified__ = 'Sat May 26 19:59:55 2018'
+__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
+
+if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
+    raise AssertionError(
+      'This template was compiled with Cheetah version'
+      ' %s. Templates compiled before version %s must be recompiled.'%(
+         __CHEETAH_version__, RequiredCheetahVersion))
+
+##################################################
+## CLASSES
+
+class search_books(layout):
+
+    ##################################################
+    ## CHEETAH GENERATED METHODS
+
+
+    def __init__(self, *args, **KWs):
+
+        super(search_books, self).__init__(*args, **KWs)
+        if not self._CHEETAH__instanceInitialized:
+            cheetahKWArgs = {}
+            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
+            for k,v in KWs.items():
+                if k in allowedKWs: cheetahKWArgs[k] = v
+            self._initCheetahInstance(**cheetahKWArgs)
+        
+
+    def body(self, **KWS):
+
+
+
+        ## CHEETAH: generated from #def body at line 4, col 1.
+        trans = KWS.get("trans")
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        write(u'''<h1>''')
+        _v = VFFSL(SL,"title",True) # u'$title' on line 5, col 5
+        if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 5, col 5.
+        write(u'''</h1>
+
+''')
+        _v = VFFSL(SL,"search_books_form",False)(searchList=VFFSL(SL,"searchList",True)) # u'$search_books_form(searchList=$searchList)' on line 8, col 1
+        if _v is not None: write(_filter(_v, rawExpr=u'$search_books_form(searchList=$searchList)')) # from line 8, col 1.
+        write(u'''
+''')
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+
+    def writeBody(self, **KWS):
+
+
+
+        ## CHEETAH: main method generated for this template
+        trans = KWS.get("trans")
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+    ##################################################
+    ## CHEETAH GENERATED ATTRIBUTES
+
+
+    _CHEETAH__instanceInitialized = False
+
+    _CHEETAH_version = __CHEETAH_version__
+
+    _CHEETAH_versionTuple = __CHEETAH_versionTuple__
+
+    _CHEETAH_genTime = __CHEETAH_genTime__
+
+    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
+
+    _CHEETAH_src = __CHEETAH_src__
+
+    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
+
+    title = 'Поиск книг'
+
+    _mainCheetahMethod_for_search_books = 'writeBody'
+
+## END CLASS DEFINITION
+
+if not hasattr(search_books, '_initCheetahAttributes'):
+    templateAPIClass = getattr(search_books,
+                               '_CHEETAH_templateClass',
+                               Template)
+    templateAPIClass._addCheetahPlumbingCodeToClass(search_books)
+
+
+# CHEETAH was developed by Tavis Rudd and Mike Orr
+# with code, advice and input from many other volunteers.
+# For more information visit http://cheetahtemplate.org/
+
+##################################################
+## if run from command line:
+if __name__ == '__main__':
+    from Cheetah.TemplateCmdLineIface import CmdLineIface
+    CmdLineIface(templateObj=search_books()).run()
+
+
diff --git a/m_librarian/web/views/search_books.tmpl b/m_librarian/web/views/search_books.tmpl
new file mode 100644 (file)
index 0000000..0446d8f
--- /dev/null
@@ -0,0 +1,9 @@
+#encoding utf-8
+#extends views.layout
+#attr $title = 'Поиск книг'
+#def body
+<h1>$title</h1>
+
+#from views.search_books_form import search_books_form
+$search_books_form(searchList=$searchList)
+#end def
diff --git a/m_librarian/web/views/search_books_form.py b/m_librarian/web/views/search_books_form.py
new file mode 100644 (file)
index 0000000..74b4c58
--- /dev/null
@@ -0,0 +1,224 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+
+
+##################################################
+## DEPENDENCIES
+import sys
+import os
+import os.path
+try:
+    import builtins as builtin
+except ImportError:
+    import __builtin__ as builtin
+from os.path import getmtime, exists
+import time
+import types
+from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
+from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
+from Cheetah.Template import Template
+from Cheetah.DummyTransaction import *
+from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
+from Cheetah.CacheRegion import CacheRegion
+import Cheetah.Filters as Filters
+import Cheetah.ErrorCatchers as ErrorCatchers
+from Cheetah.compat import unicode
+from bottle import html_escape
+
+##################################################
+## MODULE CONSTANTS
+VFFSL=valueFromFrameOrSearchList
+VFSL=valueFromSearchList
+VFN=valueForName
+currentTime=time.time
+__CHEETAH_version__ = '3.1.0'
+__CHEETAH_versionTuple__ = (3, 1, 0, 'final', 1)
+__CHEETAH_genTime__ = 1527354048.844765
+__CHEETAH_genTimestamp__ = 'Sat May 26 20:00:48 2018'
+__CHEETAH_src__ = 'search_books_form.tmpl'
+__CHEETAH_srcLastModified__ = 'Sat May 26 20:00:32 2018'
+__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'
+
+if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
+    raise AssertionError(
+      'This template was compiled with Cheetah version'
+      ' %s. Templates compiled before version %s must be recompiled.'%(
+         __CHEETAH_version__, RequiredCheetahVersion))
+
+##################################################
+## CLASSES
+
+class search_books_form(Template):
+
+    ##################################################
+    ## CHEETAH GENERATED METHODS
+
+
+    def __init__(self, *args, **KWs):
+
+        super(search_books_form, self).__init__(*args, **KWs)
+        if not self._CHEETAH__instanceInitialized:
+            cheetahKWArgs = {}
+            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
+            for k,v in KWs.items():
+                if k in allowedKWs: cheetahKWArgs[k] = v
+            self._initCheetahInstance(**cheetahKWArgs)
+        
+
+    def search_type_checked(self, value, **KWS):
+
+
+
+        ## CHEETAH: generated from #def $search_type_checked($value) at line 3, col 1.
+        trans = KWS.get("trans")
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        if VFFSL(SL,"getVar",False)('search_type', '') == VFFSL(SL,"value",True): # generated from line 4, col 1
+            write(u'''checked''')
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+
+    def case_sensitive_checked(self, **KWS):
+
+
+
+        ## CHEETAH: generated from #def $case_sensitive_checked at line 8, col 1.
+        trans = KWS.get("trans")
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        if VFFSL(SL,"getVar",False)('case_sensitive', None): # generated from line 9, col 1
+            write(u'''checked''')
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+
+    def respond(self, trans=None):
+
+
+
+        ## CHEETAH: main method generated for this template
+        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+            trans = self.transaction # is None unless self.awake() was called
+        if not trans:
+            trans = DummyTransaction()
+            _dummyTrans = True
+        else: _dummyTrans = False
+        write = trans.response().write
+        SL = self._CHEETAH__searchList
+        _filter = self._CHEETAH__currentFilter
+        
+        ########################################
+        ## START - generated method body
+        
+        write(u'''<form action="/search_books/" method="POST">
+  <div style="width: 100%">
+  <input name="search_books" value="''')
+        _v = VFFSL(SL,"html_escape",False)(VFFSL(SL,"getVar",False)('search_books',
+  ''))
+        if _v is not None: write(_filter(_v, rawExpr=u"$html_escape($getVar('search_books',\n  ''))")) # from line 15, col 37.
+        write(u'''" type="text" style="width: 100%">
+  <br>
+  <input name="search_type" value="start" ''')
+        _v = VFFSL(SL,"search_type_checked",False)('start') # u"$search_type_checked('start')" on line 18, col 43
+        if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('start')")) # from line 18, col 43.
+        write(u''' type="radio">
+  \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435
+  <input name="search_type" value="substring" ''')
+        _v = VFFSL(SL,"search_type_checked",False)('substring') # u"$search_type_checked('substring')" on line 20, col 47
+        if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('substring')")) # from line 20, col 47.
+        write(u''' type="radio">
+  \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430
+  <input name="search_type" value="full" ''')
+        _v = VFFSL(SL,"search_type_checked",False)('full') # u"$search_type_checked('full')" on line 22, col 42
+        if _v is not None: write(_filter(_v, rawExpr=u"$search_type_checked('full')")) # from line 22, col 42.
+        write(u''' type="radio">
+  \u0422\u043e\u0447\u043d\u043e\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435
+  <br>
+  <input name="case_sensitive" type="checkbox" ''')
+        _v = VFFSL(SL,"case_sensitive_checked",True) # u'$case_sensitive_checked' on line 25, col 48
+        if _v is not None: write(_filter(_v, rawExpr=u'$case_sensitive_checked')) # from line 25, col 48.
+        write(u'''>
+  \u0420\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u043f\u0438\u0441\u043d\u044b\u0435/\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435
+  </div>
+  <div style="width: 100%; text-align: center">
+  <input name="submit" type="submit">
+  </div>
+</form>
+''')
+        
+        ########################################
+        ## END - generated method body
+        
+        return _dummyTrans and trans.response().getvalue() or ""
+        
+    ##################################################
+    ## CHEETAH GENERATED ATTRIBUTES
+
+
+    _CHEETAH__instanceInitialized = False
+
+    _CHEETAH_version = __CHEETAH_version__
+
+    _CHEETAH_versionTuple = __CHEETAH_versionTuple__
+
+    _CHEETAH_genTime = __CHEETAH_genTime__
+
+    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
+
+    _CHEETAH_src = __CHEETAH_src__
+
+    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
+
+    _mainCheetahMethod_for_search_books_form = 'respond'
+
+## END CLASS DEFINITION
+
+if not hasattr(search_books_form, '_initCheetahAttributes'):
+    templateAPIClass = getattr(search_books_form,
+                               '_CHEETAH_templateClass',
+                               Template)
+    templateAPIClass._addCheetahPlumbingCodeToClass(search_books_form)
+
+
+# CHEETAH was developed by Tavis Rudd and Mike Orr
+# with code, advice and input from many other volunteers.
+# For more information visit http://cheetahtemplate.org/
+
+##################################################
+## if run from command line:
+if __name__ == '__main__':
+    from Cheetah.TemplateCmdLineIface import CmdLineIface
+    CmdLineIface(templateObj=search_books_form()).run()
+
+
diff --git a/m_librarian/web/views/search_books_form.tmpl b/m_librarian/web/views/search_books_form.tmpl
new file mode 100644 (file)
index 0000000..0f2f667
--- /dev/null
@@ -0,0 +1,31 @@
+#encoding utf-8
+#from bottle import html_escape
+#def $search_type_checked($value)
+#if $getVar('search_type', '') == $value
+checked#slurp
+#end if
+#end def
+#def $case_sensitive_checked
+#if $getVar('case_sensitive', None)
+checked#slurp
+#end if
+#end def
+<form action="/search_books/" method="POST">
+  <div style="width: 100%">
+  <input name="search_books" value="$html_escape($getVar('search_books',
+  ''))" type="text" style="width: 100%">
+  <br>
+  <input name="search_type" value="start" $search_type_checked('start') type="radio">
+  Подстрока в начале
+  <input name="search_type" value="substring" $search_type_checked('substring') type="radio">
+  Подстрока
+  <input name="search_type" value="full" $search_type_checked('full') type="radio">
+  Точное совпадение
+  <br>
+  <input name="case_sensitive" type="checkbox" $case_sensitive_checked>
+  Различать прописные/строчные
+  </div>
+  <div style="width: 100%; text-align: center">
+  <input name="submit" type="submit">
+  </div>
+</form>