1. pkumar
  2. moin-2.0


Thomas Waldmann  committed a3fe8ad

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

  • Participants
  • Parent commits 226499a
  • Branches default

Comments (0)

Files changed (5)

File MoinMoin/storage/backends/fs19.py

View file
  • Ignore whitespace
 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

File MoinMoin/storage/backends/fs2.py

View file
  • Ignore whitespace
 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
 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

File MoinMoin/storage/middleware/indexing.py

View file
  • Ignore whitespace
 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

File MoinMoin/user.py

View file
  • Ignore whitespace
 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

File MoinMoin/util/crypto.py

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