changeset 160:d1f0cfc4da0f

Show extended object properties from 'ao' and '{ts,fs,xy,c}data' tables in object view.
author Daniele Nicolodi <daniele@grinta.net>
date Fri, 04 Nov 2011 11:11:42 +0100
parents 8bd23369e429
children 6b04cb2e92c9
files src/ltpdarepo/views/browse.py
diffstat 1 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ltpdarepo/views/browse.py	Fri Nov 04 11:11:41 2011 +0100
+++ b/src/ltpdarepo/views/browse.py	Fri Nov 04 11:11:42 2011 +0100
@@ -441,7 +441,52 @@
         if obj is None:
             # not found
             abort(404)
-        return render_template('obj.html', obj=obj, database=db, fields=FIELDS+EXTRA)
+
+        fields = FIELDS + EXTRA
+
+        if obj['type'] == 'ao':
+            curs = g.db.cursor(DictCursor)
+            curs.execute("""SELECT data_type AS `data type`,
+                                   description AS `description`
+                            FROM `%s`.ao WHERE obj_id=%%s""" % database, objid)
+            fields += ('data type', 'data description', )
+            details = curs.fetchone()
+            obj.update(details)
+
+            if   obj['data type'] == 'tsdata':
+                curs = g.db.cursor(DictCursor)
+                curs.execute("""SELECT t0, nsecs, fs, xunits, yunits,
+                                       t0 - INTERVAL toffset/1000 SECOND AS `reference time`
+                                FROM `%s`.tsdata WHERE obj_id=%%s""" % database, objid)
+                details = curs.fetchone()
+                obj.update(details)
+                fields += ('reference time', 't0', 'nsecs', 'fs', 'xunits', 'yunits', )
+
+            elif obj['data type'] == 'xydata':
+                curs = g.db.cursor(DictCursor)
+                curs.execute("""SELECT xunits, yunits,
+                                FROM `%s`.xydata WHERE obj_id=%%s""" % database, objid)
+                details = curs.fetchone()
+                obj.update(details)
+                fields += ('xunits', 'yunits', )
+
+            elif obj['data type'] == 'fsdata':
+                curs = g.db.cursor(DictCursor)
+                curs.execute("""SELECT fs, xunits, yunits,
+                                FROM `%s`.fsdata WHERE obj_id=%%s""" % database, objid)
+                details = curs.fetchone()
+                obj.update(details)
+                fields += ('fs', 'xunits', 'yunits', )
+
+            elif obj['data type'] == 'cdata':
+                curs = g.db.cursor(DictCursor)
+                curs.execute("""SELECT yunits,
+                                FROM `%s`.cdata WHERE obj_id=%%s""" % database, objid)
+                details = curs.fetchone()
+                obj.update(details)
+                fields += ('yunits', )
+
+        return render_template('obj.html', obj=obj, database=db, fields=fields)
 
 
 @app.route('/<database>/<int:objid>/<frmt>')