• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

修訂b4023f78c60fd8fc95bfc805bcb010a8f0bc4034 (tree)
時間2012-02-23 06:00:49
作者Tim Van Steenburgh <tvansteenburgh@geek...>
CommiterTim Van Steenburgh

Log Message

[#3749] Run project imports and updates as site admin.

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@geek.net>

Change Summary

差異

--- a/scripts/project-import.py
+++ b/scripts/project-import.py
@@ -9,7 +9,8 @@ import sys
99 import colander as col
1010
1111 from ming.orm import session, ThreadLocalORMSession
12-from pylons import g
12+from pylons import c, g
13+from tg import config
1314
1415 from allura import model as M
1516 from allura.lib import helpers as h
@@ -158,7 +159,7 @@ def trove_ids(orig, new_):
158159 if new_ is None: return orig
159160 return set(t._id for t in list(new_))
160161
161-def create_project(p, nbhd, options):
162+def create_project(p, nbhd, user, options):
162163 worker_name = multiprocessing.current_process().name
163164 M.session.artifact_orm_session._get().skip_mod_date = True
164165 shortname = p.shortname or p.name.shortname
@@ -208,15 +209,15 @@ def create_project(p, nbhd, options):
208209 granted_to_project_id=project._id,
209210 granted_by_neighborhood_id=nbhd._id)
210211 project.notifications_disabled = False
211- with h.push_context(project._id):
212+ with h.push_config(c, project=project, user=user):
212213 ThreadLocalORMSession.flush_all()
213214 g.post_event('project_updated')
214215 session(project).clear()
215216 return 0
216217
217-def create_projects(projects, nbhd, options):
218+def create_projects(projects, nbhd, user, options):
218219 for p in projects:
219- r = create_project(Object(p), nbhd, options)
220+ r = create_project(Object(p), nbhd, user, options)
220221 if r != 0:
221222 sys.exit(r)
222223
@@ -228,6 +229,7 @@ def main(options):
228229 nbhd = M.Neighborhood.query.get(name=options.neighborhood)
229230 if not nbhd:
230231 return 'Invalid neighborhood "%s".' % options.neighborhood
232+ admin = M.User.query.get(username=config.get('sfx.api.siteadmin', 'sf-robot'))
231233
232234 data = json.load(open(options.file, 'r'))
233235 project = Project()
@@ -242,7 +244,7 @@ def main(options):
242244 jobs = []
243245 for i in range(options.nprocs):
244246 p = multiprocessing.Process(target=create_projects,
245- args=(chunks[i], nbhd, options), name='worker-' + str(i+1))
247+ args=(chunks[i], nbhd, admin, options), name='worker-' + str(i+1))
246248 jobs.append(p)
247249 p.start()
248250