You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/11/18 20:14:25 UTC

[1/3] allura git commit: [#8015] for activitystream, convert string bools to actual bools

Repository: allura
Updated Branches:
  refs/heads/master 96657d10d -> 853240a74


[#8015] for activitystream, convert string bools to actual bools


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/fd545eaf
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fd545eaf
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fd545eaf

Branch: refs/heads/master
Commit: fd545eaf0de7467cdc487eb25ee63b9610063318
Parents: 96657d1
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Nov 12 15:18:17 2015 -0500
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Wed Nov 18 12:55:28 2015 -0500

----------------------------------------------------------------------
 Allura/allura/command/base.py       |  6 +++---
 Allura/allura/config/middleware.py  |  2 +-
 Allura/allura/lib/helpers.py        | 23 +++++++++++++++++++++++
 Allura/allura/tests/test_helpers.py | 10 ++++++++++
 Allura/allura/websetup/schema.py    |  4 +++-
 5 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fd545eaf/Allura/allura/command/base.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/base.py b/Allura/allura/command/base.py
index 3d619fc..66b46d5 100644
--- a/Allura/allura/command/base.py
+++ b/Allura/allura/command/base.py
@@ -29,7 +29,7 @@ import activitystream
 import ming
 from allura.config.environment import load_environment
 from allura.lib.decorators import task
-from allura.lib.helpers import iter_entry_points
+from allura.lib import helpers as h
 
 log = None
 
@@ -103,14 +103,14 @@ class Command(command.Command):
             M = model
             ming.configure(**conf)
             if asbool(conf.get('activitystream.recording.enabled', False)):
-                activitystream.configure(**conf)
+                activitystream.configure(**h.convert_bools(conf, prefix='activitystream.'))
             pylons.tmpl_context.user = M.User.anonymous()
         else:
             # Probably being called from another script (websetup, perhaps?)
             log = logging.getLogger('allura.command')
             conf = pylons.config
         self.tools = pylons.app_globals.entry_points['tool'].values()
-        for ep in iter_entry_points('allura.command_init'):
+        for ep in h.iter_entry_points('allura.command_init'):
             log.info('Running command_init for %s', ep.name)
             ep.load()(conf)
         log.info('Loaded tools')

http://git-wip-us.apache.org/repos/asf/allura/blob/fd545eaf/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 5ce50a3..fd137c2 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -99,7 +99,7 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
 
     # Configure ActivityStream
     if asbool(app_conf.get('activitystream.recording.enabled', False)):
-        activitystream.configure(**app_conf)
+        activitystream.configure(**h.convert_bools(app_conf, prefix='activitystream.'))
 
     # Configure EW variable provider
     ew.render.TemplateEngine.register_variable_provider(get_tg_vars)

http://git-wip-us.apache.org/repos/asf/allura/blob/fd545eaf/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 72c64ad..93c0d6f 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -348,6 +348,29 @@ def vardec(fun):
     return fun
 
 
+def convert_bools(conf, prefix=''):
+    '''
+    For a given dict, automatically convert any true/false string values into bools.
+    Only applies to keys starting with the prefix.
+
+    :param dict conf:
+    :param str prefix:
+    :return: dict
+    '''
+    def convert_value(val):
+        if isinstance(val, basestring):
+            if val.strip().lower() == 'true':
+                return True
+            elif val.strip().lower() == 'false':
+                return False
+        return val
+
+    return {
+        k: (convert_value(v) if k.startswith(prefix) else v)
+        for k, v in conf.iteritems()
+    }
+
+
 def nonce(length=4):
     return sha1(ObjectId().binary + os.urandom(10)).hexdigest()[:length]
 

http://git-wip-us.apache.org/repos/asf/allura/blob/fd545eaf/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 8f2c01e..296a7c3 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -564,6 +564,7 @@ class TestIterEntryPoints(TestCase):
                                 'Multiple entry points with name "myapp".',
                                 list, h.iter_entry_points('allura'))
 
+
 def test_get_user_status():
     user = M.User.by_username('test-admin')
     assert_equals(h.get_user_status(user), 'enabled')
@@ -576,3 +577,12 @@ def test_get_user_status():
 
     user = Mock(disabled=True, pending=True)  # not an expected combination
     assert_equals(h.get_user_status(user), 'disabled')
+
+
+def test_convert_bools():
+    assert_equals(h.convert_bools({'foo': 'bar', 'baz': 'false', 'abc': 0, 'def': 1, 'ghi': True}),
+                  {'foo': 'bar', 'baz': False, 'abc': 0, 'def': 1, 'ghi': True})
+    assert_equals(h.convert_bools({'foo': 'true', 'baz': ' TRUE '}),
+                  {'foo': True, 'baz': True})
+    assert_equals(h.convert_bools({'foo': 'true', 'baz': ' TRUE '}, prefix='ba'),
+                  {'foo': 'true', 'baz': True})
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/fd545eaf/Allura/allura/websetup/schema.py
----------------------------------------------------------------------
diff --git a/Allura/allura/websetup/schema.py b/Allura/allura/websetup/schema.py
index d25128e..88c57a4 100644
--- a/Allura/allura/websetup/schema.py
+++ b/Allura/allura/websetup/schema.py
@@ -27,6 +27,8 @@ import pylons
 from paste.deploy.converters import asbool
 from paste.registry import Registry
 
+from allura.lib import helpers as h
+
 log = logging.getLogger(__name__)
 REGISTRY = Registry()
 
@@ -42,7 +44,7 @@ def setup_schema(command, conf, vars):
     REGISTRY.register(allura.credentials, allura.lib.security.Credentials())
     ming.configure(**conf)
     if asbool(conf.get('activitystream.recording.enabled', False)):
-        activitystream.configure(**conf)
+        activitystream.configure(**h.convert_bools(conf, prefix='activitystream.'))
     # Nothing to do
     log.info('setup_schema called')
 


[2/3] allura git commit: [#8015] update activitystream session name to match its change

Posted by he...@apache.org.
[#8015] update activitystream session name to match its change


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/fae95f39
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fae95f39
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fae95f39

Branch: refs/heads/master
Commit: fae95f399f3b0f04a2882c08bf9894d78f3c82ab
Parents: fd545ea
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Nov 12 15:26:08 2015 -0500
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Wed Nov 18 12:55:29 2015 -0500

----------------------------------------------------------------------
 Allura/allura/command/show_models.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fae95f39/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index d651383..917f516 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -211,8 +211,8 @@ class EnsureIndexCommand(base.Command):
         main_session_classes = [M.main_orm_session, M.repository_orm_session,
                                 M.task_orm_session]
         if asbool(self.config.get('activitystream.recording.enabled', False)):
-            from activitystream.storage.mingstorage import activity_orm_session
-            main_session_classes.append(activity_orm_session)
+            from activitystream.storage.mingstorage import activity_odm_session
+            main_session_classes.append(activity_odm_session)
         self.basic_setup()
         # by db, then collection name
         main_indexes = defaultdict(lambda: defaultdict(list))


[3/3] allura git commit: [#8015] Add the new activitystream update to the requirments.txt

Posted by he...@apache.org.
[#8015] Add the new activitystream update to the requirments.txt


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/853240a7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/853240a7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/853240a7

Branch: refs/heads/master
Commit: 853240a743e4d2f166ba8e32a79b02d345033dc8
Parents: fae95f3
Author: Heith Seewald <hs...@hsmb.local>
Authored: Wed Nov 18 12:55:03 2015 -0500
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Wed Nov 18 12:55:29 2015 -0500

----------------------------------------------------------------------
 requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/853240a7/requirements.txt
----------------------------------------------------------------------
diff --git a/requirements.txt b/requirements.txt
index 55f2921..4b3945b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-ActivityStream==0.2.0
+ActivityStream==0.2.1
 BeautifulSoup==3.2.0
 beautifulsoup4==4.4.0
 Beaker==1.6.4