You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2012/11/20 22:12:50 UTC
git commit: [#5265] WIP
Updated Branches:
refs/heads/tv/5265 [created] 49a86c428
[#5265] WIP
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/49a86c42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/49a86c42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/49a86c42
Branch: refs/heads/tv/5265
Commit: 49a86c428269d8f5d7cc1c6ac87c17386c28f022
Parents: 7eb7956
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Nov 20 21:12:27 2012 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Nov 20 21:12:27 2012 +0000
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/49a86c42/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 1789855..df7384a 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -42,6 +42,7 @@ from allura.lib.zarkov_helpers import ZarkovClient, zmq
log = logging.getLogger(__name__)
+
class ForgeMarkdown(markdown.Markdown):
def convert(self, source):
try:
@@ -53,6 +54,28 @@ class ForgeMarkdown(markdown.Markdown):
return h.html.literal(u"""<p><strong>ERROR!</strong> The markdown supplied could not be parsed correctly.
Did you forget to surround a code snippet with "~~~~"?</p><pre>%s</pre>""" % escaped)
+
+class Solr(pysolr.Solr):
+ _add = pysolr.Solr.add
+ _delete = pysolr.Solr.delete
+
+ def __init__(self, server, autocommit=True):
+ super(Solr, self).__init__(server)
+ self.autocommit = autocommit
+
+ def add(self, *args, **kw):
+ if 'commit' not in kw:
+ kw['commit'] = self.autocommit
+ log.info('Solr.add(commit=%s)' % kw['commit'])
+ return self._add(*args, **kw)
+
+ def delete(self, *args, **kw):
+ if 'commit' not in kw:
+ kw['commit'] = self.autocommit
+ log.info('Solr.delete(commit=%s)' % kw['commit'])
+ return self.delete(*args, **kw)
+
+
class Globals(object):
"""Container for objects available throughout the life of the application.
@@ -72,7 +95,7 @@ class Globals(object):
if asbool(config.get('solr.mock')):
self.solr = MockSOLR()
elif self.solr_server:
- self.solr = pysolr.Solr(self.solr_server)
+ self.solr = Solr(self.solr_server, autocommit=asbool(config.get('solr.autocommit', True)))
else: # pragma no cover
self.solr = None
self.use_queue = asbool(config.get('use_queue', False))