changeset 67:b5e72129ef72 draft

Support #errors w/ no params, as documented.
author David Barts <n5jrn@me.com>
date Sun, 14 Jul 2019 14:47:33 -0700
parents f33cb3e93473
children 61667621e19d
files tincan.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tincan.py	Fri Jul 12 20:27:52 2019 -0700
+++ b/tincan.py	Sun Jul 14 14:47:33 2019 -0700
@@ -135,6 +135,7 @@
     _NAMES = [ "errors", "forward", "methods", "python", "template" ]
     _FNAMES = [ "hidden" ]
     _ANAMES = [ "load" ]
+    _ONAMES = [ "errors" ]
 
     def __init__(self, string):
         # Initialize our state
@@ -179,7 +180,10 @@
                 continue
             # Get parameter
             if rpa is None:
-                raise TemplateHeaderError("Missing parameter.", count)
+                if name in self._ONAMES:
+                    rpa = ""
+                else:
+                    raise TemplateHeaderError("Missing parameter.", count)
             param = rpa.strip()
             for i in [ "'", '"']:
                 if param.startswith(i) and param.endswith(i):
@@ -585,7 +589,7 @@
             # self.logger.debug("forwarded to: %s", 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:
+        if oheader.hidden and oheader.errors is None:
             return
         # Get the code-behind #python
         if self._header.python is None:
@@ -687,7 +691,7 @@
             pypath = os.path.normpath(os.path.join(self._fsroot, *self._splitpath(self._python)))
         except IndexError as e:
             raise TinCanError("{0}: invalid #python".format(self._urlpath)) from e
-        klass = ErrorPage if self._header.errors else Page
+        klass = ErrorPage if self._header.errors is not None else Page
         # Give 'em a default code-behind if they don't furnish one
         pytime = self._gettime(pypath)
         if not pytime: