[Zope] TypeError: loop over non-sequence (Was: Logfiles)

Tille, Andreas TilleA@rki.de
Thu, 6 Dec 2001 10:54:55 +0100 (CET)


On Wed, 5 Dec 2001, Dieter Maurer wrote:

> Search for "STUPID_LOG_FILE" and you will become enlightened....
Light flashed into my dark brain now :)

Back to my original problem.

The log sais:

2001-12-06T09:40:39 ERROR(200) Zope Couldn't install MyFolder
Traceback (innermost last):
  File /usr/lib/zope/lib/python/OFS/Application.py, line 668, in install_product
    (Object: Zope)
    (Info: MyFolder)
  File /usr/lib/zope/lib/python/Products/MyFolder/__init__.py, line 7, in initialize
  File /usr/lib/zope/lib/python/App/ProductContext.py, line 233, in registerClass
  File /usr/lib/zope/lib/python/Interface/Util.py, line 66, in instancesOfObjectImplements
    (Object: MyFolder)
  File /usr/lib/zope/lib/python/Interface/Util.py, line 72, in _wi
    (Object: OFS.Folder)
TypeError: loop over non-sequence


but I really have no idea how to solve this.  The strange thing is that
I was able to run the MyFolder product without problems on a
   Debian GNU/Linux Sparc
machine with Zope Version: 2.3.3-1, but *not* on a
   Debian GNU/Linux i386
with the same Zope version.  With Zope 2.4.2 it did not work at all.

I attach the code of __init__.py and MyFolder.py in the hope that some
experienced programmer would open my right eye after my left one was opened
by Dieter :).

Thanks in advance

          Andreas.

~> cat __init__.py
from MyFolder import MyFolder, manage_addMyFolderForm, manage_addMyFolder

def initialize(registrar):
    registrar.registerClass(
        MyFolder,
        constructors = (manage_addMyFolderForm, manage_addMyFolder),
        icon = 'www/myfolder.png'
        )
    registrar.registerHelp()


~> cat MyFolder.py
"""MyFolder object

Derived from basic Folder

$Id: MyFolder.py,v 0.1 2001/11/30 10:26:52 tillea $"""

__version__='$Revision: 0.1 $'[11:-2]

from Acquisition import Implicit
from Globals import Persistent

from OFS import FindSupport, Folder, ObjectManager, PropertyManager
# from AccessControl import Role
from AccessControl import ClassSecurityInfo, getSecurityManager, Role
from webdav import Collection
from OFS.SimpleItem import Item

from Globals import InitializeClass, DTMLFile, default__class_init__

manage_addMyFolderForm=DTMLFile('dtml/myfolderAdd', globals())

def manage_addMyFolder(self, id, title='',
                     keywords=[], author='',
                     createPublic=1,
                     createSelection=1,
                     createHome=1,
                     createUserF=0,
                     REQUEST=None):
    """Add a new MyFolder object with id *id* and
       global keywords *keywords* and author *author*.

    If the 'createPublic' and 'createUserF' parameters are set to any true
    value, an 'index_html' and a 'UserFolder' objects are created respectively
    in the new folder.

    You can specify certain keywords which are inserted into each Document inside
    this folder.
    You can specify an author which are inserted into each Document inside
    this folder.
    """
    ob=MyFolder()
    ob.id=str(id)
    ob.title=title
    ob.keywords=[]
    for keyword in keywords:
        keyword=keyword.strip()
        if keyword != '' :
            ob.keywords.append(keyword)
    ob.author=author
    self._setObject(id, ob)
    ob=self._getOb(id)

    checkPermission=getSecurityManager().checkPermission

    if createUserF:
        if not checkPermission('Add User MyFolders', ob):
            raise 'Unauthorized', (
                  'You are not authorized to add User MyFolders.'
                  )
        ob.manage_addUserFolder()

    if createPublic:
        if not checkPermission('Add Documents, Images, and Files', ob):
            raise 'Unauthorized', (
                  'You are not authorized to add DTML Documents.'
                  )
        ob.manage_addDTMLDocument(id='index.htm', title=ob.id+' main frame')

    if createSelection:
        if not checkPermission('Add Documents, Images, and Files', ob):
            raise 'Unauthorized', (
                  'You are not authorized to add DTML Documents.'
                  )
        ob.manage_addDTMLDocument(id=ob.id+'_sel.htm', title=ob.id+' left navigation frame')

    if createHome:
        if not checkPermission('Add Documents, Images, and Files', ob):
            raise 'Unauthorized', (
                  'You are not authorized to add DTML Documents.'
                  )
        ob.manage_addDTMLDocument(id=ob.id+'_home.htm', title=ob.id+' home')

    if REQUEST is not None:
        return self.manage_main(self, REQUEST, update_menu=1)


def getProperty(self, id, d=None):
    """Get the property 'id', returning the optional second
       argument or None if no such property is found."""
    if self.hasProperty(id):
        if id == 'keywords' :
            safe_keywords=self.keywords
            self.keywords=[]
            for keyword in save_keywords:
                keyword=keyword.strip()
                if keyword != '' :
                    self.keywords.append(keyword)
        return getattr(self, id)
    return d

class MyFolder(Implicit,
    Persistent,
    ObjectManager.ObjectManager,
    PropertyManager.PropertyManager,
    Role.RoleManager,
    Collection.Collection,
    Item,
    FindSupport.FindSupport,
    ):
    """
    MyFolder is derived from Folder and supports global keywords and author
    """
    __implements__ = Folder
    meta_type='MyFolder'

    _properties=({'id':'title', 'type': 'string'},
                 {'id':'keywords', 'type':'lines', 'select_variable':'keywords'},
                 {'id':'author', 'type':'string', 'select_variable':'author'},)

    manage_options=(
        (ObjectManager.ObjectManager.manage_options[0],)+
        (
        {'label':'View', 'action':'index.htm',
         'help' : ('MyFolder', 'MyFolder_View.stx')},
        )+
        PropertyManager.PropertyManager.manage_options+
        Role.RoleManager.manage_options+
        Item.manage_options+
        FindSupport.FindSupport.manage_options
        )

#         'help' : ('MyFolder', 'MyFolder_View.stx'),
#         'label':'Properties', 'action':'manage_propertiesForm'},

    __ac_permissions__=()


default__class_init__(MyFolder)