Thomas Waldmann committed a3fe8ad

deduplicate - make all code import make_uuid and UUID_LEN from MoinMoin.util.crypto

  • Participants
  • Parent commits 226499a

Comments (0)

Files changed (5)


 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
 from import split_body
 from import NoSuchItemError, NoSuchRevisionError
 from MoinMoin.util.mimetype import MimeType
+from MoinMoin.util.crypto import make_uuid, UUID_LEN


 import os, tempfile, errno, shutil
-from uuid import uuid4 as make_uuid
 import cPickle as pickle
 from MoinMoin.util.lock import ExclusiveLock
 from MoinMoin.util import filesys
+from MoinMoin.util.crypto import make_uuid, UUID_LEN
 from import Backend as BackendBase
 from import Item as ItemBase
 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):
         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 =
         name2id = self._name2id


 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
 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
 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
 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 import NoSuchItemError, ItemAlreadyExistsError, NoSuchRevisionError


 except ImportError:
+from uuid import uuid4
+make_uuid = lambda: unicode(uuid4().hex)
+UUID_LEN = len(make_uuid())
 # random stuff