Hi all,

while pushing local site support in CMF/Plone I came across some weird
test failures. After a while of debbuging I could track this down to the
http method in ZopeTestCase's doctest support.

The method in its Zope2 incarnation is not aware of local sites, while
the one in zope.app.testing is.

I have attached a patch that mirrors the Zope3 behavior and saves the
site information before publishing a module and restores it back, just
like the security manager is saved/restored.

As this is causing some test failures in Plone 3 now, I would be happy
if somebody could take a look at this.

Thank you,
Hanno
Index: 
/opt/plone30/parts/zope2/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- 
/opt/plone30/parts/zope2/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
  (revision 72995)
+++ 
/opt/plone30/parts/zope2/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
  (working copy)
@@ -117,6 +117,7 @@
     """
     import urllib
     import rfc822
+    from zope.app.component.hooks import setSite, getSite
     from cStringIO import StringIO
     from ZPublisher.Response import Response
     from ZPublisher.Test import publish_module
@@ -126,6 +127,10 @@
     # Save current Security Manager
     old_sm = getSecurityManager()
 
+    # And we need to store the old site
+    old_site = getSite()
+    setSite(None)
+
     # Commit work done by previous python code.
     transaction.commit()
 
@@ -193,6 +198,9 @@
     # by calling the publish method above
     setSecurityManager(old_sm)
 
+    # And we need to restore the site again
+    setSite(old_site)
+
     # Sync connection
     sync()
 
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to