changeset 102:c084c1369078

move metadata name constant defs to MoinMoin.config
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 11 Mar 2011 04:44:59 +0100
parents 856945a6d936
children 1d900f3cf7bb
files MoinMoin/_tests/test_test_environ.py MoinMoin/apps/admin/views.py MoinMoin/apps/feed/views.py MoinMoin/apps/frontend/views.py MoinMoin/config/__init__.py MoinMoin/datastruct/backends/_tests/test_wiki_dicts.py MoinMoin/datastruct/backends/_tests/test_wiki_groups.py MoinMoin/datastruct/backends/wiki_dicts.py MoinMoin/datastruct/backends/wiki_groups.py MoinMoin/items/__init__.py MoinMoin/items/_tests/test_Item.py MoinMoin/script/maint/modified_systemitems.py MoinMoin/security/_tests/test_security.py MoinMoin/storage/__init__.py MoinMoin/storage/_tests/test_backends.py MoinMoin/storage/_tests/test_backends_fs19.py MoinMoin/storage/_tests/test_middleware_acl.py MoinMoin/storage/backends/_flatutils.py MoinMoin/storage/backends/acl.py MoinMoin/storage/backends/fileserver.py MoinMoin/storage/backends/flatfile.py MoinMoin/storage/backends/fs19.py MoinMoin/storage/backends/fs2.py MoinMoin/storage/backends/hg.py MoinMoin/storage/backends/indexing.py MoinMoin/themes/__init__.py MoinMoin/wikiutil.py
diffstat 27 files changed, 79 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_test_environ.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/_tests/test_test_environ.py	Fri Mar 11 04:44:59 2011 +0100
@@ -11,7 +11,7 @@
 from flask import current_app as app
 from flask import flaskg
 
-from MoinMoin.items import IS_SYSITEM, SYSITEM_VERSION
+from MoinMoin.config import IS_SYSITEM, SYSITEM_VERSION
 from MoinMoin.storage.error import NoSuchItemError
 
 from MoinMoin._tests import wikiconfig
--- a/MoinMoin/apps/admin/views.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/apps/admin/views.py	Fri Mar 11 04:44:59 2011 +0100
@@ -22,7 +22,7 @@
 from MoinMoin.apps.admin import admin
 from MoinMoin import user
 from MoinMoin.storage.error import NoSuchRevisionError
-from MoinMoin.items import SIZE
+from MoinMoin.config import SIZE
 
 @admin.route('/')
 def index():
--- a/MoinMoin/apps/feed/views.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/apps/feed/views.py	Fri Mar 11 04:44:59 2011 +0100
@@ -24,7 +24,7 @@
 from MoinMoin import wikiutil
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.apps.feed import feed
-from MoinMoin.items import NAME, ACL, MIMETYPE, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT
+from MoinMoin.config import NAME, ACL, MIMETYPE, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT
 from MoinMoin.themes import get_editor_info
 from MoinMoin.items import Item
 
--- a/MoinMoin/apps/frontend/views.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/apps/frontend/views.py	Fri Mar 11 04:44:59 2011 +0100
@@ -36,9 +36,10 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.themes import render_template
 from MoinMoin.apps.frontend import frontend
-from MoinMoin.items import Item, NonExistent, MIMETYPE, ITEMLINKS, ITEMTRANSCLUSIONS
+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 MIMETYPE, ITEMLINKS, ITEMTRANSCLUSIONS
 from MoinMoin.util.forms import make_generator
 from MoinMoin.security.textcha import TextCha, TextChaizedForm, TextChaValid
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError, AccessDeniedError
--- a/MoinMoin/config/__init__.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/config/__init__.py	Fri Mar 11 04:44:59 2011 +0100
@@ -63,7 +63,7 @@
               ]
 
 
-# rights that are valid in moin2
+# ACL rights that are valid in moin2
 ADMIN = 'admin'
 READ = 'read'
 WRITE = 'write'
@@ -71,3 +71,44 @@
 DESTROY = 'destroy'
 ACL_RIGHTS_VALID = [READ, WRITE, CREATE, ADMIN, DESTROY, ]
 
