Robert Brewer avatar Robert Brewer committed 4628802

More Python 2.3 fixes.

Comments (0)

Files changed (24)

cherrypy/__init__.py

         alias = func
         return expose_
 
-        
 def popargs(*args, **kwargs):
     """A decorator for _cp_dispatch 
     (cherrypy.dispatch.Dispatcher.dispatch_method_name).

cherrypy/lib/cpstats.py

 def extrapolate_statistics(scope):
     """Return an extrapolated copy of the given scope."""
     c = {}
-    for k, v in scope.items():
+    for k, v in list(scope.items()):
         if isinstance(v, dict):
             v = extrapolate_statistics(v)
         elif isinstance(v, (list, tuple)):
             v = [extrapolate_statistics(record) for record in v]
-        elif callable(v):
+        elif hasattr(v, '__call__'):
             v = v(scope)
         c[k] = v
     return c
     }
     
     
-    @cherrypy.expose
     def index(self):
         # Transform the raw data into pretty output for HTML
         yield """
 </body>
 </html>
 """
+    index.exposed = True
     
     def get_namespaces(self):
         """Yield (title, scalars, collections) for each namespace."""
                     if format is None:
                         # Don't output this column.
                         continue
-                    if callable(format):
+                    if hasattr(format, '__call__'):
                         v = format(v)
                     elif format is not missing:
                         v = format % v
                 if format is None:
                     # Don't output this column.
                     continue
-                if callable(format):
+                if hasattr(format, '__call__'):
                     v3 = format(v3)
                 elif format is not missing:
                     v3 = format % v3
                 if format is None:
                     # Don't output this column.
                     continue
-                if callable(format):
+                if hasattr(format, '__call__'):
                     v3 = format(v3)
                 elif format is not missing:
                     v3 = format % v3
         return headers, subrows
     
     if json is not None:
-        @cherrypy.expose
         def data(self):
             s = extrapolate_statistics(logging.statistics)
             cherrypy.response.headers['Content-Type'] = 'application/json'
             return json.dumps(s, sort_keys=True, indent=4)
+        data.exposed = True
     
-    @cherrypy.expose
-    @cherrypy.tools.allow(methods=['POST'])
     def pause(self, namespace):
         logging.statistics.get(namespace, {})['Enabled'] = False
         raise cherrypy.HTTPRedirect('./')
+    pause.exposed = True
+    pause.cp_config = ('tools.allow.on': True,
+                       'tools.allow.methods': ['POST']}
     
-    @cherrypy.expose
-    @cherrypy.tools.allow(methods=['POST'])
     def resume(self, namespace):
         logging.statistics.get(namespace, {})['Enabled'] = True
         raise cherrypy.HTTPRedirect('./')
+    resume.exposed = True
+    resume.cp_config = ('tools.allow.on': True,
+                        'tools.allow.methods': ['POST']}
 

cherrypy/test/test_auth_basic.py

 
 
 class BasicAuthTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def index(self):
         root.basic = BasicProtected()
         root.basic2 = BasicProtected2()
         cherrypy.tree.mount(root, config=conf)
+    setup_server = staticmethod(setup_server)
 
     def testPublic(self):
         self.getPage("/")

cherrypy/test/test_auth_digest.py

 
 class DigestAuthTest(helper.CPWebCase):
 
-    @staticmethod
     def setup_server():
         class Root:
             def index(self):
         root = Root()
         root.digest = DigestProtected()
         cherrypy.tree.mount(root, config=conf)
-
+    setup_server = staticmethod(setup_server)
+    
     def testPublic(self):
         self.getPage("/")
         self.assertStatus('200 OK')

cherrypy/test/test_caching.py

 
 class CacheTest(helper.CPWebCase):
 
-    @staticmethod
     def setup_server():
         
         class Root:
         cherrypy.tree.mount(UnCached(), "/expires")
         cherrypy.tree.mount(VaryHeaderCachingServer(), "/varying_headers")
         cherrypy.config.update({'tools.gzip.on': True})
-
+    setup_server = staticmethod(setup_server)
 
     def testCaching(self):
         elapsed = 0.0

cherrypy/test/test_config_server.py

 from cherrypy.test import helper
 
 class ServerConfigTests(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         
         class Root:
             # Also test default server.instance = builtin server
             'server.yetanother.socket_port': 9878,
             })
+    setup_server = staticmethod(setup_server)
     
     PORT = 9876
     

cherrypy/test/test_core.py

 from cherrypy.test import helper
 
 class CoreRequestHandlingTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             
 
 
         cherrypy.tree.mount(root)
+    setup_server = staticmethod(setup_server)
 
 
     def testStatus(self):

cherrypy/test/test_encoding.py

 
 
 class EncodingTests(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def index(self, param):
         root.gzip = GZIP()
         root.decode = Decode()
         cherrypy.tree.mount(root, config={'/gzip': {'tools.gzip.on': True}})
+    setup_server = staticmethod(setup_server)
 
     def test_query_string_decoding(self):
         europoundUtf8 = europoundUnicode.encode('utf-8')

cherrypy/test/test_etags.py

 
 
 class ETagTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def resource(self):
                       'tools.etags.autotags': True,
                       }}
         cherrypy.tree.mount(Root(), config=conf)
+    setup_server = staticmethod(setup_server)
     
     def test_etags(self):
         self.getPage("/resource")

cherrypy/test/test_http.py

 from cherrypy.test import helper
 
 class HTTPTests(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def index(self, *args, **kwargs):
         
         cherrypy.tree.mount(Root())
         cherrypy.config.update({'server.max_request_body_size': 30000000})
+    setup_server = staticmethod(setup_server)
     
     def test_no_content_length(self):
         # "The presence of a message-body in a request is signaled by the

cherrypy/test/test_httpauth.py

 from cherrypy.test import helper
 
 class HTTPAuthTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def index(self):
         root.basic = BasicProtected()
         root.basic2 = BasicProtected2()
         cherrypy.tree.mount(root, config=conf)
+    setup_server = staticmethod(setup_server)
 
 
     def testPublic(self):

cherrypy/test/test_objectmapping.py

 
 
 class ObjectMappingTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def index(self, name="world"):
                 return "milk"
         
         cherrypy.tree.mount(AnotherApp(), "/app", {'/': {'request.dispatch': d}})
+    setup_server = staticmethod(setup_server)
 
     
     def testObjectMapping(self):

cherrypy/test/test_proxy.py

 
 
 class ProxyTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         
         # Set up site
         
         for sn in script_names:
             cherrypy.tree.mount(Root(sn), sn)
+    setup_server = staticmethod(setup_server)
     
     def testProxy(self):
         self.getPage("/")

cherrypy/test/test_refleaks.py

 
 
 class ReferenceTests(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         
         class Root:
             gc_stats.exposed = True
         
         cherrypy.tree.mount(Root())
+    setup_server = staticmethod(setup_server)
 
     
     def test_threadlocal_garbage(self):

cherrypy/test/test_request_obj.py

 from cherrypy.test import helper
 
 class RequestObjectTests(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             
             '/method': {'request.methods_with_bodies': ("POST", "PUT", "PROPFIND")},
             }
         cherrypy.tree.mount(root, config=appconf)
+    setup_server = staticmethod(setup_server)
 
     def test_scheme(self):
         self.getPage("/scheme")

cherrypy/test/test_routes.py

 import nose
 
 class RoutesDispatchTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
 
         try:
         
         conf = {'/': {'request.dispatch': d}}
         cherrypy.tree.mount(root=None, config=conf)
+    setup_server = staticmethod(setup_server)
 
     def test_Routes_Dispatch(self):
         self.getPage("/hounslow")

cherrypy/test/test_sessionauthenticate.py

 
 
 class SessionAuthenticateTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         
         def check(username, password):
             index.exposed = True
         
         cherrypy.tree.mount(Test())
+    setup_server = staticmethod(setup_server)
 
     
     def testSessionAuthenticate(self):

cherrypy/test/test_static.py

 
 
 class StaticTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         if not os.path.exists(has_space_filepath):
             open(has_space_filepath, 'wb').write('Hello, world\r\n')
         
         vhost = cherrypy._cpwsgi.VirtualHost(rootApp, {'virt.net': testApp})
         cherrypy.tree.graft(vhost)
+    setup_server = staticmethod(setup_server)
 
 
-    @staticmethod
     def teardown_server():
         for f in (has_space_filepath, bigfile_filepath):
             if os.path.exists(f):
                     os.unlink(f)
                 except:
                     pass
+    teardown_server = staticmethod(teardown_server)
 
     
     def testStatic(self):

cherrypy/test/test_tools.py

 
 
 class ToolTests(helper.CPWebCase):
-    @staticmethod
     def setup_server():
         
         # Put check_access in a custom toolbox with its own namespace
         if sys.version_info >= (2, 5):
             from cherrypy.test import _test_decorators
             root.tooldecs = _test_decorators.ToolExamples()
+    setup_server = staticmethod(setup_server)
 
     def testHookErrors(self):
         self.getPage("/demo/?id=1")

cherrypy/test/test_tutorials.py

 
 
 class TutorialTest(helper.CPWebCase):
-    @classmethod
+
     def setup_server(cls):
         
         conf = cherrypy.config.copy()
         root = Dummy()
         root.load_tut_module = load_tut_module
         cherrypy.tree.mount(root)
+    setup_server = staticmethod(setup_server)
 
     
     def test01HelloWorld(self):

cherrypy/test/test_virtualhost.py

 
 
 class VirtualHostTest(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         class Root:
             def index(self):
                                 'tools.staticdir.index': 'index.html',
                                 },
             })
+    setup_server = staticmethod(setup_server)
     
     def testVirtualHost(self):
         self.getPage("/", [('Host', 'www.mydom1.com')])

cherrypy/test/test_wsgi_ns.py

 
 
 class WSGI_Namespace_Test(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         
         class WSGIResponse(object):
         app.wsgiapp.pipeline.append(('changecase', ChangeCase))
         app.wsgiapp.config['changecase'] = {'to': 'upper'}
         cherrypy.tree.mount(app, config={'/': root_conf})
+    setup_server = staticmethod(setup_server)
 
     
     def test_pipeline(self):

cherrypy/test/test_wsgi_vhost.py

 
 
 class WSGI_VirtualHost_Test(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         
         class ClassOfRoot(object):
             domains['www.classof%s.example' % year] = app
         
         cherrypy.tree.graft(cherrypy._cpwsgi.VirtualHost(default, domains))
+    setup_server = staticmethod(setup_server)
     
     def test_welcome(self):
         if not cherrypy.server.using_wsgi:

cherrypy/test/test_wsgiapps.py

 
 
 class WSGIGraftTests(helper.CPWebCase):
-    @staticmethod
+
     def setup_server():
         import os
         curdir = os.path.join(os.getcwd(), os.path.dirname(__file__))
         # be pulled from the WSGI environ each time.
         app = cherrypy.Application(Root(), script_name=None)
         cherrypy.tree.graft(ReversingMiddleware(app), '/hosted/app2')
+    setup_server = staticmethod(setup_server)
 
     wsgi_output = '''Hello, world!
 This is a wsgi app running within CherryPy!'''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.