Trees | Indices | Help |
---|
|
1 # $Id: new.py,v 1.8 2007/01/06 08:03:21 lmacken Exp $ 2 # 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; version 2 of the License. 6 # 7 # This program is distributed in the hope that it will be useful, 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # GNU Library General Public License for more details. 11 # 12 # You should have received a copy of the GNU General Public License 13 # along with this program; if not, write to the Free Software 14 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 16 import logging 17 18 from sqlobject.sqlbuilder import LIKE 19 from turbogears import (expose, identity, paginate, validate, validators, 20 redirect, error_handler, url) 21 from turbogears.controllers import Controller 22 23 from bodhi.model import PackageUpdate, Bugzilla, CVE 24 from bodhi.widgets import SearchForm 25 26 log = logging.getLogger(__name__) 27 28 search_form = SearchForm() 2931 32 @identity.require(identity.not_anonymous()) 33 @expose(template="bodhi.templates.form")6635 if tg_errors: 36 flash(tg_errors) 37 if search: 38 raise redirect('/search/%s' % search) 39 return dict(form=search_form, values={}, action=url('/search/'))40 41 @expose(template="bodhi.templates.list") 42 @identity.require(identity.not_anonymous()) 43 @validate(validators={ "search" : validators.UnicodeString() }) 44 @error_handler(index) 45 @paginate('updates', default_order='update_id', limit=15)47 results = set() 48 49 # Search name-version-release 50 map(results.add, PackageUpdate.select(LIKE(PackageUpdate.q.title, 51 '%%%s%%' % search))) 52 53 # Search bug numbers 54 try: 55 map(lambda bug: map(results.add, bug.updates), 56 Bugzilla.select(Bugzilla.q.bz_id==int(search))) 57 except ValueError: # can't convert search search to integer 58 pass 59 60 # Search CVE's 61 if search.startswith('CVE') or search.startswith('CAN'): 62 map(lambda cve: map(results.add, cve.updates), 63 CVE.select(CVE.q.cve_id==search)) 64 65 return dict(updates=list(results), num_items=len(results))
Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Sun Sep 23 14:46:39 2007 | http://epydoc.sourceforge.net |