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 17:26:54 UTC
[12/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/e2b56bbd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e2b56bbd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e2b56bbd
Branch: refs/heads/db/3154b
Commit: e2b56bbdd9b5a83ab983b3ba4c773b71ee1c7117
Parents: 6a12be7
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 15:25:55 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/e2b56bbd/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/e2b56bbd/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()