Annoying when objectValues() doesn't work
from cStringIO import StringIO def workflowscripts2methods(self): out = StringIO() print >>out, "Star converting workflow scripts into External Methods" pw = self.portal_workflow for workflow in pw.objectValues('Workflow'): for container in workflow.objectValues('Workflow Scripts'): meta_type = 'Script (Python)' for script in container.objectValues(meta_type): assert script.meta_type == meta_type print >>out, "script (%r, %s)" % (script.meta_type, script.absolute_url_path()) value = out.getvalue() print value return value I'm getting an AssertionError on this!!! After having used objectValues() for so many many years without much trouble my confidence in it just dropped. Anybody else seen something like this? -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
--On 3. Juli 2008 15:41:52 +0100 Peter Bengtsson <peter@fry-it.com> wrote:
I'm getting an AssertionError on this!!! After having used objectValues() for so many many years without much trouble my confidence in it just dropped.
After years of Zope, you know that we need a full traceback :-) Andreas
Peter Bengtsson wrote at 2008-7-3 15:41 +0100:
from cStringIO import StringIO
def workflowscripts2methods(self): out = StringIO()
print >>out, "Star converting workflow scripts into External Methods"
pw = self.portal_workflow for workflow in pw.objectValues('Workflow'): for container in workflow.objectValues('Workflow Scripts'): meta_type = 'Script (Python)' for script in container.objectValues(meta_type): assert script.meta_type == meta_type print >>out, "script (%r, %s)" % (script.meta_type, script.absolute_url_path())
value = out.getvalue() print value return value
I'm getting an AssertionError on this!!!
For efficiency reasons, a "Folder" maintains the meta types used for filtering "object*" in a separate structure (this is the "_objects" attribute for normal folders). Your "AssertionError" indicates that this structure is inconsistent with the true objects. As long as a folder is only modified by the official "Folder" api ("_setObject", "_delObject" and higher level functions), consistency is garanteed. However, lower level functions can destroy the consistency. It is not a problem with "objectValues". The problem must be elsewhere. -- Dieter
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Peter Bengtsson wrote:
from cStringIO import StringIO
def workflowscripts2methods(self): out = StringIO()
print >>out, "Star converting workflow scripts into External Methods"
pw = self.portal_workflow for workflow in pw.objectValues('Workflow'): for container in workflow.objectValues('Workflow Scripts'): meta_type = 'Script (Python)' for script in container.objectValues(meta_type): assert script.meta_type == meta_type print >>out, "script (%r, %s)" % (script.meta_type, script.absolute_url_path())
value = out.getvalue() print value return value
I'm getting an AssertionError on this!!! After having used objectValues() for so many many years without much trouble my confidence in it just dropped. Anybody else seen something like this?
Change the bare assert to generate more info, e.g.: if script.meta_type != meta_type: raise ValueError('Invalide meta_type (%s) for object %s' % (script.meta_type, script.getId())) and debug from there. You might also add the PDBDebugMode product to your instance, which would allow you to put an 'import pdb; pdb.set_trace()' inside the script. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIcCBc+gerLs4ltQ4RAoOsAJoDc07f4P8D/dBRFBQ5uOtfIqprNQCfUCAW LGXgba7MF5vvK+wIEo77/iQ= =kqGy -----END PGP SIGNATURE-----
participants (4)
-
Andreas Jung -
Dieter Maurer -
Peter Bengtsson -
Tres Seaver