[Checkins] SVN: z3c.sessionwidget/trunk/src/z3c/sessionwidget/widget.py use a hash as key, and extracted key generation method

Bernd Dorn bernd.dorn at lovelysystems.com
Tue Feb 20 11:46:03 EST 2007


Log message for revision 72719:
  use a hash as key, and extracted key generation method

Changed:
  U   z3c.sessionwidget/trunk/src/z3c/sessionwidget/widget.py

-=-
Modified: z3c.sessionwidget/trunk/src/z3c/sessionwidget/widget.py
===================================================================
--- z3c.sessionwidget/trunk/src/z3c/sessionwidget/widget.py	2007-02-20 16:29:21 UTC (rev 72718)
+++ z3c.sessionwidget/trunk/src/z3c/sessionwidget/widget.py	2007-02-20 16:46:00 UTC (rev 72719)
@@ -27,6 +27,7 @@
 from zope.app.form.interfaces import WidgetInputError, MissingInputError
 from zope.schema.interfaces import ValidationError
 from zope.security.proxy import removeSecurityProxy
+import sha
 
 SESSION_KEY = 'z3c.sessionwidget.SessionInputWidget'
 
@@ -35,17 +36,22 @@
     zope.interface.implements(interfaces.ISessionWidget)
 
     @property
-    def session(self):
-        """Get the session containing all data relevant for this
-        widget."""
-        # key from url of context
+    def sessionKey(self):
         if self.request._traversed_names:
             key = '/'.join(self.request._traversed_names[:-1] + \
                            [self.name])
         else:
             key = self.name
+        key = sha.new(key).hexdigest()
+        return key
+
+    @property
+    def session(self):
+        """Get the session containing all data relevant for this
+        widget."""
+        # key from url of context
         return ISession(self.request)[SESSION_KEY].setdefault(
-            key, SessionPkgData())
+            self.sessionKey, SessionPkgData())
 
     def setRenderedValue(self, value):
         """See zope.app.form.interfaces.IWidget"""



More information about the Checkins mailing list