[Zope] Re: Annoying when objectValues() doesn't work
Tres Seaver
tseaver at palladion.com
Sat Jul 5 21:31:08 EDT 2008
-----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 at 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-----
More information about the Zope
mailing list