+# metadata keys
+UUID = "uuid"
+NAME = "name"
+NAME_OLD = "name_old"
+
+# if an item is reverted, we store the revision number we used for reverting there:
+REVERTED_TO = "reverted_to"
+
+# some metadata key constants:
+ACL = "acl"
+
+# This says: I am a system item
+IS_SYSITEM = "is_syspage"
+# This says: original sysitem as contained in release: <release>
+SYSITEM_VERSION = "syspage_version"
+
+# keys for storing group and dict information
+# group of user names, e.g. for ACLs:
+USERGROUP = "usergroup"
+# needs more precise name / use case:
+SOMEDICT = "somedict"
+
+MIMETYPE = "mimetype"
+SIZE = "size"
+LANGUAGE = "language"
+ITEMLINKS = "itemlinks"
+ITEMTRANSCLUSIONS = "itemtransclusions"
+TAGS = "tags"
+
+ACTION = "action"
+ADDRESS = "address"
+HOSTNAME = "hostname"
+USERID = "userid"
+EXTRA = "extra"
+COMMENT = "comment"
+
+# we need a specific hash algorithm to store hashes of revision data into meta
+# data. meta[HASH_ALGORITHM] = hash(rev_data, HASH_ALGORITHM)
+# some backends may use this also for other purposes.
+HASH_ALGORITHM = 'sha1'
+
--- a/MoinMoin/datastruct/backends/_tests/test_wiki_dicts.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/datastruct/backends/_tests/test_wiki_dicts.py	Fri Mar 11 04:44:59 2011 +0100
@@ -11,7 +11,7 @@
 
 from MoinMoin.datastruct.backends._tests import DictsBackendTest
 from MoinMoin.datastruct.backends import wiki_dicts
-from MoinMoin.items import SOMEDICT
+from MoinMoin.config import SOMEDICT
 from MoinMoin._tests import become_trusted, update_item
 
 DATA = "This is a dict item."
--- a/MoinMoin/datastruct/backends/_tests/test_wiki_groups.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/datastruct/backends/_tests/test_wiki_groups.py	Fri Mar 11 04:44:59 2011 +0100
@@ -16,7 +16,7 @@
 from flask import flaskg
 from MoinMoin.datastruct.backends._tests import GroupsBackendTest
 from MoinMoin.datastruct import GroupDoesNotExistError
-from MoinMoin.items import USERGROUP
+from MoinMoin.config import USERGROUP
 from MoinMoin import security
 from MoinMoin.user import User
 from MoinMoin._tests import become_trusted, create_random_string_list, update_item
--- a/MoinMoin/datastruct/backends/wiki_dicts.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/datastruct/backends/wiki_dicts.py	Fri Mar 11 04:44:59 2011 +0100
@@ -10,7 +10,7 @@
 
 
 from flask import flaskg
-from MoinMoin.items import SOMEDICT
+from MoinMoin.config import SOMEDICT
 from MoinMoin.datastruct.backends import BaseDict, BaseDictsBackend, DictDoesNotExistError
 
 
