[Zope-CVS] CVS: Packages/HTTPMounter - LICENSE.txt:1.1 README.txt:1.1 VERSION.txt:1.1 HTTPMounter.py:1.2

Andreas Jung andreas@digicool.com
Thu, 16 May 2002 12:27:09 -0400


Update of /cvs-repository/Packages/HTTPMounter
In directory cvs.zope.org:/tmp/cvs-serv28278

Modified Files:
	HTTPMounter.py 
Added Files:
	LICENSE.txt README.txt VERSION.txt 
Log Message:
- added 'default_document'
- settings can be changed through the ZMI
- added README


=== Added File Packages/HTTPMounter/LICENSE.txt ===
HTTPMounter is published under the Zope Public License 2.0.



=== Added File Packages/HTTPMounter/README.txt ===
README for the Zope HTTPMounter Product

    HTTPMounter is a small product and allows you to "mount" a remote HTTP server
    into your local Zope instance.  The functionality is very similar to LocalFS
    where you can mount a local filesystem into your Zope instance.

    Parameters:

      - 'Title' - used in ZMI

      - 'Base URL' - URL of remote HTTP server to be mounted

      - 'Default document' - name of file to be used when '/' is last
        element of the path (default 'index.html')


=== Added File Packages/HTTPMounter/VERSION.txt ===
0.1


=== Packages/HTTPMounter/HTTPMounter.py 1.1.1.1 => 1.2 ===
 import urllib
 
+
 class HTTPMounter(Persistent, Implicit, SimpleItem):
     """ The HTTPMounter product acts like a dump LocalFS and mounts
         another HTTP into a running Zope instance.
@@ -40,12 +41,13 @@
         self.id     = id
         self.title  = title
         self.url    = url
+        self.default_document = 'index.html'
 
 
     def __bobo_traverse__(self, request, entry_name):
         """ fool Zope traversal - hehehe"""
 
-        if entry_name in ('manage_main','manage_workspace'): 
+        if entry_name in ('manage_main','manage_workspace', 'manage_preferences'): 
             return getattr(self, entry_name)
 
         return self 
@@ -55,8 +57,22 @@
         """ """
         own_path = '/'.join(self.getPhysicalPath())
         sub_path = REQUEST['PATH_TRANSLATED'].replace(own_path,'')
-        data = urllib.urlopen(self.url + sub_path).read()
+        if not sub_path: sub_path = self.default_document
+        url = self.url 
+        if url[-1] != '/': url = url = '/'
+        url = url + sub_path
+        data = urllib.urlopen(url).read()
         return data
+
+
+    def manage_preferences(self, title, url, default_document, RESPONSE=None, URL1=None):
+        """ save preferences """
+
+        self.title = title
+        self.url   = url
+        self.default_document = default_document
+
+        RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Settings%20saved')
 
 
     index_html = __call__