Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > SVN: r742 - in trunk/current: src src/db src/web templates

Project highlights: Stable Version: 1.6.1, Development Version: 1.7.6

current
Discussion topic

Back to topic list

SVN: r742 - in trunk/current: src src/db src/web templates

Reply

Author jjneely at EOS dot NCSU dot EDU
Full name jjneely at EOS dot NCSU dot EDU
Date 2005-04-30 14:59:09 PDT
Message Author: jjneely at EOS dot NCSU dot EDU
Date: 2005-04-30 17:59:03 -0400 (Sat, 30 Apr 2005)
New Revision: 742

Added:
   trunk/current/templa​tes/channels.html
   trunk/current/templa​tes/channels.table.h​tml
Removed:
   trunk/current/templa​tes/channels.html
Modified:
   trunk/current/src/cu​rrent_web.py
   trunk/current/src/db​/resultSet.py
   trunk/current/src/db/web.py
   trunk/current/src/we​b/__init__.py
   trunk/current/src/we​b/channels.py
Log:
Move toward my goals for 1.7.2. When you go to

    http://localhost/cur​rent/channels.py

you are presented with a list of Channels in Current. Click on one
to be taken to a page listing all the RPMs in that channel.



Modified: trunk/current/src/cu​rrent_web.py
====================​====================​====================​=======
--- trunk/current/src/cu​rrent_web.py 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/src/cu​rrent_web.py 2005-04-30 21:59:03 UTC (rev 742)
@@ -31,10 +31,9 @@
     mod = file.split('.')[0]
     if mod in web.modules:
         try:
- page = web.modules[mod].WebPage()
- page.setConfig(confi​gure.config)
- page.setSession(sess)
- page.setFieldStorage​(util.FieldStorage(r​eq))
+ page = web.modules[mod].Web​Page(configure.confi​g,
+ sess,
+ util.FieldStorage(req))
             s, ret = page.run()
             sess.save()
             req.write(s)

Modified: trunk/current/src/db​/resultSet.py
====================​====================​====================​=======
--- trunk/current/src/db​/resultSet.py 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/src/db​/resultSet.py 2005-04-30 21:59:03 UTC (rev 742)
@@ -109,3 +109,14 @@
         return self.cursor.rowcount
 
 
+ def dump(self):
+ """Deep copy. Return a list of dicts instead of a resultset.
+ This has the side effect of sucking everything in to python's
+ memory that was returned in this result set."""
+
+ ret = []
+ for row in self:
+ ret.append(row.copy())
+
+ return ret
+

Modified: trunk/current/src/db/web.py
====================​====================​====================​=======
--- trunk/current/src/db/web.py 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/src/db/web.py 2005-04-30 21:59:03 UTC (rev 742)
@@ -37,9 +37,9 @@
     def getChannels(self):
         # Return a dict of information for each channel
         q = "select name, label, description from CHANNEL"
- r = self.cursor.execute(q)
+ self.cursor.execute(q)
 
- return resultSet(r)
+ return resultSet(self.cursor)
         
 
     def getAllPackages(self, channel):
@@ -71,3 +71,11 @@
 
         return resultSet(self.cursor)
 
+
+ def getChannelName(self, label):
+ q = "select name from CHANNEL where label = %s"
+ self.cursor.execute(q, (label,))
+ r = resultSet(self.cursor)
+
+ return r['name']
+

Modified: trunk/current/src/we​b/__init__.py
====================​====================​====================​=======
--- trunk/current/src/we​b/__init__.py 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/src/we​b/__init__.py 2005-04-30 21:59:03 UTC (rev 742)
@@ -1,18 +1,32 @@
+from simpletal import simpleTAL, simpleTALES
 
+import db.web
+import StringIO
+import os.path
+
 class WebPageAbstract(object):
 
     templateDir = None
 
- def setConfig(self, config):
- if not self.templateDir:
- self.templateDir = config['template_dir']
-
- def setSession(self, session):
+ def __init__(self, config, session, fs):
         self.session = session
-
- def setFieldStorage(self, fs):
         self.fields = fs
+ self.templateDir = config['template_dir']
 
+ self.wdb = db.web.WebDB()
+
+
+ def build(self, file, context):
+ f = os.path.join(self.templateDir, file)
+ templateFile = open(f)
+ template = simpleTAL.compileHTM​LTemplate(templateFi​le)
+ templateFile.close()
+ buff = StringIO.StringIO()
+ template.expand(context, buff)
+
+ return buff.getvalue()
+
+
     def run(self):
         return "No Page", 0
 

