[Zope3-checkins] CVS: Zope3/src/zope/thread - __init__.py:1.2 interfaces.py:1.2

Steve Alexander steve at cat-box.net
Fri Mar 19 11:34:02 EST 2004


Update of /cvs-repository/Zope3/src/zope/thread
In directory cvs.zope.org:/tmp/cvs-serv31772/src/zope/thread

Added Files:
	__init__.py interfaces.py 
Log Message:
Module to support thread global variables for Zope.


=== Zope3/src/zope/thread/__init__.py 1.1 => 1.2 ===
--- /dev/null	Fri Mar 19 11:34:01 2004
+++ Zope3/src/zope/thread/__init__.py	Fri Mar 19 11:33:30 2004
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##############################################################################
+"""zope.thread
+
+Implements thread global variables.
+"""
+
+import threading
+from zope.interface import moduleProvides, implements
+from zope.thread.interfaces import IZopeThreadAPI
+from zope.thread.interfaces import IInteractionThreadGlobal, ISiteThreadGlobal
+
+__metaclass__ = type
+
+moduleProvides(IZopeThreadAPI)
+
+
+def thread_globals(thread=None):
+    """See IZopeThreadAPI."""
+    if thread is None:
+        thread = threading.currentThread()
+    if not hasattr(thread, '__zope3_thread_globals__'):
+        thread.__zope3_thread_globals__ = ThreadGlobals()
+    return thread.__zope3_thread_globals__
+
+
+class ThreadGlobals:
+    implements(IInteractionThreadGlobal, ISiteThreadGlobal)
+
+    interaction = None
+    site = None
+


=== Zope3/src/zope/thread/interfaces.py 1.1 => 1.2 ===
--- /dev/null	Fri Mar 19 11:34:01 2004
+++ Zope3/src/zope/thread/interfaces.py	Fri Mar 19 11:33:30 2004
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##############################################################################
+"""Interfaces for zope.thread.
+
+$Id$
+"""
+
+from zope.interface import Interface, Attribute
+
+
+class IZopeThreadAPI(Interface):
+
+    def thread_globals(thread=None):
+        """Return the thread globals instance for the given thread.
+
+        If thread is None, returns the globals for the current thread.
+        """
+
+
+class IInteractionThreadGlobal(Interface):
+
+    interaction = Attribute("""IInteraction for the current thread.""")
+
+
+class ISiteThreadGlobal(Interface):
+
+    site = Attribute("""Site for the current thread.""")




More information about the Zope3-Checkins mailing list