Anonymous avatar Anonymous committed 60e5bc8

pylons 0.10 support started

Comments (0)

Files changed (4)

tg/configuration.py

 import atexit
 import os
 import logging
+import warnings
 from copy import copy
 import mimetypes
 from UserDict import DictMixin
 
         #see http://trac.turbogears.org/ticket/2247
         if asbool(config['debug']):
+            warnings.simplefilter("ignore")
             config['pylons.strict_c'] = True
-
+            warnings.resetwarnings()
+            config['pylons.stritmpl_contextt_tmpl_context'] = True
         self.after_init_config()
 
     def after_init_config(self):
         Override this method to set up configuration variables at the application
         level.  This method will be called after your configuration object has
         been initialized on startup.  Here is how you would use it to override
-        the default setting of pylons.strict_c ::
+        the default setting of pylons.stritmpl_contextt_tmpl_context ::
 
             from tg.configuration import AppConfig
             from pylons import config
 
             class MyAppConfig(AppConfig):
                 def after_init_config(self):
-                    config['pylons.strict_c'] = False
+                    config['pylons.stritmpl_contextt_tmpl_context'] = False
 
             base_config = MyAppConfig()
 
                  [FileSystemLoader(path) for path in self.paths['templates']]),
                  auto_reload=self.auto_reload_templates)
         # Jinja's unable to request c's attributes without strict_c
+        warnings.simplefilter("ignore")
         config['pylons.strict_c'] = True
+        warnings.resetwarnings()
+        config['pylons.stritmpl_contextt_tmpl_context'] = True
+
 
         self.render_functions.jinja = render_jinja
 

tg/test_stack/dispatch/controllers/root.py

     @expose()
     def redirect_sub(self):
         tg.redirect('index')
-    
+
     @expose()
     def redirect_list(self):
         tg.redirect(["/sub2", "list"])
     @expose(content_type='image/png')
     def custom_content_type(self):
         return 'PNG'
-    
+
     @expose(content_type='text/plain')
     def custom_content_text_plain_type(self):
         return 'a<br/>bx'
     def custom_content_type2(self):
         pylons.response.headers['Content-Type'] = 'image/png'
         return 'PNG2'
-    
+
     @expose()
     def check_params(self, *args, **kwargs):
         if not args and not kwargs:
             return "None recieved"
         else:
-            return "Controler recieved: %s, %s" %(args, kwargs) 
-    
+            return "Controler recieved: %s, %s" %(args, kwargs)
+
     @expose()
     def test_url_sop(self):
         from tg import url
         eq_('/foo', url('/foo'))
 
-        
+
         u = url("/foo", bar=1, baz=2)
         assert u in \
                 ["/foo?bar=1&baz=2", "/foo?baz=2&bar=1"], u

tg/test_stack/dispatch/test_url_dispatch.py

 from tg.util import no_warn
 
 def setup_noDB():
-    base_config = TestConfig(folder = 'dispatch', 
+    base_config = TestConfig(folder = 'dispatch',
                              values = {'use_sqlalchemy': False,
                              'ignore_parameters': ["ignore", "ignore_me"]
                              }
                              )
-    return app_from_config(base_config) 
+    return app_from_config(base_config)
 
 
 app = setup_noDB()
     resp = resp.follow()
     assert 'hello world' in resp, resp
 
+@no_warn
 def test_redirect_relative():
     resp = app.get('/redirect_me?target=hello&name=abc')
     resp = resp.follow()
 def test_subcontroller_redirect_no_slash_sub2index():
     resp=app.get('/sub2/').follow()
     assert'hello list' in resp, resp
-    
+
 def test_redirect_to_list_of_strings():
     resp = app.get('/sub/redirect_list').follow()
     assert 'hello list' in resp, resp
     assert 'text/plain; charset=utf-8' == dict(resp.headers)['Content-Type'], resp
     assert resp.body == """a<br/>bx""", resp
 
+@no_warn
 def test_custom_content_type2():
     resp = app.get('/custom_content_type2')
     assert 'image/png' == dict(resp.headers)['Content-Type'], resp
     assert resp.body == 'PNG2', resp
 
+@no_warn
 def test_basicurls():
     resp = app.get("/test_url_sop")
-    
+
 def test_ignore_parameters():
     resp = app.get("/check_params?ignore='bar'&ignore_me='foo'")
     assert "None Recieved"
 def test_json_return_list():
     resp = app.get("/json_return_list")
     assert "None Recieved"
-    
+
 def test_https_redirect():
     resp = app.get("/test_https?foo=bar&baz=bat")
     assert 'https://' in resp, resp
     params = variable_encode(dict(obj=obj), add_repetitions=False)
     resp = app.get('/test_vardec', params=params)
     assert resp.json['obj'] == obj, (resp.json['obj'], obj)
-    
+
 import os, shutil
 from unittest import TestCase
 from xmlrpclib import loads, dumps
+import warnings
 
 import webob
 import beaker
         'pylons.request_options': pylons.configuration.request_defaults.copy(),
         'pylons.response_options': pylons.configuration.response_defaults.copy(),
         'pylons.strict_c': False,
+        'pylons.stritmpl_contextt_tmpl_context':False,
         'pylons.c_attach_args': True,
         'pylons.tmpl_context_attach_args': True,
         'buffet.template_engines': [],
         tmpl_options['genshi.search_path'] = ['tests']
         self._ctx = ContextObj()
         tmpl_context._push_object(self._ctx)
+
+        warnings.simplefilter("ignore")
         pylons.config.push_process_config(default_config)
+        warnings.resetwarnings()
         setup_session_dir()
 
     def tearDown(self):
         tmpl_context._pop_object(self._ctx)
+        pylons.config.pop_thread_config()
         pylons.config.pop_process_config()
         teardown_session_dir()
 
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.