Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r286 - trunk: current current/api current/db current/db/mysql cwebapp/cwebapp cwebapp/cwebapp/templates

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

current
Discussion topic

Back to topic list

svn commit: r286 - trunk: current current/api current/db current/db/mysql cwebapp/cwebapp cwebapp/cwebapp/templates

Reply

Author jjneely
Full name Jack Neely
Date 2006-09-13 11:24:20 PDT
Message Author: jjneely
Date: 2006-09-13 11:24:20-0700
New Revision: 286

Added:
   trunk/cwebapp/cwebap​p/templates/channelD​etail.kid
Modified:
   trunk/current/api/channels.py
   trunk/current/api/systems.py
   trunk/current/channels.py
   trunk/current/db/currentdb.py
   trunk/current/db/mysql/mysql.py
   trunk/current/db/profile.py
   trunk/current/profiles.py
   trunk/cwebapp/cwebap​p/controllers.py
   trunk/cwebapp/cwebap​p/templates/channels​.kid
   trunk/cwebapp/cwebap​p/templates/systemDe​tail.kid

Log:
Improved System Detail with number of possible errata ready to be deployed.
Add its own systemDetail function rather than make listSystems do
multiple things.

Added Channel Detail and moved some info from the main channel page to the
detail page.

Add some logging to the MySQL-Python cursor wrapper to log what's happening.


Modified: trunk/current/api/channels.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/api/channels.py?vi​ew=diff&rev=286​&p1=trunk/current​/api/channels.py​&p2=trunk/current/ap​i/channels.py&r1​=285&r2=286
====================​====================​====================​==================
--- trunk/current/api/channels.py (original)
+++ trunk/current/api/channels.py 2006-09-13 11:24:20-0700
@@ -26,6 +26,7 @@
 
 __current_api__ = [
     'listChannels',
+ 'getChannelDetail',
 ]
 
 def listChannels(sess):
@@ -36,3 +37,11 @@
     chanlib = Channels()
     return chanlib.listChannels()
 
+def getChannelDetail(sess, label):
+ u = SessionUser(sess)
+ if not u.isValid():
+ return xmlrpclib.Fault(EAUTH, "Bad session. Please login.")
+
+ chanlib = Channels()
+ return chanlib.getChannelDetail(label)
+

Modified: trunk/current/api/systems.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/api/systems.py?vie​w=diff&rev=286​&p1=trunk/current/​api/systems.py&p​2=trunk/current/api/​systems.py&r1=28​5&r2=286
====================​====================​====================​==================
--- trunk/current/api/systems.py (original)
+++ trunk/current/api/systems.py 2006-09-13 11:24:20-0700
@@ -21,21 +21,29 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 from current.logger import *
-from current import auth
+from current.users import SessionUser
 from current import profiles
 from current import channels
+from cadmin import EAUTH
 
 __current_api__ = [
     'systemCount',
+ 'systemDetail',
 ]
 
-def example(sysid_string):
- si = auth.SysId(sysid_string)
- (valid, reason) = si.isValid()
- if not valid:
- return xmlrpclib.Fault(1000, reason)
-
-def systemCount():
+def systemCount(sess):
+ u = SessionUser(sess)
+ if not u.isValid():
+ return xmlrpclib.Fault(EAUTH, "Bad session. Please login.")
+
     syslib = profiles.Systems()
     return syslib.systemCount()
 
+def systemDetail(sess, pid):
+ u = SessionUser(sess)
+ if not u.isValid():
+ return xmlrpclib.Fault(EAUTH, "Bad session. Please login.")
+
+ p = profiles.Profile(pid)
+ return p.getDetail()
+

Modified: trunk/current/channels.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/channels.py?view=d​iff&rev=286&​p1=trunk/current/cha​nnels.py&p2=trun​k/current/channels.p​y&r1=285&r2=​286
====================​====================​====================​==================
--- trunk/current/channels.py (original)
+++ trunk/current/channels.py 2006-09-13 11:24:20-0700
@@ -105,3 +105,12 @@
     def listChannels(self):
         list = self.db.listChannels()
         return list
