Commits

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)

MoinMoin/storage/backends/fs19.py

 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 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'

MoinMoin/storage/backends/fs2.py

 
 
 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 MoinMoin.storage import Backend as BackendBase
 from MoinMoin.storage import Item as ItemBase
 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):
         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

MoinMoin/storage/middleware/indexing.py

 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 MoinMoin.storage.error import NoSuchItemError, ItemAlreadyExistsError, NoSuchRevisionError
 
 

MoinMoin/util/crypto.py

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