[Zope-CVS] CVS: Packages/HTTPMounter - HTTPMounter.py:1.12
Andreas Jung
andreas@digicool.com
Wed, 29 May 2002 14:59:33 -0400
Update of /cvs-repository/Packages/HTTPMounter
In directory cvs.zope.org:/tmp/cvs-serv6671
Modified Files:
HTTPMounter.py
Log Message:
added getContent() to provide access to the content of an object
retrieved by HTTPMounter by an object that is acquired by the HTTPMounter
(needed to make Lance happy).
=== Packages/HTTPMounter/HTTPMounter.py 1.11 => 1.12 ===
from OFS.SimpleItem import SimpleItem
from Acquisition import Implicit
-import string, time, urlparse, httplib
+import string, time, urlparse, httplib, re
+from zLOG import INFO, LOG
MAX_TRIES = 5 # max. number of retries
TIME2SLEEP = 0.5 # time to sleep in seconds between retries
@@ -46,19 +47,37 @@
self.id = id
self.title = title
self.url = url
+ self._v_traversal = []
def __bobo_traverse__(self, request, entry_name):
""" fool Zope traversal - hehehe"""
- if entry_name in ('manage_main','manage_workspace', 'manage_preferences') or \
- hasattr(self, entry_name):
+ if not hasattr(self, '_v_traversal'):
+ self._v_traversal = []
+
+ if entry_name in ('manage_main','manage_workspace', 'manage_preferences'):
+ return self
+
+ if hasattr(self, entry_name):
+
+ tup = urlparse.urlparse(self.url)
+ host = tup[1]
+ path = tup[2]
+ if path[-1] != '/': path = path + '/'
+ path = path + string.join(self._v_traversal, '/')
+
+ self._http_request(host, path)
+ self._v_traversal = []
+
return getattr(self, entry_name)
- return self
+ else:
+ self._v_traversal.append(entry_name)
+ return self
+
def __call__(self, REQUEST, RESPONSE):
""" """
- from zLOG import INFO, LOG
own_path = string.join(self.getPhysicalPath(), '/')
@@ -105,9 +124,14 @@
H.endheaders()
status, msg, headers = H.getreply()
- data = H.getfile().read()
+ self._v_content = H.getfile().read()
+
+ return (status, self._v_content, headers)
+
+ def getContent(self):
+ """ returns content"""
+ return self._v_content
- return (status, data, headers)
def manage_preferences(self, title, url, default_document, RESPONSE=None, URL1=None):
""" save preferences """