changeset 1990:22441b6366e6

improve use of is_new in Ticket.do_modify a bit
author Cheer Xiao <xiaqqaix@gmail.com>
date Tue, 12 Feb 2013 17:43:27 +0800
parents ff77f6d8da38
children 38e79cd2b320
files MoinMoin/items/ticket.py
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/ticket.py	Tue Feb 12 17:16:07 2013 +0800
+++ b/MoinMoin/items/ticket.py	Tue Feb 12 17:43:27 2013 +0800
@@ -107,6 +107,8 @@
             return self.do_modify()
 
     def do_modify(self):
+        is_new = isinstance(self.content, NonExistentContent)
+
         if request.method in ['GET', 'HEAD']:
             form = TicketForm.from_item(self)
         elif request.method == 'POST':
@@ -119,10 +121,7 @@
                     CONTENTTYPE: 'text/x.moin.wiki;charset=utf-8',
                 })
 
-                if isinstance(self.content, NonExistentContent):
-                    data = u''
-                else:
-                    data = self.content.data_storage_to_internal(self.content.data)
+                data = u'' if is_new else self.content.data_storage_to_internal(self.content.data)
                 message = form['message'].value
                 if message:
                     data += message_markup(message)
@@ -133,13 +132,11 @@
                     abort(403)
                 else:
                     return redirect(url_for('.show_item', item_name=self.name))
-        if isinstance(self.content, NonExistentContent):
-            is_new = True
+        if is_new:
             # XXX suppress the "foo doesn't exist. Create it?" dummy content
             data_rendered = None
             form.submit_label = L_('Submit ticket')
         else:
-            is_new = False
             data_rendered = Markup(self.content._render_data())
 
         return render_template(self.modify_template,