changeset 8:201857e15b50

py3
author Jeff Hammel <k0scist@gmail.com>
date Tue, 24 Nov 2020 13:04:00 -0800
parents 394648c67478
children abf99a03a6c6
files toolbox/handlers.py
diffstat 1 files changed, 20 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/toolbox/handlers.py	Tue Nov 24 13:00:27 2020 -0800
+++ b/toolbox/handlers.py	Tue Nov 24 13:04:00 2020 -0800
@@ -7,10 +7,10 @@
 import os
 from datetime import datetime
 from pkg_resources import resource_filename
-from urllib import quote as _quote
+from urllib.parse import quote as _quote
 from urlparse import urlparse
-from util import strsplit
-from util import JSONEncoder
+from .util import strsplit
+from .util import JSONEncoder
 from webob import Response, exc
 from tempita import HTMLTemplate
 from time import time
@@ -43,18 +43,18 @@
 
         # check the method
         if request.method not in cls.methods:
-            return None
+            return
 
         # check the path
         if request.environ['path'] != cls.handler_path:
-            return None
+            return
 
         # check the constructor
         try:
             return cls(app, request)
         except HandlerMatchException:
-            return None
-    
+            return
+
     def __init__(self, app, request):
         self.app = app
         self.request = request
@@ -137,14 +137,14 @@
           'js/less-1.0.41.min.js',
           'js/jquery.timeago.js',
           'js/main.js']
-    
+
     def __init__(self, app, request):
         Handler.__init__(self, app, request)
 
         # add application template_dir if specified
         if app.template_dir:
             self.template_dirs = self.template_dirs[:] + [app.template_dir]
-            
+
         self.data = { 'request': request,
                       'css': self.css,
                       'item_name': self.app.item_name,
@@ -162,7 +162,7 @@
         # the application caches a dict of the templates if app.reload is False
         if name in self.template_cache:
             return self.template_cache[name]
-        
+
         for d in self.template_dirs:
             path = os.path.join(d, name)
             if os.path.exists(path):
@@ -194,7 +194,7 @@
                'js/jquery.jeditable.js',
                'js/jquery.autolink.js',
                'js/project.js'])
-               
+
     less = TempitaHandler.less[:]
     less.extend(['css/project.less'])
 
@@ -232,7 +232,7 @@
 
 class QueryView(ProjectsView):
     """general index view to query projects"""
-    
+
     template = 'index.html'
     methods = set(['GET'])
 
@@ -262,9 +262,9 @@
                 sort_type = '-modified'
         self.data['sort_type'] = sort_type
         if sort_type != 'search':
-            # preserve search order results 
+            # preserve search order results
             self.sort(sort_type)
-            
+
         self.data['fields'] = self.app.model.fields()
         self.data['title'] = self.app.site_name
 
@@ -436,13 +436,12 @@
         for key in self.request.POST.iterkeys():
             value = self.request.POST[key]
             self.app.model.rename_field_value(field, key, value)
-        
         return self.redirect(field, anchor=value)
-        
+
     def get_json(self):
         return self.data['values']
 
-        
+
 class CreateProjectView(TempitaHandler):
     """view to create a new project"""
 
@@ -453,10 +452,10 @@
     js.extend(['js/jquery.tokeninput.js',
                'js/queryString.js',
                'js/new.js'])
-               
+
     less = TempitaHandler.less[:]
     less.extend(['css/new.less'])
-    
+
     css = TempitaHandler.css[:]
     css.extend(['css/token-input.css',
                 'css/token-input-facebook.css'])
@@ -534,7 +533,7 @@
     methods = set(['POST'])
     handler_path = ['delete']
 
-    def Post(self):        
+    def Post(self):
         post_data = self.post_data()
         project = post_data.get('project')
         if project:
@@ -568,7 +567,7 @@
                 continue
             for field in fields:
                 ommitted[field].update(project.get(field, []))
-            
+
         for project in self.app.model.get():
             if project in omit:
                 continue