[Checkins] SVN: gocept.registration/trunk/src/gocept/registration/ Created a test registrations object that produces a predictable hash.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri May 9 13:44:05 EDT 2008


Log message for revision 86575:
  Created a test registrations object that produces a predictable hash.

Changed:
  U   gocept.registration/trunk/src/gocept/registration/registrations.py
  A   gocept.registration/trunk/src/gocept/registration/testing.py

-=-
Modified: gocept.registration/trunk/src/gocept/registration/registrations.py
===================================================================
--- gocept.registration/trunk/src/gocept/registration/registrations.py	2008-05-09 15:52:58 UTC (rev 86574)
+++ gocept.registration/trunk/src/gocept/registration/registrations.py	2008-05-09 17:44:03 UTC (rev 86575)
@@ -25,9 +25,12 @@
 
     zope.interface.implements(gocept.registration.interfaces.IRegistrations)
 
+    def _createHash(self, email, data=None):
+        return sha.new(email+datetime.datetime.now().isoformat()).hexdigest()
+
     def register(self, email, data=None):
         """Create a new registration for the given email address and data."""
-        hash = sha.new(email+datetime.datetime.now().isoformat()).hexdigest()
+        hash = self._createHash(email, data)
         self[hash] = registration = Registration(hash, email, data)
         return registration
 

Added: gocept.registration/trunk/src/gocept/registration/testing.py
===================================================================
--- gocept.registration/trunk/src/gocept/registration/testing.py	                        (rev 0)
+++ gocept.registration/trunk/src/gocept/registration/testing.py	2008-05-09 17:44:03 UTC (rev 86575)
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""A utility for managing registrations."""
+
+from gocept.registration import registration
+
+class TestingRegistrations(registration.Registrations):
+    "A registrations object that produces a non-obfuscated hash for testing."
+
+    def _createHeash(self, email, data=None):
+        return email + '-hash'


Property changes on: gocept.registration/trunk/src/gocept/registration/testing.py
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the Checkins mailing list