changeset 488:8462764f59d2

contenttype_groups structure moved under config
author Akash Sinha <akash2607@gmail.com>
date Wed, 13 Jul 2011 21:43:58 +0530
parents bdf613f0a062
children 59f8fd972e16
files MoinMoin/apps/frontend/views.py MoinMoin/config/__init__.py MoinMoin/items/__init__.py
diffstat 3 files changed, 56 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Wed Jul 13 05:00:01 2011 +0530
+++ b/MoinMoin/apps/frontend/views.py	Wed Jul 13 21:43:58 2011 +0530
@@ -43,7 +43,7 @@
 from MoinMoin.items import Item, NonExistent
 from MoinMoin.items import ROWS_META, COLS, ROWS_DATA
 from MoinMoin import config, user, wikiutil
-from MoinMoin.config import ACTION, COMMENT, CONTENTTYPE, ITEMLINKS, ITEMTRANSCLUSIONS, NAME
+from MoinMoin.config import ACTION, COMMENT, CONTENTTYPE, ITEMLINKS, ITEMTRANSCLUSIONS, NAME, CONTENTTYPE_GROUPS
 from MoinMoin.util.forms import make_generator
 from MoinMoin.util import crypto
 from MoinMoin.security.textcha import TextCha, TextChaizedForm, TextChaValid
@@ -499,11 +499,10 @@
     selected_groups = passed_fields.keys()
     index = item.flat_index(startswith, selected_groups)
 
-    nonexistent_item = NonExistent(item)
-    contenttype_groups = nonexistent_item.contenttype_groups
-    contenttype_groups = [(gname, ["%s" % ctlabel for ctname, ctlabel in contenttypes]) for gname, contenttypes in contenttype_groups]
+    ct_groups = CONTENTTYPE_GROUPS
+    ct_groups = [(gname, ["%s" % ctlabel for ctname, ctlabel in contenttypes]) for gname, contenttypes in ct_groups]
     if not selected_groups:
-        selected_groups = [gname for gname, ctlabels in contenttype_groups]
+        selected_groups = [gname for gname, ctlabels in ct_groups]
 
     initials = item.name_initial(item.flat_index())
     initials = [initial.upper() for initial in initials]
@@ -519,7 +518,7 @@
                            initials=initials,
                            startswith=startswith,
                            selected_groups=selected_groups,
-                           contenttype_groups=contenttype_groups,
+                           contenttype_groups=ct_groups,
                           )
 
 
--- a/MoinMoin/config/__init__.py	Wed Jul 13 05:00:01 2011 +0530
+++ b/MoinMoin/config/__init__.py	Wed Jul 13 21:43:58 2011 +0530
@@ -116,3 +116,50 @@
 # some backends may use this also for other purposes.
 HASH_ALGORITHM = 'sha1'
 
+# structure for contenttype groups
+CONTENTTYPE_GROUPS = [
+    ('markup text items', [
+        ('text/x.moin.wiki;charset=utf-8', 'Wiki (MoinMoin)'),
+        ('text/x.moin.creole;charset=utf-8', 'Wiki (Creole)'),
+        ('text/x-mediawiki;charset=utf-8', 'Wiki (MediaWiki)'),
+        ('text/x-rst;charset=utf-8', 'ReST'),
+        ('application/docbook+xml;charset=utf-8', 'DocBook'),
+        ('text/html;charset=utf-8', 'HTML'),
+    ]),
+    ('other text items', [
+        ('text/plain;charset=utf-8', 'plain text'),
+        ('text/x-diff;charset=utf-8', 'diff/patch'),
+        ('text/x-python;charset=utf-8', 'python code'),
+        ('text/csv;charset=utf-8', 'csv'),
+        ('text/x-irclog;charset=utf-8', 'IRC log'),
+    ]),
+    ('image items', [
+        ('image/jpeg', 'JPEG'),
+        ('image/png', 'PNG'),
+        ('image/svg+xml', 'SVG'),
+    ]),
+    ('audio items', [
+        ('audio/wave', 'WAV'),
+        ('audio/ogg', 'OGG'),
+        ('audio/mpeg', 'MP3'),
+        ('audio/webm', 'WebM'),
+    ]),
+    ('video items', [
+        ('video/ogg', 'OGG'),
+        ('video/webm', 'WebM'),
+        ('video/mp4', 'MP4'),
+    ]),
+    ('drawing items', [
+        ('application/x-twikidraw', 'TDRAW'),
+        ('application/x-anywikidraw', 'ADRAW'),
+        ('application/x-svgdraw', 'SVGDRAW'),
+    ]),
+    ('other items', [
+        ('application/pdf', 'PDF'),
+        ('application/zip', 'ZIP'),
+        ('application/x-tar', 'TAR'),
+        ('application/x-gtar', 'TGZ'),
+        ('application/octet-stream', 'binary file'),
+    ]),
+]
+
--- a/MoinMoin/items/__init__.py	Wed Jul 13 05:00:01 2011 +0530
+++ b/MoinMoin/items/__init__.py	Wed Jul 13 21:43:58 2011 +0530
@@ -68,7 +68,7 @@
                             IS_SYSITEM, SYSITEM_VERSION,  USERGROUP, SOMEDICT, \
                             CONTENTTYPE, SIZE, LANGUAGE, ITEMLINKS, ITEMTRANSCLUSIONS, \
                             TAGS, ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \
