allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/3] git commit: [#6267] ticket:360 Restore wiki API POST functionality
Date Wed, 29 May 2013 15:58:07 GMT
[#6267] ticket:360 Restore wiki API POST functionality


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

Branch: refs/heads/master
Commit: a3e7f320c28c641fa60905af08120faac58e5457
Parents: 1af5b40
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri May 24 13:09:46 2013 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon May 27 09:02:18 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/wiki_main.py |   50 ++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a3e7f320/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 94f98a5..650d271 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -702,42 +702,40 @@ class RootRestController(BaseController):
         return PageRestController(title), remainder
 
 
-    @h.vardec
-    @expose()
-    @require_post()
-    def post(self, title, **post_data):
-        page = WM.Page.query.get(
-            app_config_id=c.app.config._id,
-            title=title,
-            deleted=False)
-        if not page:
-            require_access(c.app, 'create')
-            page = WM.Page.upsert(title)
-            page.viewable_by = ['all']
-        else:
-            require_access(page, 'edit')
-        page.text = post_data['text']
-        if 'labels' in post_data:
-            page.labels = post_data['labels'].split(',')
-        page.commit()
-
 class PageRestController(BaseController):
 
     def __init__(self, title):
-        if title is not None:
-            self.page = WM.Page.query.get(app_config_id=c.app.config._id,
-                                          title=h.really_unicode(unquote(title)),
-                                          deleted=False)
-            if self.page is None:
-                raise exc.HTTPNotFound()
+        self.title = h.really_unicode(unquote(title)) if title else None
+        self.page = WM.Page.query.get(app_config_id=c.app.config._id,
+                                      title=self.title,
+                                      deleted=False)
 
     def _check_security(self):
-        require_access(self.page, 'read')
+        if self.page:
+            require_access(self.page, 'read')
 
+    @h.vardec
     @expose('json:')
     def index(self, **kw):
+        if request.method == 'POST':
+            return self._update_page(self.title, **kw)
+        if self.page is None:
+            raise exc.HTTPNotFound()
         return self.page.__json__()
 
+    def _update_page(self, title, **post_data):
+        if not self.page:
+            require_access(c.app, 'create')
+            self.page = WM.Page.upsert(title)
+            self.page.viewable_by = ['all']
+        else:
+            require_access(self.page, 'edit')
+        self.page.text = post_data['text']
+        if 'labels' in post_data:
+            self.page.labels = post_data['labels'].split(',')
+        self.page.commit()
+        return {}
+
 
 class WikiAdminController(DefaultAdminController):
 


Mime
View raw message