Commits

Matthew Scott  committed 458e3cb

+ Allow use of no cache directory; useful for localhost browsing

  • Participants
  • Parent commits 176fd11

Comments (0)

Files changed (1)

File slipper/app.py

             else:
                 status = '302 FOUND'
                 response_headers = [
-                    ('Content-Type', 'text/html'),
+                    ('Content-Type', 'text/plain'),
                     ('Location', self.index_path),
                     ]
                 start_response(status, response_headers)
             return [status]
         section, revision, file_path = parts
         # Get the configuration for that section.
-        config = self.repo_map[section]
+        try:
+            config = self.repo_map[section]
+        except KeyError:
+            # XXX: HTTP experts: is this correct?
+            status = '404 NOT FOUND'
+            response_headers = [
+                ('Content-Type', 'text/plain'),
+                ]
+            start_response(status, response_headers)
+            return [status]
         # Use index.txt for directory indices.
         if file_path == '' or file_path.endswith('/'):
             file_path += 'index' + config.rst_extension
                     """ % (config.hgweb_url, revision, file_path))
             hash = sha(data).hexdigest()
             # Look in cache first.
-            cache_filename = join(config.cache_dir, '%s.html' % hash)
-            if exists(cache_filename):
+            if config.cache_dir:
+                cache_filename = join(config.cache_dir, '%s.html' % hash)
+            if config.cache_dir and exists(cache_filename):
                 f = open(cache_filename, 'rb')
                 data = f.read()
                 f.close()
                     writer=w, 
                     settings_overrides=settings,
                     )
-                f = open(cache_filename, 'wb')
-                f.write(data)
-                f.close()
+                if config.cache_dir:
+                    f = open(cache_filename, 'wb')
+                    f.write(data)
+                    f.close()
             mime_type = 'text/html'
         status = '200 OK'
         response_headers = [