[Zope-dev] MailHost, 2.2.1, and tracebacks

Bill Anderson bill@libc.org
Mon, 04 Sep 2000 13:58:27 -0600


Shane Hathaway wrote:
> 
> Bill Anderson wrote:
...
> >   File /local/ZopeSites/TestBed/lib/python/AccessControl/Owned.py, line 152, in getOwner
> >     (Object: mailPasswordTemplate)
> > ValueError: (see above)
> 
> By any chance does it say something to the effect of "Unpack tuple of
> incorrect size"?  If so, I suggest you add a "print owner" statement
> just before line 152 of Owner.py and tell us what it says.


Hi Shane, I apologize for the delay, been working on other aspects of it.
I added a print statement, and it prints [].
line 52 reads:
udb, oid = owner
Which makes sense that it would barf, since the list is zero-length.

Here is the code bit, with my print statement added in:
-------------------------
    def getOwner(self, info=0,
                 aq_get=aq_get, None=None, UnownableOwner=UnownableOwner,
                 ):
        """Get the owner

        If a true argument is provided, then only the owner path and id are
        returned. Otherwise, the owner object is returned.
        """
        owner=aq_get(self, '_owner', None, 1)
        if owner is None: return owner

        if info: return owner

        if owner is UnownableOwner: return None
        print owner
        udb, oid = owner
        root=self.getPhysicalRoot()
        udb=root.unrestrictedTraverse(udb, None)
        if udb is None: return SpecialUsers.nobody
        owner = udb.getUserById(oid, None)
        if owner is None: return SpecialUsers.nobody
        return owner
--------------------------

The following patch seems to alleviate the problem, but I dunno if it affects anything else:
==================
--- lib/python/AccessControl/Owned.py	Mon Sep  4 13:56:52 2000
+++ lib/python/AccessControl/Owned.py	Mon Sep  4 13:55:40 2000
@@ -149,6 +149,8 @@
             
         if owner is UnownableOwner: return None
 
+        if len(owner)==0: return None
+
         udb, oid = owner
         root=self.getPhysicalRoot()
         udb=root.unrestrictedTraverse(udb, None)
===================

Basically, I test for an empty list, and return None.

--
Do not meddle in the affairs of sysadmins, for they are easy to annoy,
and have the root password.