changeset 844:a3fe8ad5d893

deduplicate - make all code import make_uuid and UUID_LEN from MoinMoin.util.crypto
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 04 Sep 2011 18:07:15 +0200
parents 226499a0b42b
children c58b083f670d
files MoinMoin/storage/backends/fs19.py MoinMoin/storage/backends/fs2.py MoinMoin/storage/middleware/indexing.py MoinMoin/user.py MoinMoin/util/crypto.py
diffstat 5 files changed, 9 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/storage/backends/fs19.py	Sun Sep 04 16:59:52 2011 +0200
+++ b/MoinMoin/storage/backends/fs19.py	Sun Sep 04 18:07:15 2011 +0200
@@ -19,11 +19,7 @@
 from StringIO import StringIO
 import hashlib
 
-from uuid import uuid4
-make_uuid = lambda: unicode(uuid4().hex)
-
 MAX_NAME_LEN = 1000 # max length of a page name, page+attach name, user name
-UUID_LEN = len(make_uuid())
 
 from sqlalchemy import create_engine, MetaData, Table, Column, String, Unicode, Integer
 
@@ -45,6 +41,7 @@
 from MoinMoin.storage.backends._flatutils import split_body
 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError
 from MoinMoin.util.mimetype import MimeType
+from MoinMoin.util.crypto import make_uuid, UUID_LEN
 
 
 DELETED_MODE_KEEP = 'keep'
--- a/MoinMoin/storage/backends/fs2.py	Sun Sep 04 16:59:52 2011 +0200
+++ b/MoinMoin/storage/backends/fs2.py	Sun Sep 04 18:07:15 2011 +0200
@@ -14,7 +14,6 @@
 
 
 import os, tempfile, errno, shutil
-from uuid import uuid4 as make_uuid
 
 import cPickle as pickle
 
@@ -36,6 +35,7 @@
 
 from MoinMoin.util.lock import ExclusiveLock
 from MoinMoin.util import filesys
+from MoinMoin.util.crypto import make_uuid, UUID_LEN
 
 from MoinMoin.storage import Backend as BackendBase
 from MoinMoin.storage import Item as ItemBase
@@ -52,8 +52,6 @@
 MAX_NAME_LEN = 500
 from MoinMoin.config import HASH_ALGORITHM
 
-UUID_LEN = len(make_uuid().hex)
-
 
 class Item(ItemBase):
     def __init__(self, backend, item_name, _fs_item_id=None, _fs_metadata=None, *args, **kw):
@@ -276,7 +274,7 @@
         See _add_item_internally, this is just internal for locked operation.
         """
         item, revmeta, revdata, revdata_target, itemmeta = arg
-        item_id = make_uuid().hex
+        item_id = make_uuid()
         item_name = item.name
 
         name2id = self._name2id
--- a/MoinMoin/storage/middleware/indexing.py	Sun Sep 04 16:59:52 2011 +0200
+++ b/MoinMoin/storage/middleware/indexing.py	Sun Sep 04 18:07:15 2011 +0200
@@ -19,9 +19,6 @@
 import os
 import time, datetime
 
-from uuid import uuid4
-make_uuid = lambda: unicode(uuid4().hex)
-
 from flask import current_app as app
 from flask import g as flaskg
 from flask import request
@@ -36,6 +33,7 @@
 from MoinMoin.util.iri import Iri
 from MoinMoin.util.mime import Type, type_moin_document
 from MoinMoin.util.tree import moin_page
+from MoinMoin.util.crypto import make_uuid
 from MoinMoin import wikiutil
 
 from MoinMoin import log
--- a/MoinMoin/user.py	Sun Sep 04 16:59:52 2011 +0200
+++ b/MoinMoin/user.py	Sun Sep 04 18:07:15 2011 +0200
@@ -22,9 +22,6 @@
 import time
 import copy
 
-from uuid import uuid4
-make_uuid = lambda: unicode(uuid4().hex)
-
 from babel import parse_locale
 
 from flask import current_app as app
@@ -38,7 +35,7 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.util.interwiki import getInterwikiHome, getInterwikiName, is_local_wiki
 from MoinMoin.util.crypto import crypt_password, upgrade_password, valid_password, \
-                                 generate_token, valid_token
+                                 generate_token, valid_token, make_uuid
 from MoinMoin.storage.error import NoSuchItemError, ItemAlreadyExistsError, NoSuchRevisionError
 
 
--- a/MoinMoin/util/crypto.py	Sun Sep 04 16:59:52 2011 +0200
+++ b/MoinMoin/util/crypto.py	Sun Sep 04 18:07:15 2011 +0200
@@ -47,6 +47,10 @@
 except ImportError:
     pass
 
+from uuid import uuid4
+
+make_uuid = lambda: unicode(uuid4().hex)
+UUID_LEN = len(make_uuid())
 
 # random stuff