diff MoinMoin/items/__init__.py @ 174:e8f61cbd661b

modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix on password change, the new password was not saved to the profile User / crypto code: minor optimizations / refactorings crypto module contents: password hashing/encryption, validation, pw hash upgrades: * pw_hash = crypt_password(password) * is_valid = valid_password(password, pw_hash) * upgraded_pw_hash = upgrade_password(password, pw_hash) password recovery: * key, token = generate_token() * is_valid = valid_token(key, token) random strings: * rs = random_string(length, chars) compute ascii cache keys: * key = cache_key(**kw)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 07 Apr 2011 20:56:35 +0200
parents 89f50aed143f
children 17693a043442
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Wed Apr 06 16:46:54 2011 +0200
+++ b/MoinMoin/items/__init__.py	Thu Apr 07 20:56:35 2011 +0200
@@ -24,6 +24,7 @@
 from MoinMoin.security.textcha import TextCha, TextChaizedForm, TextChaValid
 from MoinMoin.util.forms import make_generator
 from MoinMoin.util.mimetype import MimeType
+from MoinMoin.util.crypto import cache_key
 
 try:
     import PIL
@@ -167,9 +168,9 @@
         hash_name = HASH_ALGORITHM
         hash_hexdigest = self.rev.get(hash_name)
         if hash_hexdigest:
-            cid = wikiutil.cache_key(usage="internal_representation",
-                                     hash_name=hash_name,
-                                     hash_hexdigest=hash_hexdigest)
+            cid = cache_key(usage="internal_representation",
+                            hash_name=hash_name,
+                            hash_hexdigest=hash_hexdigest)
             doc = app.cache.get(cid)
         else:
             # likely a non-existing item
@@ -731,7 +732,7 @@
         if isinstance(name, unicode):
             name = name.encode('utf-8')
         temp_fname = os.path.join(tempfile.gettempdir(), 'TarContainer_' +
-                                  wikiutil.cache_key(usage='TarContainer', name=self.name))
+                                  cache_key(usage='TarContainer', name=self.name))
         tf = tarfile.TarFile(temp_fname, mode='a')
         ti = tarfile.TarInfo(name)
         if isinstance(content, str):
@@ -908,10 +909,10 @@
             # resize requested, XXX check ACL behaviour! XXX
             hash_name = HASH_ALGORITHM
             hash_hexdigest = self.rev[hash_name]
-            cid = wikiutil.cache_key(usage="ImageTransform",
-                                     hash_name=hash_name,
-                                     hash_hexdigest=hash_hexdigest,
-                                     width=width, height=height, transpose=transpose)
+            cid = cache_key(usage="ImageTransform",
+                            hash_name=hash_name,
+                            hash_hexdigest=hash_hexdigest,
+                            width=width, height=height, transpose=transpose)
             c = app.cache.get(cid)
             if c is None:
                 content_type = self.rev[MIMETYPE]
@@ -935,10 +936,10 @@
 
     def _render_data_diff_raw(self, oldrev, newrev):
         hash_name = HASH_ALGORITHM
-        cid = wikiutil.cache_key(usage="ImageDiff",
-                                 hash_name=hash_name,
-                                 hash_old=oldrev[hash_name],
-                                 hash_new=newrev[hash_name])
+        cid = cache_key(usage="ImageDiff",
+                        hash_name=hash_name,
+                        hash_old=oldrev[hash_name],
+                        hash_new=newrev[hash_name])
         c = app.cache.get(cid)
         if c is None:
             if PIL is None: