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/08/21 22:12:26 UTC

[10/50] git commit: [#3154] ticket:394 Set up context before calling bulk_export

[#3154] ticket:394 Set up context before calling bulk_export

Also, use controller's method inside ForgeLink's bulk_export()
to get app's json representation to avoid code duplication.


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

Branch: refs/heads/db/3154b
Commit: 31c192a0ad25e733297020722c7a25316837615c
Parents: e4b392a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Jul 23 13:48:26 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Aug 21 18:12:23 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/export_tasks.py |  3 ++-
 ForgeLink/forgelink/link_main.py    | 10 +++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/31c192a0/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 672f51b..9001500 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -56,7 +56,8 @@ def bulk_export(project_shortname, tools, username):
         try:
             path = create_export_dir(project)
             with open(os.path.join(path, '%s.json' % tool), 'w') as f:
-                app.bulk_export(f)
+                with h.push_context(project._id, app_config_id=app.config._id):
+                    app.bulk_export(f)
         except:
             log.error('Something went wrong during export of %s' % tool, exc_info=True)
             not_exported_tools.append(tool)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/31c192a0/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 2350e84..b5dd0d4 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -17,10 +17,11 @@
 
 #-*- python -*-
 import logging
+import json
 
 # Non-stdlib imports
 import pkg_resources
-from tg import expose, validate, redirect, response, flash
+from tg import expose, validate, redirect, response, flash, jsonify
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request
 
@@ -95,7 +96,7 @@ class ForgeLinkApp(Application):
         super(ForgeLinkApp, self).uninstall(project)
 
     def bulk_export(self, f):
-        f.write('{"url": "%s"}' % self.config.options.get('url', 'test'))
+        json.dump(RootRestController().link_json(), f, cls=jsonify.GenericJSON)
 
 
 class RootController(BaseController):
@@ -132,9 +133,12 @@ class RootRestController(BaseController):
     def _check_security(self):
         require_access(c.app, 'read')
 
+    def link_json(self):
+        return dict(url=c.app.config.options.get('url'))
+
     @expose('json:')
     def index(self, url='', **kw):
         if (request.method == 'POST') and (url != ''):
             require_access(c.app, 'configure')
             c.app.config.options.url = url
-        return dict(url=c.app.config.options.get('url'))
+        return self.link_json()