Description

I have a config that doesn't have an underlay_dir, and get the following error:

Import of configuration file "homepage.py" failed because of TypeError: coercing to Unicode: need string or buffer, NoneType found.

We hope this error message make sense. If not, you are welcome to ask on #moin channel on irc.freenode.net, or on the mailing list. 

Furthermore, Nir's new error message handler broke mod_py completly if there are configuration errors. If you have fixed it by moving some variable initialisations in __init__, then you see the standard error which shows a broken traceback (not really useful).

Steps to reproduce

  1. create a new wiki with underlay_dir = None

  2. try to look at it.

MoinMoin Version

Latest patchlevel (some 4xx)

Workaround

Configure underlay, with an existing path, not None.

Discussion

Underlay is required, this is not a bug. Without underlay, you will have the problem of MoinMoinBugs/EmptyWiki, which this underlay check try to prevent.

But the code should handle the wrong value, so I leave this as a bug. The planed fix is to check for None or empty string value and show a proper error message.

-- NirSoffer 2004-12-18 19:04:25

That's crazy. I explicitly want an empty wiki as I'm only using it for personal stuff. Now please don't tell me I should set underlay_dir = "/tmp/empty" or something strange. If all you want to avoid is MoinMoinBugs/EmptyWiki, then set the default underlay_dir = "" (empty string) and allow me to override it with None. -- JohannesBerg 2004-12-21 15:31:09

You don't want an empty wiki, as you can't create new pages with it, since the MisssingPage is part of underlay. What the problem in removing any page you don't want to use from your underlay dir? Of course you can copy this page to you data dir, but then you will have to upgrade it when moin upgrade.

I'll think we will not check existence and accessibility of directories with value of empty strings or None. This will solve the problem for those who want to run without any directory.

Error message handler side effects not fixed --Alex

I don't have here modpy setup, so I don't know what are the side effects mentioned. This will have to be fixed by someone with modpy setup. -- NirSoffer 2004-12-19 01:47:22

Patch:

--- orig/MoinMoin/request.py
+++ mod/MoinMoin/request.py
@@ -1586,6 +1586,9 @@
             @param req: the mod_python request instance
         """
         try:
+            # flags if headers sent out contained content-type or status
+            self._have_ct = 0
+            self._have_status = 0
             req.add_common_vars()
             self.mpyreq = req
             # some mod_python 2.7.X has no get method for table objects,
@@ -1595,9 +1598,6 @@
             else:
                 env=req.subprocess_env
             self._setup_vars_from_std_env(env)
-            # flags if headers sent out contained content-type or status
-            self._have_ct = 0
-            self._have_status = 0
             RequestBase.__init__(self)
  
         except error.FatalError, err:

-- JohannesBerg 2004-12-21 15:45:49

I'll apply this patch. -- NirSoffer 2004-12-21 15:55:20

Update:

This isn't fixed totally in moin up to patch-501, I get the following traceback after applying above patch again:

Mod_python error: "PythonHandler MoinMoin.request::RequestModPy.run"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 291, in HandlerDispatch
    arg=req, silent=hlist.silent)

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 526, in resolve_object
    instance = parent(arg)

  File "/usr/local/lib/python2.3/site-packages/MoinMoin/request.py", line 1607, in __init__
    RequestBase.__init__(self)

  File "/usr/local/lib/python2.3/site-packages/MoinMoin/request.py", line 105, in __init__
    self.rootpage = Page(self, rootname, is_rootpage=1)

  File "/usr/local/lib/python2.3/site-packages/MoinMoin/Page.py", line 61, in __init__
    self.reset()

  File "/usr/local/lib/python2.3/site-packages/MoinMoin/Page.py", line 70, in reset
    underlaypath = os.path.join(self.cfg.data_underlay_dir, "pages", qpagename)

  File "/usr/lib/python2.3/posixpath.py", line 62, in join
    elif path == '' or path.endswith('/'):

AttributeError: 'NoneType' object has no attribute 'endswith'

Fairly obvious, the following patch fixes it: (committed to arch -- ThomasWaldmann 2005-01-11 02:51:04)

--- orig/MoinMoin/Page.py
+++ mod/MoinMoin/Page.py
@@ -67,7 +67,10 @@
         self.page_name_fs = qpagename

         # the normal and the underlay path used for this page
-        underlaypath = os.path.join(self.cfg.data_underlay_dir, "pages", qpagename)
+        if not self.cfg.data_underlay_dir is None:
+          underlaypath = os.path.join(self.cfg.data_underlay_dir, "pages", qpagename)
+        else:
+          underlaypath = None
         if self.is_rootpage: # we have no request.rootpage yet!
             if not page_name:
                 normalpath = self.cfg.data_dir

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/WrongErrorMessageWhenUnderlayIsNone (last edited 2007-10-29 19:05:59 by localhost)