+
+ def getChannelDetail(self, label):
+ cid = self.db._getChanID(label)
+ detail = self.db.getChannelDetail(cid)
+ if detail == None:
+ # a sane value when channel_id doesn't exist
+ return {}
+ else:
+ return detail

Modified: trunk/current/db/currentdb.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/db/currentdb.py?vi​ew=diff&rev=286​&p1=trunk/current​/db/currentdb.py​&p2=trunk/current/db​/currentdb.py&r1​=285&r2=286
====================​====================​====================​==================
--- trunk/current/db/currentdb.py (original)
+++ trunk/current/db/currentdb.py 2006-09-13 11:24:20-0700
@@ -941,7 +941,7 @@
     def listChannels(self):
         """Return a list of dicts with basic channel information."""
 
- q = """select name, label, arch, osrelease, description
+ q = """select name, label, description, channel_id
                from CHANNEL"""
 
         self.cursor.execute(q)
@@ -950,3 +950,15 @@
             return []
         return r.dump()
 
+
+ def getChannelDetail(self, channel_id):
+ q = """select name, label, description, arch, osrelease,
+ lastupdate, base from CHANNEL where channel_id = %s"""
+
+ self.cursor.execute(q, (channel_id,))
+ r = resultSet(self.cursor)
+ if r.rowcount() == 0:
+ return None
+
+ return r.dump()[0]
+

Modified: trunk/current/db/mysql/mysql.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/db/mysql/mysql.py?​view=diff&rev=28​6&p1=trunk/curre​nt/db/mysql/mysql.py​&p2=trunk/curren​t/db/mysql/mysql.py​&r1=285&r2=28​6
====================​====================​====================​==================
--- trunk/current/db/mysql/mysql.py (original)
+++ trunk/current/db/mysql/mysql.py 2006-09-13 11:24:20-0700
@@ -27,7 +27,9 @@
         try:
             return getattr(self.sdb.cursor, name)
         except MySQLdb.OperationalError, e:
+ log(DEBUG2, "OperationalError: e.args = %s" % str(e.args))
             if e.args[0] in (2006, 2013):
+ log(VERBOSE, "Forcing reconnect to MySQL database")
                 self.sdb.conn = None
                 self.sdb.cursor = None
                 self.sdb.getCursor()

Modified: trunk/current/db/profile.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/db/profile.py?view​=diff&rev=286​&p1=trunk/current/d​b/profile.py&p2=​trunk/current/db/pro​file.py&r1=285​&r2=286
====================​====================​====================​==================
--- trunk/current/db/profile.py (original)
+++ trunk/current/db/profile.py 2006-09-13 11:24:20-0700
@@ -209,7 +209,16 @@
         r = self.cursor.fetchone()
 
         return r[0]
-
+
+ def getNumUpdatable(self, pid):
+ q = """select count(*) from INSTALLED where profile_id = %s
+ and info = %s"""
+
+ self.cursor.execute(q, (pid, UPDATABLE))
+ r = self.cursor.fetchone()
+
+ return r[0]
+
     def _getChanID(self, channel):
         """Take a channel label and return the chan id from the DB."""
 

Modified: trunk/current/profiles.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/curren​t/profiles.py?view=d​iff&rev=286&​p1=trunk/current/pro​files.py&p2=trun​k/current/profiles.p​y&r1=285&r2=​286
====================​====================​====================​==================
--- trunk/current/profiles.py (original)
+++ trunk/current/profiles.py 2006-09-13 11:24:20-0700
@@ -22,6 +22,7 @@
 
 from current.exception import *
 from current.db import profile
+from current.logger import *
 
 class Profile(object):
 
@@ -33,10 +34,14 @@
             # New object
             return
 
- if len(id.split('-')) is not 5:
- raise CurrentException("Badly formed UUID.")
+ if len(id.split('-')) == 5:
+ self.pid = self.db.getProfileID(id)
+ elif id.find("-") == -1:
+ self.pid = int(id)
+ else:
+ log(TRIVIA, "type of id: %s" % str(type(id)))
+ raise CurrentException("Badly formed ID.")
         
- self.pid = self.db.getProfileID(id)
         if self.pid == None:
             raise CurrentException("No profile found for id: %s" % id)
 
@@ -113,6 +118,11 @@
     def updateAllInstallPackages(self):
         return self.db.updateAllIns​tallPackages()
 
+ def getDetail(self):
+ self.__sanity()
+ system = self.db.listSystems(​self.pid)[0]
+ system['num_old_packages'] = self.db.getNumUpdata​ble(self.pid)
+ return system
 
 class Systems(object):
 

Modified: trunk/cwebapp/cwebap​p/controllers.py
Url: http://current.tigri​s.org/source/browse/​current/trunk/cwebap​p/cwebapp/controller​s.py?view=diff&r​ev=286&p1=trunk/​cwebapp/cwebapp/cont​rollers.py&p2=tr​unk/cwebapp/cwebapp/​controllers.py&r​1=285&r2=286
====================​====================​====================​==================
--- trunk/cwebapp/cwebap​p/controllers.py (original)
+++ trunk/cwebapp/cwebap​p/controllers.py 2006-09-13 11:24:20-0700
@@ -18,9 +18,9 @@
     @turbogears.expose(h​tml="cwebapp.templat​es.systemDetail")
     @auth.needsLogin
     def details(self, userInfo, profileID):
- system = self.__api.cadmin.fi​ndProfile(userInfo['​session'],
+ system = self.__api.systems.s​ystemDetail(userInfo​['session'],
                                                 profileID)
- return dict(system=system[0])
+ return dict(system=system)
 
 class Channels(object):
 
@@ -33,6 +33,13 @@
         channels = self.__api.channels.​listChannels(userInf​o['session'])
         return dict(channels=channels)
 
+ @turbogears.expose(h​tml="cwebapp.templat​es.channelDetail")
+ @auth.needsLogin
+ def detail(self, userInfo, label):
+ detail = self.__api.channels.​getChannelDetail(use​rInfo['session'],
+ label)
+ return dict(channel=detail)
+
 class Root(controllers.Root):
 
     def __init__(self):
@@ -49,7 +56,8 @@
     @auth.needsLogin
     def index(self, userInfo):
         print userInfo
- return dict(systemTotal=sel​f.__api.systems.syst​emCount(),
+ return dict(systemTotal=sel​f.__api.systems.syst​emCount(
+ userInfo['session']),
                     userID=userInfo['userid'])
 
     @turbogears.expose(h​tml="cwebapp.templat​es.login")

Added: trunk/cwebapp/cwebap​p/templates/channelD​etail.kid
Url: http://current.tigri​s.org/source/browse/​current/trunk/cwebap​p/cwebapp/templates/​channelDetail.kid?vi​ew=auto&rev=286
====================​====================​====================​==================
--- (empty file)
+++ trunk/cwebapp/cwebap​p/templates/channelD​etail.kid 2006-09-13 11:24:20-0700
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR​/xhtml1/DTD/xhtml1-t​ransitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
+ py:extends="'master.kid'">
+
+<head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
+ <link rel="stylesheet" type="text/css" charset="utf-8"
+ href="${std.url('/s​tatic/css/current.cs​s')}" />
+ <title>Current​</title>
+</head>
+
+<body>
+ <h1>Channel Details</h1>
+
+ <table>
+ <tr>
+ <th>Channel Name:</th>
+ <td py:content="channel[​'name']">Name goes here</td>
+ </tr>
+ <tr>
+ <th>Label:</th>
+ <td py:content="channel[​'label']">label-f​oo-i386</td>
+ </tr>
+ <tr>
+ <th>Descriptio​n:</th>
+ <td py:content="channel[​'description']">I​D Number</td>
+ </tr>
+ <tr>
+ <th>Arch:</th>
+ <td py:content="channel[​'arch']">i786<​/td>
+ </tr>
+ <tr>
+ <th>OS Release:</th>
+ <td py:content="channel[​'osrelease']">i78​6</td>
+ </tr>
+ <tr>
+ <th>Last Update Timestamp:</th>
+ <td py:content="channel[​'lastupdate']">i7​86</td>
+ </tr>
+ <tr>
+ <th>Base Channel:</th>
+ <td py:if="channel['base​']">True</td​>
+ <td py:if="not channel['base']">​False</td>
+ </tr>
+ </table>
+
+</body>
+</html>

Modified: trunk/cwebapp/cwebap​p/templates/channels​.kid
Url: http://current.tigri​s.org/source/browse/​current/trunk/cwebap​p/cwebapp/templates/​channels.kid?view=di​ff&rev=286&p​1=trunk/cwebapp/cweb​app/templates/channe​ls.kid&p2=trunk/​cwebapp/cwebapp/temp​lates/channels.kid​&r1=285&r2=286​
====================​====================​====================​==================
--- trunk/cwebapp/cwebap​p/templates/channels​.kid (original)
+++ trunk/cwebapp/cwebap​p/templates/channels​.kid 2006-09-13 11:24:20-0700
@@ -15,13 +15,17 @@
     <p>Channels:</p>
 
     <table class="tabledata">
- <tr><th>​Name</th><t​h>Label</th​><th>Arch</​th><th>OS Release</th></tr>
+ <tr><th>​Name</th><t​h>Label</th​></tr>
         <tr py:for="i, channel in enumerate(channels)"
             class="${i%2 and 'oddrow' or 'evenrow'}">
- <td py:content="channel[​'name']">Name goes here</td>
- <td py:content="channel[​'label']">Channel​-label</td>
- <td py:content="channel[​'arch']">Channel Arch</td>
- <td py:content="channel[​'osrelease']">Cha​nnel OS release</td>
+ <td><a href="" py:content="channel['name']"
+ py:attrs="href='/cha​nnels/detail?label='​+channel['label']"​>
+ Name goes here</a>
+ </td>
+ <td><a href="" py:content="channel['label']"
+ py:attrs="href='/cha​nnels/detail?label='​+channel['label']"​>
+ Channel-label</a>
+ </td>
         </tr>
     </table>
     

Modified: trunk/cwebapp/cwebap​p/templates/systemDe​tail.kid
Url: http://current.tigri​s.org/source/browse/​current/trunk/cwebap​p/cwebapp/templates/​systemDetail.kid?vie​w=diff&rev=286​&p1=trunk/cwebapp/​cwebapp/templates/sy​stemDetail.kid&p​2=trunk/cwebapp/cweb​app/templates/system​Detail.kid&r1=28​5&r2=286
====================​====================​====================​==================
--- trunk/cwebapp/cwebap​p/templates/systemDe​tail.kid (original)
+++ trunk/cwebapp/cwebap​p/templates/systemDe​tail.kid 2006-09-13 11:24:20-0700
@@ -35,6 +35,10 @@
                     <span py:replace="l">la​bel-foo</span>​<br/></span​>
             </td>
         </tr>
+ <tr>
+ <th>Number of Packages Needing Update:</th>
+ <td py:content="system['​num_old_packages']"​>All of them</td>
+ </tr>
     </table>
     
 </body>

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

Messages

Show all messages in topic

svn commit: r286 - trunk: current current/api current/db current/db/mysql cwebapp/cwebapp cwebapp/cwebapp/templates jjneely Jack Neely 2006-09-13 11:24:20 PDT
Messages per page: