]> andersk Git - sql.git/blobdiff - lib/python/mitsql/interface/handler.py
implemented base interface
[sql.git] / lib / python / mitsql / interface / handler.py
diff --git a/lib/python/mitsql/interface/handler.py b/lib/python/mitsql/interface/handler.py
new file mode 100644 (file)
index 0000000..14eac9e
--- /dev/null
@@ -0,0 +1,48 @@
+import mitsql
+from cheetah import templates
+import cherrypy
+
+from pprint import pformat
+
+def _500(*argv, **kw):
+    s_exc = cherrypy._cperror.format_exc()
+    mitsql.logging.error(s_exc)
+    return templates.common.shell(title='%s (CherryPy %s)' % (kw.get('status'), kw.get('version')),
+                                  content=('<p>%s</p>' + (2*'<div><pre>%s</pre></div>'))
+                                  % (kw.get('message'), kw.get('traceback'),
+                                     _phtml(dict(filter(lambda x: not x[0][:2] == '__',
+                                                        cherrypy.request.__dict__.items())))))
+
+class Root(object):
+    class Error(object):
+        @cherrypy.expose
+        def _404(*argv, **kw):
+            return templates.common._404()
+        def _500(*argv, **kw):
+            return _500(*argv, **kw)
+    error = Error()
+    
+    class DB(object):
+        def list(*argv, **kw):
+            r = {'db_list': [],
+                 'size_tot': '1M',
+                 'size_max': '100M',
+                 'user': {
+                 'db_prefix': 'presbrey+'
+                 }}
+            return templates.main.db_list(**r)
+        list.exposed = True
+    db = DB()
+
+    def test(self, *argv, **kw):
+        cherrypy.response.headers['Content-type'] = 'text/plain'
+        return pformat(dict(filter(lambda x: not x[0][:2] == '__', cherrypy.request.__dict__.items())))
+    test.exposed = True
+
+    def index(self, *argv, **kw):
+        return templates.main.index()
+    index.exposed = True
+    
+    def passwd(self, *argv, **kw):
+        return templates.main.passwd()
+    passwd.exposed = True
\ No newline at end of file
This page took 0.032751 seconds and 4 git commands to generate.