allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hei...@apache.org
Subject [06/13] allura git commit: [#7891] ticket:786 Stop sending zarkov events from Allura
Date Thu, 25 Jun 2015 14:43:29 GMT
[#7891] ticket:786 Stop sending zarkov events from Allura


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

Branch: refs/heads/hs/7873
Commit: b71482774b3ff0ae03841fa47a1447eb45da1b5f
Parents: 2e3ac2c
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Jun 3 14:38:36 2015 +0000
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Jun 17 10:39:51 2015 -0400

----------------------------------------------------------------------
 Allura/allura/config/middleware.py         |  8 ----
 Allura/allura/lib/app_globals.py           | 47 ----------------------
 Allura/allura/lib/plugin.py                |  1 -
 Allura/allura/lib/zarkov_helpers.py        | 39 ------------------
 Allura/allura/model/project.py             |  7 ----
 Allura/allura/model/session.py             |  7 ----
 Allura/allura/tests/test_zarkov_helpers.py | 53 -------------------------
 Allura/development.ini                     |  5 ---
 8 files changed, 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 840a39c..ba07cc4 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -117,14 +117,6 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     # Configure the Pylons environment
     load_environment(global_conf, app_conf)
 
-    if config.get('zarkov.host'):
-        try:
-            import zmq
-        except ImportError:
-            raise ImportError, "Unable to import the zmq library. Please"\
-                               " check that zeromq is installed or comment out"\
-                               " the zarkov.host setting in your ini file."
-
     app = tg.TGApp()
 
     for mw_ep in h.iter_entry_points('allura.middleware'):

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 7a13969..2a7ee5c 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -62,7 +62,6 @@ from allura.lib import helpers as h
 from allura.lib.widgets import analytics
 from allura.lib.security import Credentials
 from allura.lib.solr import MockSOLR, make_solr_from_config
-from allura.lib.zarkov_helpers import ZarkovClient
 from allura.model.session import artifact_orm_session
 
 log = logging.getLogger(__name__)
@@ -299,9 +298,6 @@ class Globals(object):
         duration = asint(config.get('neighborhood.cache.duration', 0))
         self.neighborhood_cache = NeighborhoodCache(duration)
 
-        # Zarkov logger
-        self._zarkov = None
-
         # Set listeners to update stats
         statslisteners = []
         for name, ep in self.entry_points['stats'].iteritems():
@@ -356,49 +352,6 @@ class Globals(object):
     def post_event(self, topic, *args, **kwargs):
         allura.tasks.event_tasks.event.post(topic, *args, **kwargs)
 
-    def zarkov_event(
-            self, event_type,
-            user=None, neighborhood=None, project=None, app=None,
-            extra=None):
-        context = dict(
-            user=None,
-            neighborhood=None, project=None, tool=None,
-            mount_point=None,
-            is_project_member=False)
-
-        if not config.get('zarkov.host'):
-            return
-
-        user = user or getattr(c, 'user', None)
-        project = project or getattr(c, 'project', None)
-        app = app or getattr(c, 'app', None)
-        if user:
-            context['user'] = user.username
-        if project:
-            context.update(
-                project=project.shortname,
-                neighborhood=project.neighborhood.url_prefix.strip('/'))
-            if user:
-                cred = Credentials.get()
-                if cred is not None:
-                    for pr in cred.user_roles(user._id, project._id).reaching_roles:
-                        if pr.get('name') and pr.get('name')[0] != '*':
-                            context['is_project_member'] = True
-        if app:
-            context.update(
-                tool=app.config.tool_name,
-                mount_point=app.config.options.mount_point)
-
-        try:
-            if self._zarkov is None:
-                self._zarkov = ZarkovClient(
-                    config.get('zarkov.host', 'tcp://127.0.0.1:6543'))
-            self._zarkov.event(event_type, context, extra)
-        except Exception, ex:
-            self._zarkov = None
-            log.error('Error sending zarkov event(%r): %r', ex, dict(
-                type=event_type, context=context, extra=extra))
-
     @LazyProperty
     def theme(self):
         return plugin.ThemeProvider.get()

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index d66704e..3fc5e87 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -161,7 +161,6 @@ class AuthenticationProvider(object):
             else:
                 self.session['login_expires'] = True
             self.session.save()
-            g.zarkov_event('login', user=user)
             g.statsUpdater.addUserLogin(user)
             user.track_login(self.request)
             # set a non-secure cookie with same expiration as session,

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/lib/zarkov_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/zarkov_helpers.py b/Allura/allura/lib/zarkov_helpers.py
deleted file mode 100644
index 2f136f2..0000000
--- a/Allura/allura/lib/zarkov_helpers.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-import calendar
-from datetime import datetime, timedelta
-
-try:
-    import zmq
-except ImportError:
-    zmq = None
-import bson
-
-
-class ZarkovClient(object):
-
-    def __init__(self, addr):
-        context = zmq.Context.instance()
-        self._sock = context.socket(zmq.PUSH)
-        self._sock.connect(addr)
-
-    def event(self, type, context, extra=None):
-        obj = dict(
-            type=type, context=context, extra=extra)
-        self._sock.send(bson.BSON.encode(obj))
-

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 2ad3be4..2b0566c 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -169,12 +169,6 @@ class TroveCategory(MappedClass):
         )
 
 
-class ProjectMapperExtension(MapperExtension):
-
-    def after_insert(self, obj, st, sess):
-        g.zarkov_event('project_create', project=obj)
-
-
 class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
     '''
     Projects contain tools, subprojects, and their own metadata.  They live
@@ -196,7 +190,6 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
             ('deleted', 'shortname', 'neighborhood_id'),
             ('neighborhood_id', 'is_nbhd_project', 'deleted')]
         unique_indexes = [('neighborhood_id', 'shortname')]
-        extensions = [ProjectMapperExtension]
 
     type_s = 'Project'
 

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index eb1f4ba..3399456 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -133,13 +133,6 @@ class ArtifactSessionExtension(ManagedSessionExtension):
                 log.exception(
                     "Failed to update artifact references. Is this a borked project migration?")
             self.update_index(self.objects_deleted, arefs)
-            for obj in self.objects_added:
-                g.zarkov_event('create', extra=obj.index_id())
-            for obj in self.objects_modified:
-                g.zarkov_event('modify', extra=obj.index_id())
-            for obj in self.objects_deleted:
-                g.zarkov_event('delete', extra=obj.index_id())
-
         super(ArtifactSessionExtension, self).after_flush(obj)
 
     def update_index(self, objects_deleted, arefs):

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/allura/tests/test_zarkov_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_zarkov_helpers.py b/Allura/allura/tests/test_zarkov_helpers.py
deleted file mode 100644
index 2a6cb38..0000000
--- a/Allura/allura/tests/test_zarkov_helpers.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- coding: utf-8 -*-
-
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-import unittest
-from calendar import timegm
-from datetime import datetime
-
-import bson
-import mock
-
-from allura.lib import zarkov_helpers as zh
-
-
-class TestZarkovClient(unittest.TestCase):
-
-    def setUp(self):
-        addr = 'tcp://0.0.0.0:0'
-        ctx = mock.Mock()
-        self.socket = mock.Mock()
-        ctx.socket = mock.Mock(return_value=self.socket)
-        PUSH = mock.Mock()
-        with mock.patch('allura.lib.zarkov_helpers.zmq') as zmq:
-            zmq.PUSH = PUSH
-            zmq.Context.instance.return_value = ctx
-            self.client = zh.ZarkovClient(addr)
-        zmq.Context.instance.assert_called_once_with()
-        ctx.socket.assert_called_once_with(PUSH)
-        self.socket.connect.assert_called_once_with(addr)
-
-    def test_event(self):
-        self.client.event('test', dict(user='testuser'))
-        obj = bson.BSON.encode(dict(
-            type='test',
-            context=dict(user='testuser'),
-            extra=None))
-        self.socket.send.assert_called_once_with(obj)
-

http://git-wip-us.apache.org/repos/asf/allura/blob/b7148277/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index c81ed24..9146033 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -371,11 +371,6 @@ ming.project.uri = mongodb://127.0.0.1:27017/project-data
 ming.project.auto_ensure_indexes = False
 ming.task.uri = mongodb://127.0.0.1:27017/task
 ming.task.auto_ensure_indexes = False
-;ming.zarkov.uri = mongodb://127.0.0.1:27017/zarkov
-;ming.zarkov.auto_ensure_indexes = False
-
-; Zarkov host setting, requires the zarkov and gevent libraries.
-;zarkov.host = tcp://127.0.0.1:9000
 
 ; A float from 0-1 representing a % of requests to measure timing on.
 ; Sampled requests will have timing logged to stats.log (can change file in [handler_timermiddleware]
logging section)


Mime
View raw message