On 1/25/10 9:31 AM, John wrote:
> On Sunday 24 January 2010 10:50:27 am John wrote:
>> On Sunday 24 January 2010 10:42:32 am Ed Leafe wrote:
>>> On Jan 24, 2010, at 1:34 PM, John wrote:
>>>> I guess I'll have to revert back.  But I wish I had discovered what was
>>>> causing the issue.  I'll wait a while in case you have another
>>>> suggestion.
>>>
>>>     It's almost always a class that tries to import something from uiwx
>>> before the app has started up. E.g., when I was creating dSpinner from
>>> other Dabo uiwx classes, I had to go through a lot to avoid the sort of
>>> problem you're seeing. The code would try to import something that hadn't
>>> yet been imported into the dabo.ui namespace, so it would try to re-load
>>> the UI classes, and get a sort of circular reference that would cause the
>>> kind of errors you're getting.
>>>
>>>
>>> -- Ed Leafe
>>
>> Would I see the uiwx.__init__.py called twice?  Also I don't see why your
>> recent changes in the code would suddenly cause my class code to error out?
>> I just added most (not all yet) of my classes to the test form without
>> error. Hmmm !
>>
>>
>> I'll look for the circular reference - thanks
>>
>> Johnf
>
> I have discovered that the order in which I import modules is very important.
> If I have the following I get errors.
>
> import wx
> dabo.ui.loadUI("wx")

Confirmed:
mac:dabo pmcnett$ python
impPython 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
o>>> import dabo
 >>> import wx
 >>> dabo.ui.loadUI("wx")
ui.loadUI failed: wxversion.ensureMinimal() must be called before wxPython is 
imported
Traceback (most recent call last):
   File "/home/pmcnett/dabo-full/trunk/dabo/ui/__init__.py", line 58, in loadUI
     exec("from %s import *" % mods[typ], globals())
   File "<string>", line 1, in <module>
   File "dabo/ui/uiwx/__init__.py", line 19, in <module>
     wxversion.ensureMinimal(minWx)
   File 
"/usr/local/lib/wxPython-unicode-2.8.9.1/lib/python2.5/site-packages/wxversion.py",
 
line 181, in ensureMinimal
     raise AlreadyImportedError("wxversion.ensureMinimal() must be called 
before 
wxPython is imported")
AlreadyImportedError: wxversion.ensureMinimal() must be called before wxPython 
is 
imported
False


> It is also true that any modules that contain similar imports will cause the
> error.

Yep.

> So the question is should the framework be so depended on the order of the
> imports?  I wouldn't think so.  In my modules I import many other modules to
> allow for testing.  Is it a requirement to isolate import's to insure they
> don't cause errors in Dabo?  It would seem that python and the framework
> should realize that the import's were in the namespace and not attempt to
> import again.  Isn't that standard Python?

This is unintended. Looking at that error I'm unsure how to use ensureMinimal() 
since 
we can't guarantee that wx hasn't been imported yet. Perhaps it would be 
acceptable 
to catch AlreadyImportedError in this case and just move on, which would be the 
same 
behavior as before in that case.

Thanks for pressing the issue, John.
Paul

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to