[Checkins] SVN: zc.selenium/branches/wosc-zope2/src/zc/selenium/ zope2 does not know browser:resource, so convert those resources that are dynamic anyway to be views.

Wolfgang Schnerring wosc at wosc.de
Fri Feb 13 10:26:31 EST 2009


Log message for revision 96492:
  zope2 does not know browser:resource, so convert those resources that are dynamic anyway to be views.
  

Changed:
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py
  U   zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py

-=-
Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml	2009-02-13 15:16:00 UTC (rev 96491)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/configure.zcml	2009-02-13 15:26:30 UTC (rev 96492)
@@ -17,26 +17,31 @@
         />
   </class>
 
-  <browser:resource
+  <browser:page
+      for="*"
       name="selenium_results"
-      factory=".results.Results"
+      class=".results.Results"
       permission="zope.Public"
       />
 
-  <browser:resource
+  <browser:page
+      for="*"
       name="selenium-push.html"
-      factory=".dbs.PushDBs"
+      class=".dbs.PushDBs"
       permission="zope.Public"
       />
 
-  <browser:resource
+  <browser:page
+      for="*"
       name="selenium-pop.html"
-      factory=".dbs.PopDBs"
+      class=".dbs.PopDBs"
       permission="zope.Public"
       />
 
+  <!-- XXX module is unknown in zope2, what to do? -->
+  <!--
   <module module=".pytest">
     <allow attributes="suite" />
   </module>
-
+  -->
 </configure>

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py	2009-02-13 15:16:00 UTC (rev 96491)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/dbs.py	2009-02-13 15:26:30 UTC (rev 96492)
@@ -18,20 +18,19 @@
 
 from ZODB.DemoStorage import DemoStorage
 from ZODB.DB import DB
-from zope.exceptions.interfaces import UserError
 
 import zc.selenium.resource
 
 
 class PushDBs(zc.selenium.resource.ResourceBase):
 
-    def GET(self):
+    def __call__(self):
         publication = self.request.publication
         if [1
             for d in publication.db.databases.values()
             if not isinstance(d._storage, DemoStorage)
             ]:
-            raise UserError("Wrong mode")
+            raise RuntimeError("Wrong mode")
 
         databases = {}
         for name, db in publication.db.databases.items():
@@ -47,7 +46,7 @@
 
 class PopDBs(zc.selenium.resource.ResourceBase):
 
-    def GET(self):
+    def __call__(self):
         publication = self.request.publication
         publication.db = publication.db.pushed_base
 

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py	2009-02-13 15:16:00 UTC (rev 96491)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/resource.py	2009-02-13 15:26:30 UTC (rev 96492)
@@ -16,14 +16,18 @@
 """
 __docformat__ = "reStructuredText"
 
+import zope.app.publisher.browser.resource
 import zope.interface
-import zope.publisher.browser
 import zope.publisher.interfaces.browser
 
-import zope.app.publisher.browser.resource
+# Zope2 compatibility
+try:
+    from zope.publisher.browser import BrowserView
+except ImportError:
+    from zope.app.publisher.browser import BrowserView
 
 
-class ResourceBase(zope.publisher.browser.BrowserView,
+class ResourceBase(BrowserView,
                    zope.app.publisher.browser.resource.Resource):
 
     zope.interface.implements(

Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py	2009-02-13 15:16:00 UTC (rev 96491)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/results.py	2009-02-13 15:26:30 UTC (rev 96492)
@@ -26,7 +26,7 @@
 
     template = zope.app.pagetemplate.ViewPageTemplateFile('results.pt')
 
-    def POST(self):
+    def __call__(self):
         # get the queue used to communicate with the test thread, this will
         # fail horribly if not running in "Selenium test" mode
         messages = sys.modules['__main__'].messages



More information about the Checkins mailing list