-                            HASH_ALGORITHM
+                            HASH_ALGORITHM, CONTENTTYPE_GROUPS
 
 COLS = 80
 ROWS_DATA = 20
@@ -583,12 +583,11 @@
         if selected_groups is set, items whose contentype belonging to the selected contenttype_groups, are filtered.
         """
         index = self.get_index()
-        nonexistent_item = NonExistent(self)
         if not selected_groups:
-            selected_groups = [gname for (gname, contenttypes) in nonexistent_item.contenttype_groups]
+            selected_groups = [gname for (gname, contenttypes) in CONTENTTYPE_GROUPS]
 
         ctypes = [[ctype for ctype, clabel in contenttypes]
-                  for gname, contenttypes in nonexistent_item.contenttype_groups
+                  for gname, contenttypes in CONTENTTYPE_GROUPS
                   if gname in selected_groups]
 
         ctypes_chain = itertools.chain(*ctypes)
@@ -631,53 +630,6 @@
         return initials
 
 class NonExistent(Item):
-    contenttype_groups = [
-        ('markup text items', [
-            ('text/x.moin.wiki;charset=utf-8', 'Wiki (MoinMoin)'),
-            ('text/x.moin.creole;charset=utf-8', 'Wiki (Creole)'),
-            ('text/x-mediawiki;charset=utf-8', 'Wiki (MediaWiki)'),
-            ('text/x-rst;charset=utf-8', 'ReST'),
-            ('application/docbook+xml;charset=utf-8', 'DocBook'),
-            ('text/html;charset=utf-8', 'HTML'),
-        ]),
-        ('other text items', [
-            ('text/plain;charset=utf-8', 'plain text'),
-            ('text/x-diff;charset=utf-8', 'diff/patch'),
-            ('text/x-python;charset=utf-8', 'python code'),
-            ('text/csv;charset=utf-8', 'csv'),
-            ('text/x-irclog;charset=utf-8', 'IRC log'),
-        ]),
-        ('image items', [
-            ('image/jpeg', 'JPEG'),
-            ('image/png', 'PNG'),
-            ('image/svg+xml', 'SVG'),
-        ]),
-        ('audio items', [
-            ('audio/wave', 'WAV'),
-            ('audio/ogg', 'OGG'),
-            ('audio/mpeg', 'MP3'),
-            ('audio/webm', 'WebM'),
-        ]),
-        ('video items', [
-            ('video/ogg', 'OGG'),
-            ('video/webm', 'WebM'),
-            ('video/mp4', 'MP4'),
-        ]),
-        ('drawing items', [
-            ('application/x-twikidraw', 'TDRAW'),
-            ('application/x-anywikidraw', 'ADRAW'),
-            ('application/x-svgdraw', 'SVGDRAW'),
-        ]),
-
-        ('other items', [
-            ('application/pdf', 'PDF'),
-            ('application/zip', 'ZIP'),
-            ('application/x-tar', 'TAR'),
-            ('application/x-gtar', 'TGZ'),
-            ('application/octet-stream', 'binary file'),
-        ]),
-    ]
-
     def do_get(self, force_attachment=False):
         abort(404)
 
@@ -688,7 +640,7 @@
         # XXX think about and add item template support
         return render_template('modify_show_type_selection.html',
                                item_name=self.name,
-                               contenttype_groups=self.contenttype_groups,
+                               contenttype_groups=CONTENTTYPE_GROUPS,
                               )
 
 item_registry.register(NonExistent._factory, Type('application/x-nonexistent'))