changeset 613:d8f961381f75

GenshiTutorial: fix storing of submissions.
author cmlenz
date Wed, 29 Aug 2007 19:34:39 +0000
parents 09de73cae3d5
children 0dc152d128f5
files examples/tutorial/geddit/controller.py
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/examples/tutorial/geddit/controller.py
+++ b/examples/tutorial/geddit/controller.py
@@ -18,15 +18,15 @@
 
     def __init__(self, data):
         self.data = data
-        self.submission_lookup = {}
-        self.comment_lookup = {}
+        self._submission_lookup = {}
+        self._comment_lookup = {}
         for submission in self.data:
-            self.submission_lookup[submission.code] = submission
+            self._submission_lookup[submission.code] = submission
             for comment in submission.comments:
-                self.comment_lookup[comment.code] = comment
+                self._comment_lookup[comment.code] = comment
                 def _add_replies(comment):
                     for reply in comment.replies:
-                        self.comment_lookup[reply.code] = reply
+                        self._comment_lookup[reply.code] = reply
                 _add_replies(comment)
 
     @cherrypy.expose
@@ -37,7 +37,7 @@
     @cherrypy.expose
     @template.output('info.html', method='html', doctype='html')
     def info(self, code):
-        submission = self.submission_lookup.get(code)
+        submission = self._submission_lookup.get(code)
         if not submission:
             raise cherrypy.NotFound()
         return template.render(submission=submission)
@@ -53,6 +53,7 @@
                 data = form.to_python(data)
                 submission = Submission(**data)
                 self.data.append(submission)
+                self._comment_lookup[comment.code] = comment
                 raise cherrypy.HTTPRedirect('/')
             except Invalid, e:
                 errors = e.unpack_errors()
@@ -64,7 +65,7 @@
     @cherrypy.expose
     @template.output('comment.html', method='html', doctype='html')
     def comment(self, code, cancel=False, **data):
-        submission = self.submission_lookup.get(code)
+        submission = self._submission_lookup.get(code)
         if not submission:
             raise cherrypy.NotFound()
         if cherrypy.request.method == 'POST':
@@ -74,7 +75,7 @@
             try:
                 data = form.to_python(data)
                 comment = submission.add_comment(**data)
-                self.comment_lookup[comment.code] = comment
+                self._comment_lookup[comment.code] = comment
                 raise cherrypy.HTTPRedirect('/')
             except Invalid, e:
                 errors = e.unpack_errors()
@@ -87,7 +88,7 @@
     @cherrypy.expose
     @template.output('comment.html', method='html', doctype='html')
     def reply(self, code, cancel=False, **data):
-        comment = self.comment_lookup.get(code)
+        comment = self._comment_lookup.get(code)
         submission = comment.submission
         if not comment:
             raise cherrypy.NotFound()
@@ -98,7 +99,7 @@
             try:
                 data = form.to_python(data)
                 comment = comment.add_reply(**data)
-                self.comment_lookup[comment.code] = comment
+                self._comment_lookup[comment.code] = comment
                 raise cherrypy.HTTPRedirect('/')
             except Invalid, e:
                 errors = e.unpack_errors()
Copyright (C) 2012-2017 Edgewall Software