Hi Zopists, I try to create ISNGFolder class which is subclassed from Zope Folder class. During instantiation of this ISNGFolder class I also try to set permissions ['View', 'Access contents information'] for role 'Content' by calling manage_role('Content', ['View', 'Access contents information']) function of this object. But some error occurs and I don't know python API very well for folderish objects. Can somebody help me, please?? I use Zope 2.1.6 on Linux Debian Below you can see part of my python product for folderish object and error output of Zope. Begin of code: manage_addISNGFolderForm=HTMLFile('addFolder', globals()) def manage_addISNGFolder(self, cz_id, title='', key_words=[], header='', footer='', createPublic=0, createUserF=0, REQUEST=None): """Add a new 'ISNG Folder' object with id *id*.""" author = repr(REQUEST.AUTHENTICATED_USER) id = cz_id2id(cz_id) ob=ISNGFolder() ob.id = id ob.cz_id = cz_id ob.title = title ob.creation = DateTime.DateTime(time.time()) ob.author = author ob.modifier = author ob.key_words = key_words ob.header = header ob.footer = footer self._setObject(id, ob) ob.manage_role('Content', ['Access contents information', 'View']) if REQUEST is not None: return MessageDialog( title = 'Add ISNGFolder', message = 'New ISNGFolder %s was added.' % ob.getProperty('cz_id'), action = './addFolder' ) class ISNGFolder(Folder): """ISNGFolder class. Is created by inheritance from Folder Zope object.""" meta_type = 'ISNG Folder' __ac_permissions__ = ( ('View', ('manage_infoISNGForm',)), ) _properties = ( {'id':'title', 'type':'string', 'mode':'w'}, {'id':'cz_id', 'type':'string', 'mode':'w'}, {'id':'author', 'type':'string', 'mode':'w'}, {'id':'modifier', 'type':'string', 'mode':'w'}, {'id':'key_words', 'type':'lines', 'mode':'w'}, {'id':'header', 'type':'text', 'mode':'w'}, {'id':'footer', 'type':'text', 'mode':'w'} ) _ManageOptions = ( {'label':'Edit ISNG', 'action':'manage_editISNGForm'}, {'label':'Info ISNG', 'action':'manage_infoISNGForm'}, {'label':'Header ISNG', 'action':'manage_editHeaderISNGForm'}, {'label':'Footer ISNG', 'action':'manage_editFooterISNGForm'}, {'label':'Permissions ISNG', 'action':'manage_permissionsFrameISNGForm'}, ) Error output of Zope: Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: aq_acquire Troubleshooting Suggestions The URL may be incorrect. The parameters passed to this resource may be incorrect. A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience. Traceback (innermost last): File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/www/Zope-2.1.6/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_addISNGFolder) File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_addISNGFolder) File /usr/local/www/Zope-2.1.6/lib/python/Products/ISNG/ISNG.py, line 810, in manage_addISNGFolder File /usr/local/www/Zope-2.1.6/lib/python/AccessControl/Role.py, line 179, in manage_role (Object: ElementWithAttributes) File /usr/local/www/Zope-2.1.6/lib/python/AccessControl/Role.py, line 137, in ac_inherited_permissions (Object: ElementWithAttributes) File /usr/local/www/Zope-2.1.6/lib/python/OFS/ObjectManager.py, line 173, in _subobject_permissions (Object: ElementWithAttributes) AttributeError: (see above) -- Petr Knápek NEXTRA Czech Republic, s.r.o., Hlinky 114, 603 00 Brno, Czech Republic e-mail: mailto:petr.knapek@nextra.cz tel:+420-5-43 554 150 FAX:+420-5-43 554 214 "Perl is worse than Python because people wanted it worse." Larry Wall, 14 Oct 1998
The error would be with aq_acquire, do you have that specified anywhere in your code (eg in the __init__)? -- Andy McKay, Developer. ActiveState. ----- Original Message ----- From: "Petr Knapek" <knapek@knapek.pvt.net> To: <zope@zope.org> Sent: Monday, November 06, 2000 4:46 AM Subject: [Zope] Folderish object -API
Hi Zopists, I try to create ISNGFolder class which is subclassed from Zope Folder class. During instantiation of this ISNGFolder class I also try to set permissions ['View', 'Access contents information'] for role 'Content' by calling manage_role('Content', ['View', 'Access contents information']) function of this object. But some error occurs and I don't know python API very well for folderish objects. Can somebody help me, please??
I use Zope 2.1.6 on Linux Debian
Below you can see part of my python product for folderish object and error output of Zope.
Begin of code:
manage_addISNGFolderForm=HTMLFile('addFolder', globals())
def manage_addISNGFolder(self, cz_id, title='', key_words=[], header='', footer='', createPublic=0, createUserF=0, REQUEST=None): """Add a new 'ISNG Folder' object with id *id*."""
author = repr(REQUEST.AUTHENTICATED_USER) id = cz_id2id(cz_id) ob=ISNGFolder() ob.id = id ob.cz_id = cz_id ob.title = title ob.creation = DateTime.DateTime(time.time()) ob.author = author ob.modifier = author ob.key_words = key_words ob.header = header ob.footer = footer self._setObject(id, ob) ob.manage_role('Content', ['Access contents information', 'View']) if REQUEST is not None: return MessageDialog( title = 'Add ISNGFolder', message = 'New ISNGFolder %s was added.' % ob.getProperty('cz_id'), action = './addFolder' )
class ISNGFolder(Folder): """ISNGFolder class.
Is created by inheritance from Folder Zope object."""
meta_type = 'ISNG Folder'
__ac_permissions__ = ( ('View', ('manage_infoISNGForm',)), )
_properties = ( {'id':'title', 'type':'string', 'mode':'w'}, {'id':'cz_id', 'type':'string', 'mode':'w'}, {'id':'author', 'type':'string', 'mode':'w'}, {'id':'modifier', 'type':'string', 'mode':'w'}, {'id':'key_words', 'type':'lines', 'mode':'w'}, {'id':'header', 'type':'text', 'mode':'w'}, {'id':'footer', 'type':'text', 'mode':'w'} )
_ManageOptions = ( {'label':'Edit ISNG', 'action':'manage_editISNGForm'}, {'label':'Info ISNG', 'action':'manage_infoISNGForm'}, {'label':'Header ISNG', 'action':'manage_editHeaderISNGForm'}, {'label':'Footer ISNG', 'action':'manage_editFooterISNGForm'}, {'label':'Permissions ISNG', 'action':'manage_permissionsFrameISNGForm'}, )
Error output of Zope:
Zope Error
Zope has encountered an error while publishing this resource.
Error Type: AttributeError Error Value: aq_acquire
Troubleshooting Suggestions
The URL may be incorrect. The parameters passed to this resource may be incorrect. A resource that this resource relies on may be encountering an error.
For more detailed information about the error, please refer to the HTML source for this page.
If the error persists please contact the site maintainer. Thank you for your patience.
Traceback (innermost last): File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/www/Zope-2.1.6/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_addISNGFolder) File /usr/local/www/Zope-2.1.6/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_addISNGFolder) File /usr/local/www/Zope-2.1.6/lib/python/Products/ISNG/ISNG.py, line 810, in manage_addISNGFolder File /usr/local/www/Zope-2.1.6/lib/python/AccessControl/Role.py, line 179, in manage_role (Object: ElementWithAttributes) File /usr/local/www/Zope-2.1.6/lib/python/AccessControl/Role.py, line 137, in ac_inherited_permissions (Object: ElementWithAttributes) File /usr/local/www/Zope-2.1.6/lib/python/OFS/ObjectManager.py, line 173, in _subobject_permissions (Object: ElementWithAttributes) AttributeError: (see above)
-- Petr Knápek NEXTRA Czech Republic, s.r.o., Hlinky 114, 603 00 Brno, Czech Republic e-mail: mailto:petr.knapek@nextra.cz tel:+420-5-43 554 150 FAX:+420-5-43 554 214
"Perl is worse than Python because people wanted it worse." Larry Wall, 14 Oct 1998
_______________________________________________ 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 )
Petr Knapek wrote:
def manage_addISNGFolder(self, cz_id, title='', key_words=[], header='', footer='', createPublic=0, createUserF=0, REQUEST=None): """Add a new 'ISNG Folder' object with id *id*."""
...
ob=ISNGFolder()
...
ob.manage_role('Content', ['Access contents information', 'View'])
Your problem is here and I'm betting it's 'cos #ob' isn't an acquisition wrapper... Try replacing the above line with: ob.__of__(self).manage_role('Content', ['Access contents information', 'View']) cheers, Chris
participants (3)
-
Andy McKay -
Chris Withers -
Petr Knapek