Hi all: In an python script i put the following code: "container.manage_delObjects([container.exampleFolder.getId()])" where "exampleFolder" is the name of an object of type "Folder" in the "container". This code delete the "exampleFolder" OK. But when I have the name of the "Folder" that i want to delete in a variable and call the "manage_delObjects", example: folderToDelete = "exampleFolder" container.manage_delObjects([container[folderToDelete]]) #or container.manage_delObjects([getattr(container, folderToDelete)]) ---------------------------- I get the following error: Error Type: AttributeError Error Value: __getslice__ ----------------------------- The Traceback: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 306, in __call__ Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec Module Products.PythonScripts.PythonScript, line 323, in _exec Module None, line 18, in update - <PythonScript at /approach/SiccApproach/Configuration/AuthenticationTypes/update> - Line 18 Module OFS.ObjectManager, line 453, in manage_delObjects Module OFS.ObjectManager, line 241, in _getOb AttributeError: __getslice__ ------------------------------- This appears that the "manage_delObjects" expect that somehow a non sequence entered a property expected to be a sequence.? My objetives is delete a object of type "Folder" in the "container" from this Script(Python) I use Zope2.7 Thanks in advance!
--On Mittwoch, 23. März 2005 12:37 Uhr -0400 Leticia Larrosa <LETICIA@tesla.cujae.edu.cu> wrote:
Hi all: In an python script i put the following code: "container.manage_delObjects([container.exampleFolder.getId()])" where "exampleFolder" is the name of an object of type "Folder" in the "container". This code delete the "exampleFolder" OK. But when I have the name of the "Folder" that i want to delete in a variable and call the "manage_delObjects", example: folderToDelete = "exampleFolder" container.manage_delObjects([container[folderToDelete]]) # or container.manage_delObjects([getattr(container, folderToDelete)]) ---------------------------- I get the following error: Error Type: AttributeError Error Value: __getslice__ ----------------------------- The Traceback: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 306, in __call__ Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec Module Products.PythonScripts.PythonScript, line 323, in _exec Module None, line 18, in update - <PythonScript at /approach/SiccApproach/Configuration/AuthenticationTypes/update> - Line 18 Module OFS.ObjectManager, line 453, in manage_delObjects Module OFS.ObjectManager, line 241, in _getOb AttributeError: __getslice__
manage_delObjects() takes a list of object *ids* and not of objects. -aj
Leticia Larrosa wrote at 2005-3-23 12:37 -0400:
... "manage_delObjects", example: folderToDelete = "exampleFolder" container.manage_delObjects([container[folderToDelete]]) #or container.manage_delObjects([getattr(container, folderToDelete)]) ---------------------------- I get the following error: Error Type: AttributeError Error Value: __getslice__
You pass in the object itself -- but you should pass its id. Thus, the following will probably work: container.manage_delObjects([folderToDelete]) -- Dieter
Thanks for all the answer but I try, for example whit: folderToDelete = 'toDelete' container.manage_delObjects([folderToDelete]) #or container.manage_delObjects([container[folderToDelete].getId()]) and get the following error in both cases: Error Type: KeyError Error Value: toDelete --------------------------- and the "really" traceback is: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 306, in __call__ Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec Module Products.PythonScripts.PythonScript, line 323, in _exec Module None, line 27, in update - <PythonScript at /approach/SiccApproach/Configuration/AuthenticationTypes/update> - Line 27 Module Shared.DC.Scripts.Bindings, line 306, in __call__ Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec Module Products.PageTemplates.ZopePageTemplate, line 222, in _exec Module Products.PageTemplates.PageTemplate, line 96, in pt_render - <ZopePageTemplate at /approach/SiccApproach/Configuration/AuthenticationTypes/update_html> Module TAL.TALInterpreter, line 190, in __call__ Module TAL.TALInterpreter, line 234, in interpret Module TAL.TALInterpreter, line 291, in do_startTag Module TAL.TALInterpreter, line 357, in attrAction_tal Module Products.PageTemplates.TALES, line 227, in evaluateText Module Products.PageTemplates.TALES, line 221, in evaluate - URL: /approach/SiccApproach/Configuration/AuthenticationTypes/update_html - Line 56, Column 13 - Expression: <PythonExpr container[request['autType']][request['autType']+'AuthType'].function()> - Names: {'container': <Folder instance at 430bbc80>, 'context': <Folder instance at 430bbc80>, 'default': <Products.PageTemplates.TALES.Default instance at 0x40aa4c6c>, 'here': <Folder instance at 430bbc80>, 'loop': <SafeMapping instance at 40ac2f90>, 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x40aa92ec>, 'nothing': None, 'options': {'args': (), 'msg': 'Usted ha tenido suerte, el servidor est\xe1 prendido y se ha podido modificar'}, 'repeat': <SafeMapping instance at 40ac2f90>, 'request': <HTTPRequest, URL=http://172.16.13.105:9673/approach/SiccApproach/Configuration/AuthenticationTypes/update>, 'root': <application instance at 43001b30>, 'template': <ZopePageTemplate at /approach/SiccApproach/Configuration/AuthenticationTypes/update_html>, 'traverse_subpath': [], 'user': leticia} Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ - __traceback_info__: container[request['autType']][request['autType']+'AuthType'].function() Module Python expression "container[request['autType']][request['autType']+'AuthType'].function()", line 1, in <expression> Module AccessControl.ZopeGuards, line 67, in guarded_getitem Module OFS.ObjectManager, line 663, in __getitem__ KeyError: 'adminSiccDB34' -----Original Message----- From: Dieter Maurer <dieter@handshake.de> To: "Leticia Larrosa" <LETICIA@tesla.cujae.edu.cu> Cc: zope@zope.org Date: Wed, 23 Mar 2005 20:16:15 +0100 Subject: Re: [Zope] manage_delObjects()
Leticia Larrosa wrote at 2005-3-23 12:37 -0400:
... "manage_delObjects", example: folderToDelete = "exampleFolder" container.manage_delObjects([container[folderToDelete]]) #or container.manage_delObjects([getattr(container, folderToDelete)]) ---------------------------- I get the following error: Error Type: AttributeError Error Value: __getslice__
You pass in the object itself -- but you should pass its id.
Thus, the following will probably work:
container.manage_delObjects([folderToDelete])
-- Dieter _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Leticia Larrosa wrote:
Thanks for all the answer but I try, for example whit:
folderToDelete = 'toDelete' container.manage_delObjects([folderToDelete])
if something called 'toDelete' exists, then this should work.
container.manage_delObjects([container[folderToDelete].getId()])
This is just tortological ;-) What does the code surrounding this section look like? I suspect that's where the problem lies... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Andreas Jung -
Chris Withers -
Dieter Maurer -
Leticia Larrosa