You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/07/02 21:44:33 UTC

[1/3] git commit: [#4657] update for solr changes

Updated Branches:
  refs/heads/db/4657 [created] d9b5b87e4


[#4657] update for solr changes


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

Branch: refs/heads/db/4657
Commit: ea385820156ba664ecc3b8f0ca8260e23b59acaa
Parents: b3f80f6
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Jun 10 19:46:03 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Jul 2 19:44:19 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ea385820/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 62b1b3a..ba00f3f 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -115,7 +115,7 @@ class Globals(object):
         if asbool(config.get('solr.mail.mock')):
             self.solr_mail = MockSOLR()
         elif self.solr_mail_server:
-            self.solr_mail = Solr(self.solr_mail_server, timeout=int(config.get('solr.mail.timeout', 60)))
+            self.solr_mail = make_solr_from_config(self.solr_mail_server, timeout=int(config.get('solr.mail.timeout', 60)))
         self.use_queue = asbool(config.get('use_queue', False))
 
         # Load login/logout urls; only used for SFX logins


[2/3] git commit: [#4657] ticket:243 Add solr 'mail' core to the globals

Posted by br...@apache.org.
[#4657] ticket:243 Add solr 'mail' core to the globals


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

Branch: refs/heads/db/4657
Commit: b3f80f689ea738a15e72c0db98c0b4ecd294d605
Parents: ebc7e43
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 7 13:23:16 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Jul 2 19:44:19 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py | 6 ++++++
 Allura/test.ini                  | 1 +
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b3f80f68/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index bdcacf7..62b1b3a 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -110,6 +110,12 @@ class Globals(object):
         else: # pragma no cover
             self.solr = None
             self.solr_short_timeout = None
+        # SOLR mail core
+        self.solr_mail_server = config.get('solr.mail.server')
+        if asbool(config.get('solr.mail.mock')):
+            self.solr_mail = MockSOLR()
+        elif self.solr_mail_server:
+            self.solr_mail = Solr(self.solr_mail_server, timeout=int(config.get('solr.mail.timeout', 60)))
         self.use_queue = asbool(config.get('use_queue', False))
 
         # Load login/logout urls; only used for SFX logins

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b3f80f68/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index f1bd5f2..fad2acb 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -54,6 +54,7 @@ activitystream.timeline_collection = timelines
 activitystream.enabled = true
 
 solr.mock = true
+solr.mail.mock = true
 amqp.mock = true
 smtp.mock = true
 


[3/3] git commit: [#4657] refactor File.serve to a general helper method

Posted by br...@apache.org.
[#4657] refactor File.serve to a general helper method


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

Branch: refs/heads/db/4657
Commit: d9b5b87e4cb717a394fc41237edc96fcd9da3d92
Parents: ea38582
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Jun 10 22:31:12 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Jul 2 19:44:20 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/utils.py        | 25 ++++++++++++++++++++++++-
 Allura/allura/model/filesystem.py | 20 +++++---------------
 2 files changed, 29 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d9b5b87e/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 7c490e2..a88511c 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -37,7 +37,7 @@ from formencode import Invalid
 from tg.decorators import before_validate
 from pylons import response
 from pylons import tmpl_context as c
-from paste.deploy.converters import asbool
+from paste.deploy.converters import asbool, asint
 from paste.httpheaders import CACHE_CONTROL, EXPIRES
 from webhelpers.html import literal
 from webob import exc
@@ -471,3 +471,26 @@ def take_while_true(source):
         yield x
         x = source()
 
+
+def serve_file(fp, filename, content_type, last_modified=None, cache_expires=None, size=None, embed=True):
+    '''Sets the response headers and serves as a wsgi iter'''
+    pylons.response.headers['Content-Type'] = ''
+    pylons.response.content_type = content_type.encode('utf-8')
+    pylons.response.cache_expires = cache_expires or asint(tg.config.get('files_expires_header_secs', 60 * 60))
+    pylons.response.last_modified = last_modified
+    if size:
+        pylons.response.content_length = size
+    if 'Pragma' in pylons.response.headers:
+        del pylons.response.headers['Pragma']
+    if 'Cache-Control' in pylons.response.headers:
+        del pylons.response.headers['Cache-Control']
+    if not embed:
+        pylons.response.headers.add(
+            'Content-Disposition',
+            'attachment;filename="%s"' % filename.encode('utf-8'))
+    # http://code.google.com/p/modwsgi/wiki/FileWrapperExtension
+    block_size = 4096
+    if 'wsgi.file_wrapper' in tg.request.environ:
+        return tg.request.environ['wsgi.file_wrapper'](fp, block_size)
+    else:
+        return iter(lambda: fp.read(block_size), '')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d9b5b87e/Allura/allura/model/filesystem.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/filesystem.py b/Allura/allura/model/filesystem.py
index c56e595..1bb0087 100644
--- a/Allura/allura/model/filesystem.py
+++ b/Allura/allura/model/filesystem.py
@@ -23,7 +23,6 @@ import pylons
 import PIL
 from gridfs import GridFS
 from tg import config
-from paste.deploy.converters import asint
 
 from ming import schema
 from ming.orm import session, FieldProperty
@@ -109,20 +108,11 @@ class File(MappedClass):
 
     def serve(self, embed=True):
         '''Sets the response headers and serves as a wsgi iter'''
-        fp = self.rfile()
-        pylons.response.headers['Content-Type'] = ''
-        pylons.response.content_type = self.content_type.encode('utf-8')
-        pylons.response.cache_expires = asint(config.get('files_expires_header_secs', 60 * 60))
-        pylons.response.last_modified = self._id.generation_time
-        if 'Pragma' in pylons.response.headers:
-            del pylons.response.headers['Pragma']
-        if 'Cache-Control' in pylons.response.headers:
-            del pylons.response.headers['Cache-Control']
-        if not embed:
-            pylons.response.headers.add(
-                'Content-Disposition',
-                'attachment;filename="%s"' % self.filename.encode('utf-8'))
-        return iter(fp)
+        gridfs_file = self.rfile()
+        return utils.serve_file(gridfs_file, self.filename, self.content_type,
+                                last_modified=self._id.generation_time,
+                                size=gridfs_file.length,
+                                embed=embed)
 
     @classmethod
     def save_thumbnail(cls, filename, image,