Hello, I plan to write a product derived from Folder which has some keywords as additional properties. Those keywords should be included as meta tags of the documents of this folder. I tried to understand the Zope Developers Guide and copied the basic folder class to MyFolder and did some changes. While I had some syntactical errors I´ve got a "Broken product" in my Zope product folder and found the error log. After fixing those errors I was quite happy - but now the Product vanished from my products folder after restarting Zope :-((. Any idea what could be wrong here? I'm using Zope 2.4.2 on a Debian GNU/Linux system. I might note that this could be caused by the following side effect. I had trouble installing the PageTemplate Product which was also not presented in the Products folder. When restarting Zope I've got: # /etc/init.d/zope restart Restarting Zope...WARNING: Python C API version mismatch for module pyexpat: This Python has API version 1010, module pyexpat has version 1007. ........ done. While doing my debugging stuff I did not see this Warning message. But when my Product MyFolder seemed to be syntactically OK this warning reapeared - and PageTemplates was in my Products folder mytseriousely. This is kind of strange but it might be that the warning is a hint that one of my products can not be installed and now MyFolder took over the role of PageTemplates? I append my really first try in a tar file. Could somebody please give me a hint? Kind regards Andreas.
Tille, Andreas writes:
I plan to write a product derived from Folder which has some keywords as additional properties. Those keywords should be included as meta tags of the documents of this folder.
I tried to understand the Zope Developers Guide and copied the basic folder class to MyFolder and did some changes. While I had some syntactical errors I´ve got a "Broken product" in my Zope product folder and found the error log. After fixing those errors I was quite happy - but now the Product vanished from my products folder after restarting Zope :-((. What do you see in the Zope log file (I means the "STUPID_LOG_FILE" not "var/Z2.log"!)?
.... # /etc/init.d/zope restart Restarting Zope...WARNING: Python C API version mismatch for module pyexpat: This Python has API version 1010, module pyexpat has version 1007. ........ done. Definitely not a good sign:
Your Zope accesses a "pyexpat" shared object (or DLL) that was generated for an older Python version than you use now. This may cause nasty crashes... Find the outdated shared object and replace it with one generated for your current Python version. Dieter
On Sat, 1 Dec 2001, Dieter Maurer wrote:
What do you see in the Zope log file (I means the "STUPID_LOG_FILE" not "var/Z2.log"!)? Sorry I'm to stupid to find such kind of logfile ... :-(
Find the outdated shared object and replace it with one generated for your current Python version. Please couny kind soul have a look at my product if it works on an other installation?
This would be very kind. Thanks a lot Andreas.
On Mon, 3 Dec 2001, Tille, Andreas wrote:
On Sat, 1 Dec 2001, Dieter Maurer wrote:
What do you see in the Zope log file (I means the "STUPID_LOG_FILE" not "var/Z2.log"!)? Sorry I'm to stupid to find such kind of logfile ... :-( Could anybody please enlighten me, how could I track down the problem when a Product just does not appear in my products folder? It was there as long as I had syntactical errors but after fixing them it just vanished and I can't find any log where it is recorded.
On interest I could repost the product in question in case somebody wants to debug it. Kind regards Andreas.
Tille, Andreas writes:
On Mon, 3 Dec 2001, Tille, Andreas wrote:
On Sat, 1 Dec 2001, Dieter Maurer wrote:
What do you see in the Zope log file (I means the "STUPID_LOG_FILE" not "var/Z2.log"!)? Sorry I'm to stupid to find such kind of logfile ... :-( Could anybody please enlighten me, how could I track down the problem when a Product just does not appear in my products folder? It was there as long as I had syntactical errors but after fixing them it just vanished and I can't find any log where it is recorded. You know the mailing list archives?
They are searchable via Google or NIP. Search for "STUPID_LOG_FILE" and you will become enlightened.... Dieter
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)
in class MyFolder you should remove the line '__implements__ = Folder' or replace 'Folder' with an interface ;-) Wolfram ----- Original Message ----- From: "Tille, Andreas" <TilleA@rki.de> Cc: "Zope user list" <zope@zope.org> Sent: Thursday, December 06, 2001 10:54 AM Subject: [Zope] TypeError: loop over non-sequence (Was: Logfiles)
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)
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Thu, 6 Dec 2001, Wolfram Kerber wrote:
in class MyFolder you should remove the line '__implements__ = Folder' Well, this helps!
or replace 'Folder' with an interface ;-) Well it was copied from Zope Developers Guide and I perhaps missinterpreted something because I'm a Python beginner.
Just to understand things right: Would you suggest using an interface? I found some interfaces in /usr/lib/zope/lib/python/Products/OFSP/help Namely Folder.py would perhaps be the right thing to use. (I thought it would be used in my __implements__ statement which was obviousely wrong.) Kind regards Andreas.
Well, i think interfaces are a good thing, it's just that they're not used very frequently in the current zope version because you usually 'implement' an interface by subclassing. Those interfaces you found are mainly for documentation (wich is an important aspect of interfaces nevertheless). This will all change with zope3 (looking forward to that)... For now i would suggest defining an interface just for the functionality that you add over a usual Folder and adding this to __implements__. so, you can write: class myFolder(Folder.Folder): ... __implements__ = Folder.__implements__ + (my_interface,) Wolfram ----- Original Message ----- From: "Tille, Andreas" <TilleA@rki.de> Cc: "Zope user list" <zope@zope.org> Sent: Thursday, December 06, 2001 11:32 AM Subject: [Zope] Re: TypeError: loop over non-sequence (Was: Logfiles)
On Thu, 6 Dec 2001, Wolfram Kerber wrote:
in class MyFolder you should remove the line '__implements__ = Folder' Well, this helps!
or replace 'Folder' with an interface ;-) Well it was copied from Zope Developers Guide and I perhaps missinterpreted something because I'm a Python beginner.
Just to understand things right: Would you suggest using an interface?
I found some interfaces in
/usr/lib/zope/lib/python/Products/OFSP/help
Namely Folder.py would perhaps be the right thing to use. (I thought it would be used in my __implements__ statement which was obviousely wrong.)
Kind regards
Andreas.
participants (3)
-
Dieter Maurer -
Tille, Andreas -
Wolfram Kerber