qmsk.dmx.web: port to qmsk.web, python3
authorTero Marttila <terom@paivola.fi>
Sat, 07 Jun 2014 16:23:16 +0300
changeset 96 e6dfc98ec50f
parent 95 478b9d0485aa
child 97 ce91458641c1
qmsk.dmx.web: port to qmsk.web, python3
qmsk/dmx/web.py
--- a/qmsk/dmx/web.py	Sat Jun 07 16:22:56 2014 +0300
+++ b/qmsk/dmx/web.py	Sat Jun 07 16:23:16 2014 +0300
@@ -1,5 +1,7 @@
-import pvl.web
-from pvl.web import urls, html
+from qmsk.web import urls
+from qmsk.web.application import Application
+from qmsk.web.html import HTMLHandler
+from qmsk.web.html import html5 as html
 
 import collections
 import logging; log = logging.getLogger('qmsk.dmx.web')
@@ -37,11 +39,8 @@
 def head_color (head, value) :
     return html.div(class_='dmx-color-background')(colorize(html.div(id='-'.join([head, 'color']), class_='dmx-color')(' '), **value))
 
-class Handler (pvl.web.Handler) :
+class Handler (HTMLHandler) :
     # Bootstrap
-    DOCTYPE = 'html'
-    HTML_XMLNS = None
-    HTML_LANG = 'en'
     CSS = (
             '//code.jquery.com/ui/1.10.4/themes/ui-darkness/jquery-ui.css',
             '//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css',
@@ -64,7 +63,7 @@
         if self.request.method == 'POST' :
             update = collections.defaultdict(dict)
 
-            for name, value in self.request.form.iteritems() :
+            for name, value in self.request.form.items() :
                 head_name, attr = name.split('-', 1)
                 head = self.app.universe[head_name]
 
@@ -125,10 +124,10 @@
             )
         )
 
-class DMXWebApplication (pvl.web.Application) :
-    URLS = urls.Map((
-        urls.rule('/',          Handler),
-    ))
+class DMXWebApplication (Application) :
+    URLS = urls.rules({
+        '/':                    Handler,
+    })
 
     def __init__ (self, universe, **opts) :
         """
@@ -144,6 +143,6 @@
             Update given {head: {attr: value}}
         """
         
-        for head, attrs in update.iteritems():
+        for head, attrs in update.items():
             self.universe.update(head, attrs)