--- a/MoinMoin/datastruct/backends/wiki_groups.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/datastruct/backends/wiki_groups.py	Fri Mar 11 04:44:59 2011 +0100
@@ -15,7 +15,7 @@
 """
 
 from flask import flaskg
-from MoinMoin.items import USERGROUP
+from MoinMoin.config import USERGROUP
 from MoinMoin.datastruct.backends import GreedyGroup, BaseGroupsBackend, GroupDoesNotExistError
 
 
--- a/MoinMoin/items/__init__.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/items/__init__.py	Fri Mar 11 04:44:59 2011 +0100
@@ -51,47 +51,16 @@
 from MoinMoin.util.send_file import send_file
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError, AccessDeniedError, \
                                    StorageError
-from MoinMoin.storage import HASH_ALGORITHM
+from MoinMoin.config import UUID, NAME, NAME_OLD, REVERTED_TO, ACL, \
+                            IS_SYSITEM, SYSITEM_VERSION,  USERGROUP, SOMEDICT, \
+                            MIMETYPE, SIZE, LANGUAGE, ITEMLINKS, ITEMTRANSCLUSIONS, \
+                            TAGS, ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \
+                            HASH_ALGORITHM
 
 COLS = 80
 ROWS_DATA = 20
 ROWS_META = 10
 
-UUID = "uuid"
-NAME = "name"
-NAME_OLD = "name_old"
-
-# if an item is reverted, we store the revision number we used for reverting there:
-REVERTED_TO = "reverted_to"
-
-# some metadata key constants:
-ACL = "acl"
-
-# This says: I am a system item
-IS_SYSITEM = "is_syspage"
-# This says: original sysitem as contained in release: <release>
-SYSITEM_VERSION = "syspage_version"
-
-# keys for storing group and dict information
-# group of user names, e.g. for ACLs:
-USERGROUP = "usergroup"
-# needs more precise name / use case:
-SOMEDICT = "somedict"
-
-MIMETYPE = "mimetype"
-SIZE = "size"
-LANGUAGE = "language"
-ITEMLINKS = "itemlinks"
-ITEMTRANSCLUSIONS = "itemtransclusions"
-TAGS = "tags"
-
-ACTION = "action"
-ADDRESS = "address"
-HOSTNAME = "hostname"
-USERID = "userid"
-EXTRA = "extra"
-COMMENT = "comment"
-
 
 class DummyRev(dict):
     """ if we have no stored Revision, we use this dummy """
--- a/MoinMoin/items/_tests/test_Item.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/items/_tests/test_Item.py	Fri Mar 11 04:44:59 2011 +0100
@@ -11,8 +11,8 @@
 from flask import flaskg
 
 from MoinMoin._tests import become_trusted
-from MoinMoin.items import Item, ApplicationXTar, NonExistent, Binary, Text, Image, TransformableBitmapImage, \
-                           MIMETYPE, ADDRESS, COMMENT, HOSTNAME, USERID, ACTION
+from MoinMoin.items import Item, ApplicationXTar, NonExistent, Binary, Text, Image, TransformableBitmapImage
+from MoinMoin.config import MIMETYPE, ADDRESS, COMMENT, HOSTNAME, USERID, ACTION
 
 class TestItem(object):
     def testNonExistent(self):
--- a/MoinMoin/script/maint/modified_systemitems.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/script/maint/modified_systemitems.py	Fri Mar 11 04:44:59 2011 +0100
@@ -11,7 +11,7 @@
 
 from flask import current_app as app
 from flaskext.script import Command
-from MoinMoin.items import IS_SYSITEM, SYSITEM_VERSION
+from MoinMoin.config import IS_SYSITEM, SYSITEM_VERSION
 from MoinMoin.storage.error import NoSuchRevisionError
 
 class Modified_SystemItems(Command):
--- a/MoinMoin/security/_tests/test_security.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/security/_tests/test_security.py	Fri Mar 11 04:44:59 2011 +0100
@@ -19,7 +19,7 @@
 AccessControlList = security.AccessControlList
 
 from MoinMoin.user import User
-from MoinMoin.items import ACL
+from MoinMoin.config import ACL
 
 from MoinMoin._tests import update_item
 from MoinMoin._tests import become_trusted
--- a/MoinMoin/storage/__init__.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/__init__.py	Fri Mar 11 04:44:59 2011 +0100
@@ -51,14 +51,7 @@
                                    BackendError, NoSuchItemError, \
                                    RevisionAlreadyExistsError, ItemAlreadyExistsError
 
-#XXX doesn't work, cyclic imports:
-#from MoinMoin.items import SIZE
-SIZE = "size"
-
-# we need a specific hash algorithm to store hashes of revision data into meta
-# data. meta[HASH_ALGORITHM] = hash(rev_data, HASH_ALGORITHM)
-# some backends may use this also for other purposes.
-HASH_ALGORITHM = 'sha1'
+from MoinMoin.config import SIZE, HASH_ALGORITHM
 
 import hashlib
 
--- a/MoinMoin/storage/_tests/test_backends.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/_tests/test_backends.py	Fri Mar 11 04:44:59 2011 +0100
@@ -24,7 +24,7 @@
 from MoinMoin.storage.backends import memory
 from MoinMoin.storage.error import NoSuchItemError, ItemAlreadyExistsError, NoSuchRevisionError, RevisionAlreadyExistsError
 from MoinMoin.storage import terms
-from MoinMoin.items import SIZE
+from MoinMoin.config import SIZE
 
 item_names = (u"quite_normal",
               u"äöüßłóąćółąńśćżź",
--- a/MoinMoin/storage/_tests/test_backends_fs19.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/_tests/test_backends_fs19.py	Fri Mar 11 04:44:59 2011 +0100
@@ -13,7 +13,7 @@
 
 from flask import current_app as app
 
-from MoinMoin.items import TAGS
+from MoinMoin.config import TAGS
 from MoinMoin.storage import Item
 from MoinMoin.storage.backends._fsutils import quoteWikinameFS, unquoteWikiname
 from MoinMoin.storage.backends.fs19 import FSPageBackend, regenerate_acl, process_categories
--- a/MoinMoin/storage/_tests/test_middleware_acl.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/_tests/test_middleware_acl.py	Fri Mar 11 04:44:59 2011 +0100
@@ -12,7 +12,7 @@
 
 from flask import flaskg
 
-from MoinMoin.items import ACL
+from MoinMoin.config import ACL
 from MoinMoin.storage.error import AccessDeniedError
 from MoinMoin.storage._tests.test_backends import BackendTest
 from MoinMoin._tests import wikiconfig
--- a/MoinMoin/storage/backends/_flatutils.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/_flatutils.py	Fri Mar 11 04:44:59 2011 +0100
@@ -5,6 +5,7 @@
     MoinMoin - helpers for flatfile meta/data stores
 """
 
