changeset 1677:d74b9e4d41e5

items/__init__.py: Split helper methods from_item and from_requst in Item._ModifyForm to a separate BaseModifyForm class.
author Cheer Xiao <xiaqqaix@gmail.com>
date Tue, 14 Aug 2012 00:40:06 +0800
parents 36ae694c4122
children 51e1e8b0b7f2
files MoinMoin/items/__init__.py
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Mon Aug 13 13:50:18 2012 +0200
+++ b/MoinMoin/items/__init__.py	Tue Aug 14 00:40:06 2012 +0800
@@ -136,6 +136,21 @@
     tags = Tags
 
 
+class BaseModifyForm(BaseChangeForm):
+    @classmethod
+    def from_item(cls, item):
+        form = cls.from_defaults()
+        TextCha(form).amend_form()
+        form._load(item)
+        return form
+
+    @classmethod
+    def from_request(cls, request):
+        form = cls.from_flat(request.form.items() + request.files.items())
+        TextCha(form).amend_form()
+        return form
+
+
 class Item(object):
     """ Highlevel (not storage) Item, wraps around a storage Revision"""
     @classmethod
@@ -304,7 +319,7 @@
 
         return self._save(meta, data, contenttype_guessed=contenttype_guessed, comment=comment)
 
-    class _ModifyForm(BaseChangeForm):
+    class _ModifyForm(BaseModifyForm):
         """Base class for ModifyForm of Item subclasses."""
         meta_form = BaseMetaForm
         extra_meta_text = JSON.using(label=L_("Extra MetaData (JSON)")).with_properties(rows=ROWS_META, cols=COLS)
@@ -329,19 +344,6 @@
             comment = self['comment'].value
             return meta, data, contenttype_guessed, comment
 
-        @classmethod
-        def from_item(cls, item):
-            form = cls.from_defaults()
-            TextCha(form).amend_form()
-            form._load(item)
-            return form
-
-        @classmethod
-        def from_request(cls, request):
-            form = cls.from_flat(request.form.items() + request.files.items())
-            TextCha(form).amend_form()
-            return form
-
     def do_modify(self):
         """
         Handle +modify requests, both GET and POST.