Modified: trunk/current/src/we​b/channels.py
====================​====================​====================​=======
--- trunk/current/src/we​b/channels.py 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/src/we​b/channels.py 2005-04-30 21:59:03 UTC (rev 742)
@@ -1,37 +1,44 @@
-import os.path
 import sys
-import StringIO
 
 from web import WebPageAbstract
 from simpletal import simpleTAL, simpleTALES
 from logger import *
-import db.web
 
 class WebPage(WebPageAbstract):
 
- def run(self):
+ def listPackages(self, label):
+ name = self.wdb.getChannelName(label)
+ l = self.wdb.getPackages​(label).dump()
 
- wdb = db.web.WebDB()
- r = wdb.getPackages("rawhid")
-
         # Create the context that is used by the template
         context = simpleTALES.Context()
- context.addGlobal("title", "RPMS in rawhid")
+ context.addGlobal("title", "RPMS in channel %s" % name)
 
- # A list that contains a dictionary
- l = []
- for row in r:
- l.append(row.copy())
-
         context.addGlobal("rpm", l)
 
- f = os.path.join(self.templateDir, "channels.html")
- templateFile = open(f)
- template = simpleTAL.compileHTM​LTemplate(templateFi​le)
+ html = self.build("channels​.table.html", context)
 
- templateFile.close()
- buff = StringIO.StringIO()
- template.expand(context, buff)
+ return html, 0
 
- return buff.getvalue(), 0
-
+
+ def listChannels(self):
+ chans = self.wdb.getChannels().dump()
+
+ for c in chans:
+ c['link'] = "channels.py?label=%s" % c['label']
+
+ context = simpleTALES.Context()
+ context.addGlobal("title", "Select Channel")
+ context.addGlobal("channels", chans)
+
+ html = self.build("channels.html", context)
+
+ return html, 0
+
+
+ def run(self):
+ if self.fields.has_key("label"):
+ return self.listPackages(se​lf.fields['label'])
+ else:
+ return self.listChannels()
+

Deleted: trunk/current/templa​tes/channels.html
====================​====================​====================​=======
--- trunk/current/templa​tes/channels.html 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/templa​tes/channels.html 2005-04-30 21:59:03 UTC (rev 742)
@@ -1,13 +0,0 @@
-<html>
- <body>
- <h1 tal:content="title">The title</h1>
- <table>
- <div tal:repeat="foo rpm">
- <tr><td tal:content="foo/nam​e"></td>
- <td tal:content="foo/ver​sion"></td>​
- <td tal:content="foo/rel​ease"></td>​
- </div>
- </table>
- </body>
-</html>
-

Added: trunk/current/templa​tes/channels.html
====================​====================​====================​=======
--- trunk/current/templa​tes/channels.html 2005-04-29 23:09:00 UTC (rev 741)
+++ trunk/current/templa​tes/channels.html 2005-04-30 21:59:03 UTC (rev 742)
@@ -0,0 +1,13 @@
+<html>
+ <body>
+ <h1 tal:content="title">The title</h1>
+ <ul>
+ <div tal:repeat="foo channels">
+ <li><a href=""
+ tal:attributes="href foo/link"
+ tal:content="foo/nam​e">Channel Name</a></li>
+ </div>
+ </ul>
+ </body>
+</html>
+

Copied: trunk/current/templa​tes/channels.table.h​tml (from rev 738, trunk/current/templa​tes/channels.html)
====================​====================​====================​=======
--- trunk/current/templa​tes/channels.html 2005-04-16 21:24:55 UTC (rev 738)
+++ trunk/current/templa​tes/channels.table.h​tml 2005-04-30 21:59:03 UTC (rev 742)
@@ -0,0 +1,23 @@
+<html>
+ <body>
+ <h1 tal:content="title">The title</h1>
+ <table>
+ <tr>
+ <th>Name</th>
+ <th>Epoch</th>
+ <th>Version</th>
+ <th>Release</th>
+ <th>Arch</th>
+ </tr>
+ <div tal:repeat="foo rpm">
+ <tr><td tal:content="foo/nam​e"></td>
+ <td tal:content="foo/epo​ch"></td>
+ <td tal:content="foo/ver​sion"></td>​
+ <td tal:content="foo/rel​ease"></td>​
+ <td tal:content="foo/arc​h"></td>
+ </tr>
+ </div>
+ </table>
+ </body>
+</html>
+

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

SVN: r742 - in trunk/current: src src/db src/web templates jjneely at EOS dot NCSU dot EDU jjneely at EOS dot NCSU dot EDU 2005-04-30 14:59:09 PDT
Messages per page: