xiaq avatar xiaq committed bb94565

Add MoinMoin.constants.itemtypes module.

Comments (0)

Files changed (4)


 from MoinMoin import config, user, util
 from MoinMoin.config import CONTENTTYPE_GROUPS
 from MoinMoin.constants.keys import *
+from MoinMoin.constants.itemtypes import ITEMTYPES
 from MoinMoin.util import crypto
 from MoinMoin.util.interwiki import url_for_item
 from MoinMoin.search import SearchForm, ValidSearch


+# Copyright: 2012 MoinMoin:CheerXiao
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+MoinMoin - itemtype related constants
+from __future__ import absolute_import, division
+from collections import namedtuple
+from MoinMoin.i18n import L_
+ItemtypeSpec = namedtuple('ItemtypeSpec', 'itemtype display_name description')
+ITEMTYPE_DEFAULT = u'default'
+ITEMTYPE_TICKET = u'ticket'
+ITEMTYPE_BLOG = u'blog'
+ITEMTYPE_BLOGENTRY = u'blogentry'
+# TODO Perhaps construct this list from the item_registry instead of having it
+# as a constant, which is more extensible (we can have itemtype plugins in
+# future and plugged-in itemtypes will be included too). Two more fields (ie.
+# display name and description) are needed in the registry then to support the
+# automatic construction.
+    ItemtypeSpec(ITEMTYPE_DEFAULT, L_('Default'), L_('Wiki item')),
+    ItemtypeSpec(ITEMTYPE_TICKET, L_('Ticket'), L_('Ticket item')),
+    ItemtypeSpec(ITEMTYPE_BLOG, L_('Blog'), L_('Blog item')),
+    ItemtypeSpec(ITEMTYPE_BLOGENTRY, L_('Blog entry'), L_('Blog entry item')),


 from MoinMoin.constants.contenttypes import charset, CONTENTTYPE_GROUPS
+from MoinMoin.constants.itemtypes import ITEMTYPES
 from .content import Content, NonExistentContent, Draw, content_registry
         return self._select_itemtype()
     def _select_itemtype(self):
-        # TODO Construct this list from the item_registry. Two more fields (ie.
-        # display name and description) are needed in the registry then to
-        # support the automatic construction.
-        ITEMTYPES = [
-            (u'default', u'Default', 'Wiki item'),
-            (u'ticket', u'Ticket', 'Ticket item'),
-            (u'blog', u'Blog', 'Blog item'),
-            (u'blogentry', u'Blog entry', 'Blog entry item'),
-        ]
         return render_template('modify_select_itemtype.html',


 {{ _("Item '%(name)s' does not exist (yet), but you can try creating it now. Please select the type of the item you want to create.", name=item_name) }}
 <table class="zebra">
-    {% for itname, itlabel, itdesc in itemtypes %}
+    {% for it in itemtypes %}
-            <a href="{{ url_for('frontend.modify_item', item_name=item_name, itemtype=itname) }}">{{ itlabel }}</a> - {{ itdesc }}
+            <a href="{{ url_for('frontend.modify_item', item_name=item_name, itemtype=it.itemtype) }}">{{ it.display_name }}</a> - {{ it.description }}
     {% endfor %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.