Commits

xiaq committed 78b7a11

use constants in MoinMoin.constans.{item,content}types more

  • Participants
  • Parent commits 77d7c15

Comments (0)

Files changed (6)

MoinMoin/constants/contenttypes.py

 
 CONTENTTYPE_USER = u'application/x.moin.userprofile'
 CONTENTTYPE_DEFAULT = u'application/octet-stream'
+CONTENTTYPE_NONEXISTENT = u'application/x-nonexistent'
 
 
 GROUP_MARKUP_TEXT = 'markup text items'

MoinMoin/converter/docbook_out.py

 logging = log.getLogger(__name__)
 
 from MoinMoin.util.tree import html, moin_page, xlink, docbook, xml
+from MoinMoin.constants.contenttypes import CONTENTTYPE_NONEXISTENT
 
 
 class Converter(object):
         """
         href = element.get(xlink.href, None)
         attrib = {}
-        mimetype = Type(_type=element.get(moin_page.type_, 'application/x-nonexistent'))
+        mimetype = Type(_type=element.get(moin_page.type_, CONTENTTYPE_NONEXISTENT))
         if href:
             attrib[docbook.fileref] = href
             if Type('image/').issupertype(mimetype):

MoinMoin/converter/html_out.py

 from MoinMoin import wikiutil
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.util.tree import html, moin_page, xlink, xml, Name
+from MoinMoin.constants.contenttypes import CONTENTTYPE_NONEXISTENT
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
         # TODO: maybe IE8 would display transcluded external pages if we could do <object... type="text/html" ...>
         href = elem.get(xlink.href, None)
         attrib = {}
-        mimetype = Type(_type=elem.get(moin_page.type_, 'application/x-nonexistent'))
+        mimetype = Type(_type=elem.get(moin_page.type_, CONTENTTYPE_NONEXISTENT))
         # Get the object type
         obj_type = self.eval_object_type(mimetype, href)
 

MoinMoin/converter/nonexistent_in.py

 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.util.iri import Iri
 from MoinMoin.util.tree import moin_page, xlink
+from MoinMoin.constants.contenttypes import CONTENTTYPE_NONEXISTENT
 
 
 class Converter(object):
 
 from . import default_registry
 from MoinMoin.util.mime import Type, type_moin_document
-default_registry.register(Converter._factory, Type('application/x-nonexistent'), type_moin_document)
+default_registry.register(Converter._factory, Type(CONTENTTYPE_NONEXISTENT), type_moin_document)

MoinMoin/items/__init__.py

     CONTENTTYPE, SIZE, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT,
     HASH_ALGORITHM, ITEMID, REVID, DATAID, CURRENT, PARENTID
     )
-from MoinMoin.constants.contenttypes import charset
+from MoinMoin.constants.contenttypes import charset, CONTENTTYPE_NONEXISTENT
+from MoinMoin.constants.itemtypes import (
+    ITEMTYPE_NONEXISTENT, ITEMTYPE_USERPROFILE, ITEMTYPE_DEFAULT,
+    )
 
 from .content import content_registry, Content, NonExistentContent, Draw
 
     def __init__(self, item, itemtype=None, contenttype=None):
         self.item = item
         self.meta = {
-            ITEMTYPE: itemtype or u'nonexistent',
-            CONTENTTYPE: contenttype or u'application/x-nonexistent'
+            ITEMTYPE: itemtype or ITEMTYPE_NONEXISTENT,
+            CONTENTTYPE: contenttype or CONTENTTYPE_NONEXISTENT
         }
         self.data = StringIO('')
         self.revid = None
     """
     A "conventional" wiki item.
     """
-    itemtype = u'default'
+    itemtype = ITEMTYPE_DEFAULT
     display_name = L_('Default')
     description = L_('Wiki item')
     order = -10
     Currently userprofile is implemented as a contenttype. This is a stub of an
     itemtype implementation of userprofile.
     """
-    itemtype = u'userprofile'
+    itemtype = ITEMTYPE_USERPROFILE
     display_name = L_('User profile')
     description = L_('User profile item (not implemented yet!)')
 
     A dummy Item for nonexistent items (when modifying, a nonexistent item with
     undetermined itemtype)
     """
-    itemtype = u'nonexistent'
+    itemtype = ITEMTYPE_NONEXISTENT
     shown = False
 
     def _convert(self, doc):

MoinMoin/items/content.py

 from MoinMoin.forms import File
 from MoinMoin.constants.contenttypes import (
     GROUP_MARKUP_TEXT, GROUP_OTHER_TEXT, GROUP_IMAGE, GROUP_AUDIO, GROUP_VIDEO,
-    GROUP_DRAWING, GROUP_OTHER,
+    GROUP_DRAWING, GROUP_OTHER, CONTENTTYPE_NONEXISTENT,
     )
 from MoinMoin.constants.keys import (
     NAME, NAME_EXACT, WIKINAME, CONTENTTYPE, SIZE, TAGS, HASH_ALGORITHM
 @register
 class NonExistentContent(Content):
     """Dummy Content to use with NonExistent."""
-    contenttype = 'application/x-nonexistent'
+    contenttype = CONTENTTYPE_NONEXISTENT
     group = None
 
     def do_get(self, force_attachment=False, mimetype=None):