[PEAK] Strange behaviour

Tiago Cogumbreiro cogumbreiro at gmail.com
Wed Jul 20 13:04:00 EDT 2005

Thanks Philip for your fast reply.

Btw, I'm learning how peak.events work and created a wiki entry for it.


If someone is interested in adding some examples it would be great.

On 7/20/05, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 09:00 PM 7/19/2005 +0000, Tiago Cogumbreiro wrote:
> >Hello list,
> >
> >While doing a very small example the strangest thing happened. I am
> >registring my models in the [Component Factories] entry of the INI
> >file, just as the bulletins example. The problem is, when I try to use
> >the DM _the first_ an error about not being able to import the module
> >appears. I am using this in a test case and as you can see the second
> >time it's run the problem silently goes away.
> >
> >Can someone help me spot what am I doing wrong?
> Your helpdesk/__init__.py imports 'storage' from peak.api, and importString
> picks this up as being 'helpdesk.storage'.  It then tries to retrieve
> 'ClientDM' from peak.storage.api as a result.  When this fails, it falls
> back to attempting to import 'helpdesk.storage.ClientDM' as a module.  This
> fails, but it causes the correct 'helpdesk.storage' module to be loaded as
> a side effect, such that subsequent checks work.
> So, in helpdesk/__init__.py you shouldn't use 'from peak.api import *';
> it's generally not a great idea to put much in __init__.py files anyway.
> I could probably also change importString() to try importing *before* doing
> getattr(), and maybe display better error information, but I'm not sure
> when I'll have time to do that and figure out some tests for it.
> _______________________________________________
> PEAK mailing list
> PEAK at eby-sarna.com
> http://www.eby-sarna.com/mailman/listinfo/peak

Tiago Cogumbreiro <cogumbreiro at users.sf.net>


More information about the PEAK mailing list