[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser - fileresource.py:1.4 viewmeta.py:1.12

Jim Fulton jim@zope.com
Fri, 7 Feb 2003 11:00:17 -0500


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser
In directory cvs.zope.org:/tmp/cvs-serv24670/src/zope/app/publisher/browser

Modified Files:
	fileresource.py viewmeta.py 
Log Message:
Implemented HTTP PUT. Do do this, I had to:

- Implement working HTTP publication, request, response

- Change the server setup so that rather than having a Browser
  server and an XML-RPC server, there is an HTTP server that 
  uses:

  o Browser request, response, and publication for browser (GET, POST, 
    and HEAD) requests,

  o XMLRPC request, response, and publication for xml-rpc (POST 
    w content-type=='text/xml') requests,

  o HTTP request, response, and publication for all other HTTP requests.

  XML-RPC now runs on the same port, 8080, as browser requests.

- Implemented HEAD.

- Implemented some simple PUT views that use the
  file-system-reprentation adapter framework. (This is the replacement
  for VFS that is also used by FTP and may be used as part of
  file-system synchronization.) 
  



=== Zope3/src/zope/app/publisher/browser/fileresource.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/publisher/browser/fileresource.py:1.3	Sat Dec 28 11:14:00 2002
+++ Zope3/src/zope/app/publisher/browser/fileresource.py	Fri Feb  7 10:59:44 2003
@@ -39,8 +39,7 @@
 
     def browserDefault(self, request):
         '''See interface IBrowserPublisher'''
-        method = request.get('REQUEST_METHOD', 'GET').upper()
-        return getattr(self, method), ()
+        return getattr(self, request.method), ()
 
     #
     ############################################################


=== Zope3/src/zope/app/publisher/browser/viewmeta.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/publisher/browser/viewmeta.py:1.11	Thu Feb  6 01:49:39 2003
+++ Zope3/src/zope/app/publisher/browser/viewmeta.py	Fri Feb  7 10:59:44 2003
@@ -317,11 +317,17 @@
         cdict['publishTraverse'] = publishTraverse
 
         if not hasattr(class_, 'browserDefault'):
-            default = self.default or self.pages[0][0]
-            cdict['browserDefault'] = (
-                lambda self, request, default=default:
-                (self, (default, ))
-                )
+            if self.default or self.pages:
+                default = self.default or self.pages[0][0]
+                cdict['browserDefault'] = (
+                    lambda self, request, default=default:
+                    (self, (default, ))
+                    )
+            elif providesCallable(class_):
+                cdict['browserDefault'] = (
+                    lambda self, request: (self, ())
+                    )
+                
 
         if class_ is not None:
             bases = (class_, simple)
@@ -473,3 +479,10 @@
 
         meth = getattr(self, attr)
         return meth(*a, **k)
+
+def providesCallable(class_):
+    if hasattr(class_, '__call__'):
+        for c in class_.__mro__:
+            if '__call__' in c.__dict__:
+                return True
+    return False