Author: dmeyer
Date: Sun Jan 29 11:44:17 2006
New Revision: 7888
Added:
trunk/WIP/webserver/src/tv/
trunk/WIP/webserver/src/tv/__init__.py
trunk/WIP/webserver/src/tv/rec2.kid
trunk/WIP/webserver/src/tv/recordings.tmpl
Modified:
trunk/WIP/webserver/src/__init__.py
trunk/WIP/webserver/src/root.py
Log:
add some more test code
Modified: trunk/WIP/webserver/src/__init__.py
==============================================================================
--- trunk/WIP/webserver/src/__init__.py (original)
+++ trunk/WIP/webserver/src/__init__.py Sun Jan 29 11:44:17 2006
@@ -1,29 +1,2 @@
-import os
-
from config import config
from root import Root
-
-def _add_subdirs(node, dirname):
- """
- Internal function to add sudirs as nodes to an object.
- """
- # add special attribute config
- node.config = config
- for name in os.listdir(dirname):
- filename = os.path.join(dirname, name)
- if not os.path.isdir(filename):
- continue
- module = filename[len(os.path.dirname(__file__))+1:]
- exec('from %s import Root' % module.replace('/', '.'))
- # add special attribute basename
- Root.basename = '/' + module
- # create object
- setattr(node, name, Root())
- # find subdirs
- _add_subdirs(getattr(node, name), filename)
-
-
-# add special attribute basename
-Root.basename = '/'
-# add all subdirs to Root
-_add_subdirs(Root, os.path.dirname(__file__))
Modified: trunk/WIP/webserver/src/root.py
==============================================================================
--- trunk/WIP/webserver/src/root.py (original)
+++ trunk/WIP/webserver/src/root.py Sun Jan 29 11:44:17 2006
@@ -1,13 +1,48 @@
# Define root functions here. No objects (subdirs). Use a real subdir
# with a new Root dir instead
+import os
+
import kaa.cherrypy
+import config
+
# cheetah template!
import foo
class Root:
+ def __init__(self):
+ """
+ Init the root node. This will import all the submodules and
+ create the root.
+ """
+ # add special attribute basename
+ self.basename = '/'
+ # add all subdirs to Root
+ self._add_subdirs(self, os.path.dirname(__file__))
+
+
+ def _add_subdirs(self, node, dirname):
+ """
+ Internal function to add sudirs as nodes to an object.
+ """
+ # add special attribute config
+ node.config = config
+ for name in os.listdir(dirname):
+ filename = os.path.join(dirname, name)
+ if not os.path.isdir(filename):
+ continue
+ module = filename[len(os.path.dirname(__file__))+1:]
+ exec('from %s import Root' % module.replace('/', '.'))
+ # add special attribute basename
+ Root.basename = '/' + module
+ # create object
+ setattr(node, name, Root())
+ # find subdirs
+ self._add_subdirs(getattr(node, name), filename)
+
+
# add other functions here
@kaa.cherrypy.expose()
Added: trunk/WIP/webserver/src/tv/__init__.py
==============================================================================
--- (empty file)
+++ trunk/WIP/webserver/src/tv/__init__.py Sun Jan 29 11:44:17 2006
@@ -0,0 +1,28 @@
+import kaa.cherrypy
+
+import recordings
+import rec2
+
+# freevo core imports
+import freevo.ipc
+
+# get tvserver interface
+tvserver = freevo.ipc.Instance().tvserver
+
+# root for browse
+class Root:
+
+ @kaa.cherrypy.expose()
+ def index(self):
+ print 'running on port %s' % self.config.port
+ print 'basename is %s' % self.basename
+ return ""
+
+ # notice: pass the _imported_module_ to this function here
+ @kaa.cherrypy.expose(template=recordings)
+ def recordings(self):
+ return dict(recordings=tvserver.recordings.list())
+
+ # A kid template as function without extra attributes. The template
+ # loads tvserver by itself.
+ rec2 = kaa.cherrypy.Template(rec2).render
Added: trunk/WIP/webserver/src/tv/rec2.kid
==============================================================================
--- (empty file)
+++ trunk/WIP/webserver/src/tv/rec2.kid Sun Jan 29 11:44:17 2006
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <?python
+ # import freevo.ipc stuff
+ import freevo.ipc
+ tvserver = freevo.ipc.Instance().tvserver
+ ?>
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://purl.org/kid/ns#">
+
+<head>
+<title>Recordings with Kid</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+</head>
+<body>
+
+<h1>Recordings</h1>
+
+<ol>
+ <li py:for="rec in tvserver.recordings.list()">
+ <span py:replace="rec"></span>
+ </li>
+</ol>
+
+</body>
+</html>
Added: trunk/WIP/webserver/src/tv/recordings.tmpl
==============================================================================
--- (empty file)
+++ trunk/WIP/webserver/src/tv/recordings.tmpl Sun Jan 29 11:44:17 2006
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>Recordings</title>
+ </head>
+ <body>
+ <ul>
+ #for $rec in $recordings
+ <li>$rec</li>
+ #end for
+ </ul>
+ </body>
+</html>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog