Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /sandbox/wiki/wiki20/controllers/root.py [r4089] .. [r4090] Maximize Restore

  Switch to side-by-side view

--- a/sandbox/wiki/wiki20/controllers/root.py
+++ b/sandbox/wiki/wiki20/controllers/root.py
@@ -1,7 +1,7 @@
 
 from wiki20.lib.base import BaseController
 from tg import expose, flash
-#from tg import redirect, validate
+import tg
 from wiki20.model import DBSession
 from wiki20.model.page import Page
 from genshi import XML
@@ -16,4 +16,20 @@
     @expose(template="wiki20.templates.edit")
     def edit(self, pagename):
         page = DBSession.query(Page).filter_by(pagename=pagename).one()
-        return dict(page=page)+        return dict(page=page)
+
+    @expose()
+    def save(self, pagename, data, submit):
+        page = DBSession.query(Page).filter_by(pagename=pagename).one()
+        page.data = data
+        
+        DBSession.flush()  # Sends changes to the database
+        DBSession.commit() # Tells database to commit changes perminantly
+        
+        # Strictly speaking the above call to flush is not required above, because
+        # commit implies flush, and will flush automatically for you if you
+        # havent done it. 
+        
+        tg.flash("Changes saved!")
+        raise tg.redirect("/", pagename=pagename)
+