/[gentoo]/src/packages/query_package.py
Gentoo

Diff of /src/packages/query_package.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.4 Revision 1.5
1#!/usr/bin/python -OO 1#!/usr/bin/python -O
2 2
3import cgi 3import cgi
4from urllib import quote 4from urllib import quote
5import os 5import os
6import sys 6import sys
41 'FROM package WHERE category="%s"' % escape_string(category)) 41 'FROM package WHERE category="%s"' % escape_string(category))
42 42
43if name: 43if name:
44 query = ('%s AND name="%s"' %(query,escape_string(name))) 44 query = ('%s AND name="%s"' %(query,escape_string(name)))
45 45
46# first get row count
47db = ebuilddb.db_connect()
48c = db.cursor()
49c.execute(query)
50total_rows = c.rowcount
51
46query = ('%s LIMIT %s,%s' % (query,offset,config.MAX_CATEGORIES)) 52query = ('%s LIMIT %s,%s' % (query,offset,config.MAX_CATEGORIES))
47 53
48db = ebuilddb.db_connect()
49c = db.cursor()
50c.execute(query) 54c.execute(query)
51results = c.fetchall() 55results = c.fetchall()
52 56
53#print query 57#print query
54if results: 58if results:
55 if name: 59 if name:
56 for result in results: 60 for result in results:
57 #print result 61 #print result
58 pkg = query_to_dict(result) 62 pkg = query_to_dict(result)
59 sys.stdout.write('%s<br>\n<br>\n' 63 sys.stdout.write('%s<br>\n<br>\n'
60 % gentoo.package_to_html(pkg,db)) 64 % gentoo.package_to_html(pkg,db, full=True))
61 else: 65 else:
62 sys.stdout.write('<table class="centerpage">\n') 66 sys.stdout.write('<table class="centerpage">\n')
63 sys.stdout.write('<tr><th class="category">' 67 sys.stdout.write('<tr><th class="category">'
64 '%s</th></tr>\n<tr><td>' % category) 68 '%s</th></tr>\n<tr><td>' % category)
65 for result in results: 69 for result in results:
68 sys.stdout.write('</td></tr></table>\n') 72 sys.stdout.write('</td></tr></table>\n')
69 if offset !="0": 73 if offset !="0":
70 sys.stdout.write('<a href="?category=%s;name=%s' 74 sys.stdout.write('<a href="?category=%s;name=%s'
71 ';offset=%s">[Previous]</a> ' 75 ';offset=%s">[Previous]</a> '
72 % (category,name,int(offset) - config.MAX_CATEGORIES)) 76 % (category,name,int(offset) - config.MAX_CATEGORIES))
73 if len(results) == config.MAX_CATEGORIES: 77 if int(offset) + len(results) < total_rows:
74 sys.stdout.write('<a href="?category=%s;name=%s;offset=%s">[Next]</a> ' 78 sys.stdout.write('<a href="?category=%s;name=%s;offset=%s">[Next]</a> '
75 % (category,name,int(offset) + config.MAX_CATEGORIES)) 79 % (category,name,int(offset) + config.MAX_CATEGORIES))
76 80
77else: 81else:
78 sys.stdout.write('<div class="centerpage">\n' 82 sys.stdout.write('<div class="centerpage">\n'

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.20