diff tincan.py @ 12:496d43d551d2 draft

More redirecting fixes and improved error reportage.
author David Barts <n5jrn@me.com>
date Wed, 15 May 2019 00:16:06 -0700
parents 8037bad7d5a8
children 6de828de4409
line wrap: on
line diff
--- a/tincan.py	Wed May 15 00:00:45 2019 -0700
+++ b/tincan.py	Wed May 15 00:16:06 2019 -0700
@@ -361,7 +361,11 @@
             try:
                 self._template = TemplateFile(self._fspath)
             except IOError as e:
-                raise TinCanError(str(e)) from e
+                if oheader is not None:
+                    note = "{0}: invalid #forward: ".format(self._origin)
+                else:
+                    note = ""
+                raise TinCanError("{0}{1!s}".format(note, e)) from e
             try:
                 self._header = TemplateHeader(self._template.header)
             except TemplateHeaderError as e:
@@ -372,9 +376,9 @@
                 raise TinCanError("{0}: invalid #forward".format(self._origin))
             if self._header.forward is None:
                 break
-            print("forwarding from:", self._urlpath)  # debug
+            # print("forwarding from:", self._urlpath)  # debug
             self._redirect()
-            print("forwarded to:", self._urlpath)  # debug
+            # print("forwarded to:", self._urlpath)  # debug
         # If this is a #hidden page, we ignore it for now, since hidden pages
         # don't get routes made for them.
         if oheader.hidden and not oheader.errors:
@@ -485,7 +489,7 @@
         self._subdir = rlist
         self._python = name + _PEXTEN
         self._fspath = os.path.join(self._fsroot, *self._subdir, rname)
-        self._urlpath = self._urljoin(*self._subdir, rname)
+        self._urlpath = '/' + self._urljoin(*self._subdir, rname)
 
     def _urljoin(self, *args):
         args = list(args)