+from MoinMoin.config import NAME, ACL, MIMETYPE, LANGUAGE
 
 
 def split_body(body):
@@ -57,8 +58,6 @@
     """
     Adds the processing instructions to the data.
     """
-    from MoinMoin.items import NAME, ACL, MIMETYPE, LANGUAGE
-
     meta_keys = [NAME, ACL, MIMETYPE, LANGUAGE, ]
 
     metadata_data = ""
--- a/MoinMoin/storage/backends/acl.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/acl.py	Fri Mar 11 04:44:59 2011 +0100
@@ -48,13 +48,12 @@
 
 from flask import flaskg
 
-from MoinMoin.items import ACL
 from MoinMoin.security import AccessControlList
 
 from MoinMoin.storage import Item, NewRevision, StoredRevision
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError, AccessDeniedError
 
-from MoinMoin.config import ADMIN, READ, WRITE, CREATE, DESTROY
+from MoinMoin.config import ACL, ADMIN, READ, WRITE, CREATE, DESTROY
 
 
 class AclWrapperBackend(object):
--- a/MoinMoin/storage/backends/fileserver.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/fileserver.py	Fri Mar 11 04:44:59 2011 +0100
@@ -23,7 +23,7 @@
 from MoinMoin.storage import Backend, Item, StoredRevision
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError
 
-from MoinMoin.items import ACL, MIMETYPE, ACTION, COMMENT, SIZE
+from MoinMoin.config import ACL, MIMETYPE, ACTION, COMMENT, SIZE
 MTIME = '__timestamp' # does not exist in storage any more
 
 class FSError(Exception):
--- a/MoinMoin/storage/backends/flatfile.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/flatfile.py	Fri Mar 11 04:44:59 2011 +0100
@@ -33,7 +33,8 @@
                                    RevisionAlreadyExistsError
 from MoinMoin.storage.backends._fsutils import quoteWikinameFS, unquoteWikiname
 from MoinMoin.storage.backends._flatutils import add_metadata_to_body, split_body
-from MoinMoin.items import MIMETYPE, ACTION
+from MoinMoin.config import MIMETYPE, ACTION
+
 
 class FlatFileBackend(Backend):
     def __init__(self, path):
