But in a web2py app, you would have something like 
/applications/Cast/modules/cast.py, and in your code you would just do 
'import cast'. My understanding of the problem is that in that case, the new 
web2py importer tries to import applications.cast.modules.cast instead of 
applications.Cast.modules.cast, which results in an import error. In fact, I 
cannot actually reproduce that problem (Windows 7, Python 2.7, web2py 
1.96.3) -- if I capitalize the name of the application folder, the web2py 
importer still appears to work. So, as far as I can tell, the importer 
works, even without the fix in trunk, though maybe I have misunderstood the 
problem.
 
Anthony

On Thursday, June 9, 2011 10:03:01 AM UTC-4, cjrh wrote: 

> Ok, so here is the thing: it appears that on Windows, everything works if 
> the capitalization of the import statement matches the capitalization of the 
> folder structure. 
>
> Consider this folder structure (and there is an __init__.py in each folder 
> hierarchy): 
>
>  /app/Cast/inner/cast.py
>
>
> In my file /test_imp.py, these contents WORK:
>
>  try:
>      import app.Cast.inner.cast
>      print 'Pass'
>  except:
>      print 'Fail'
>      pass
>
>
> These contents FAIL:
>
>  try:
>      import app.cast.inner.cast
>      print 'Pass'
>  except:
>      print 'Fail'
>      pass
>
>
> If, however, I change the folder structure to this:
>
>  /app/cast/inner/cast.py
>
>
> Then I get *exactly opposite results*.  In other words, the capitalization 
> of the import path in the python file and on the file system must exactly 
> match.  This is on Windows XP x64 SP2.  I have attached my test.
>
> In my opinion, we should just document that the cast must match.  Note that 
> this issue has *nothing to do with web2py*, and as a Windows user, I am 
> not too surprised by this behaviour anyway.
>

Reply via email to