[ckan-changes] [okfn/ckan] 49d7fd: [xs] fix failing test

GitHub noreply at github.com
Mon Apr 23 11:44:55 UTC 2012


  Branch: refs/heads/master
  Home:   https://github.com/okfn/ckan
  Commit: 49d7fd9b7cdd3dc20c2c091de5b4e61a9777141f
      https://github.com/okfn/ckan/commit/49d7fd9b7cdd3dc20c2c091de5b4e61a9777141f
  Author: Toby <toby.junk at gmail.com>
  Date:   2012-04-23 (Mon, 23 Apr 2012)

  Changed paths:
    M ckan/tests/functional/test_cors.py

  Log Message:
  -----------
  [xs] fix failing test


diff --git a/ckan/tests/functional/test_cors.py b/ckan/tests/functional/test_cors.py
index daa4d4e..b69ff1e 100644
--- a/ckan/tests/functional/test_cors.py
+++ b/ckan/tests/functional/test_cors.py
@@ -18,6 +18,6 @@ def test_headers(self):
         headers = dict(out.headers)
         print headers
         assert headers['Access-Control-Allow-Origin'] == '*'
-        assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, DELETE"
-        assert headers['Access-Control-Allow-Headers'] == "X-CKAN-API-KEY, Content-Type"
+        assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, DELETE, OPTIONS"
+        assert headers['Access-Control-Allow-Headers'] == "X-CKAN-API-KEY, Authorization, Content-Type"
 


================================================================
  Commit: 4f059c9b9fc1e311a3a8f87484f064f3a864cda8
      https://github.com/okfn/ckan/commit/4f059c9b9fc1e311a3a8f87484f064f3a864cda8
  Author: Toby <toby.junk at gmail.com>
  Date:   2012-04-23 (Mon, 23 Apr 2012)

  Changed paths:
    M ckan/config/environment.py

  Log Message:
  -----------
  better feedback on depreciated/missing  helper functions


diff --git a/ckan/config/environment.py b/ckan/config/environment.py
index 580e472..8d42f4b 100644
--- a/ckan/config/environment.py
+++ b/ckan/config/environment.py
@@ -30,10 +30,14 @@ class _Helpers(object):
     def __init__(self, helpers, restrict=True):
         functions = {}
         allowed = helpers.__allowed_functions__
+        # list of functions due to be depreciated
+        self.depreciated = []
 
         for helper in dir(helpers):
-            if restrict and (helper not in allowed):
-                continue
+            if helper not in allowed:
+                self.depreciated.append(helper)
+                if restrict:
+                    continue
             functions[helper] = getattr(helpers, helper)
         self.functions = functions
 
@@ -46,6 +50,8 @@ def __init__(self, helpers, restrict=True):
                     raise Exception('overwritting extra helper %s' % helper)
                 extra_helpers.append(helper)
                 functions[helper] = helpers[helper]
+        # logging
+        self.log = logging.getLogger('ckan.helpers')
 
     @classmethod
     def null_function(cls, *args, **kw):
@@ -57,10 +63,21 @@ def null_function(cls, *args, **kw):
     def __getattr__(self, name):
         ''' return the function/object requested '''
         if name in self.functions:
+            if name in self.depreciated:
+                msg = 'Template helper function `%s` is depriciated' % name
+                self.log.warn(msg)
             return self.functions[name]
         else:
-            log = logging.getLogger('ckan.helpers')
-            log.critical('Helper function `%s` could not be found (missing extension?)' % name)
+            if name in self.depreciated:
+                msg = 'Template helper function `%s` is not available ' \
+                      'as it has been depriciated.\nYou can enable it ' \
+                      'by setting ckan.restrict_template_vars = true ' \
+                      'in your .ini file.' % name
+                self.log.critical(msg)
+            else:
+                msg = 'Helper function `%s` could not be found\n ' \
+                      '(are you missing an extension?)' % name
+                self.log.critical(msg)
             return self.null_function
 
 


================================================================
Compare: https://github.com/okfn/ckan/compare/fbf7754...4f059c9


More information about the ckan-changes mailing list