--- a/MoinMoin/storage/backends/fs19.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/fs19.py	Fri Mar 11 04:44:59 2011 +0100
@@ -32,15 +32,14 @@
 logging = log.getLogger(__name__)
 
 from MoinMoin import wikiutil, config
+from MoinMoin.config import ACL, MIMETYPE, UUID, NAME, NAME_OLD, REVERTED_TO, \
+                            ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \
+                            IS_SYSITEM, SYSITEM_VERSION, \
+                            TAGS, SIZE, HASH_ALGORITHM
 from MoinMoin.storage import Backend, Item, StoredRevision
-from MoinMoin.items import ACL, MIMETYPE, UUID, NAME, NAME_OLD, REVERTED_TO, \
-                           ACTION, ADDRESS, HOSTNAME, USERID, EXTRA, COMMENT, \
-                           IS_SYSITEM, SYSITEM_VERSION, \
-                           TAGS, SIZE
 from MoinMoin.storage.backends._fsutils import quoteWikinameFS, unquoteWikiname
 from MoinMoin.storage.backends._flatutils import split_body
 
-from MoinMoin.storage import HASH_ALGORITHM
 
 MTIME = '__timestamp' # does not exist in storage any more
 
--- a/MoinMoin/storage/backends/fs2.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/fs2.py	Fri Mar 11 04:44:59 2011 +0100
@@ -44,7 +44,7 @@
 PICKLEPROTOCOL = 1
 
 MAX_NAME_LEN = 500
-from MoinMoin.storage import HASH_ALGORITHM
+from MoinMoin.config import HASH_ALGORITHM
 
 UUID_LEN = len(make_uuid().hex)
 
--- a/MoinMoin/storage/backends/hg.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/hg.py	Fri Mar 11 04:44:59 2011 +0100
@@ -56,7 +56,7 @@
 except ImportError:
     from MoinMoin.util import pycdb as cdb
 
-from MoinMoin.items import USERID, COMMENT
+from MoinMoin.config import USERID, COMMENT
 from MoinMoin.storage import Backend, Item, StoredRevision, NewRevision
 from MoinMoin.storage.error import (BackendError, NoSuchItemError, NoSuchRevisionError,
                                    RevisionNumberMismatchError, ItemAlreadyExistsError,
--- a/MoinMoin/storage/backends/indexing.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/storage/backends/indexing.py	Fri Mar 11 04:44:59 2011 +0100
@@ -26,8 +26,7 @@
 logging = log.getLogger(__name__)
 
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError
-from MoinMoin.items import ACL, MIMETYPE, UUID, NAME, NAME_OLD, \
-                           TAGS
+from MoinMoin.config import ACL, MIMETYPE, UUID, NAME, NAME_OLD, TAGS
 
 
 class IndexingBackendMixin(object):
--- a/MoinMoin/themes/__init__.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/themes/__init__.py	Fri Mar 11 04:44:59 2011 +0100
@@ -20,6 +20,7 @@
 
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin import wikiutil, user
+from MoinMoin.config import USERID, ADDRESS, HOSTNAME
 from MoinMoin.util.interwiki import split_interwiki, resolve_interwiki, join_wiki, getInterwikiHome
 
 
@@ -312,7 +313,6 @@
 
 
 def get_editor_info(rev, external=False):
-    from MoinMoin.items import USERID, ADDRESS, HOSTNAME
     addr = rev.get(ADDRESS)
     hostname = rev.get(HOSTNAME)
     text = _('anonymous')  # link text
--- a/MoinMoin/wikiutil.py	Fri Mar 11 03:52:14 2011 +0100
+++ b/MoinMoin/wikiutil.py	Fri Mar 11 04:44:59 2011 +0100
@@ -24,6 +24,8 @@
 from flask import request
 
 from MoinMoin import config
+from MoinMoin.config import IS_SYSITEM
+
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.util import pysupport, lock
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError
@@ -134,7 +136,6 @@
     :rtype: bool
     :returns: True if page is a system item
     """
-    from MoinMoin.items import IS_SYSITEM
     try:
         item = flaskg.storage.get_item(itemname)
         return item.get_revision(-1)[IS_SYSITEM]