web2py 1.96.1 is OUT

310 views
Skip to first unread message

Massimo Di Pierro

unread,
Jun 1, 2011, 2:25:28 PM6/1/11
to web2py-users
I could not wait any longer. We had so many changes that we need to
move on.
I do not recall any other release with so many new features. Thanks to
all those who have contributed with patches and testing.

Changelog:

- "from gluon import *" imports in every python module a web2py
environment (A, DIV,..SQLFORM, DAL, Field,...) including
current.request, current.response, current.session, current.T,
current.cache, thanks Jonathan.
- conditional models in
models/<controller>/a.py and models/<controller>/<function>/a.py
- from mymodule import *, looks for mymodule in applications/thisapp/
modules first and then in sys.path. No more need for local_import.
Thanks Pierre.
- usage of generic.* views is - by default - restricted to localhost
for security. This can be changed in a granular way with:
response.generic_patterns=['*']. This is a slight change of behavior
for new app but a major security fix.

- all applications have cas 2.0 provider at http://.../user/cas/login
- all applications can delegate to login to external provider
Auth(...,cas_provider='http://.../other_app/default/user/cas')
- A(...,callback=URL(...),larget='id') does Ajax
- URL(...,user_signature=True), LOAD(...,user_signature=True) can sign
urls and @auth.requires_signature() will check the signature for any
decorated action.

- DAL(...,migrate_enabled=False) to disable all migrations
- DAL(...,fake_migrate_all=True) to rebuild all corrupted metadata
- new DAL metadata format (databases/*.table)
- DAL(...,adapter_arg={}) allows support for alternate drivers
- DAL now allows circular table defintions
- DAL(..,auto_import=True) automatically imports tables from metadata
without need to db.define_table(...)s.
- new alterante syntax for inner joins: db(...).select(join=...)
- experimental cubrid database support
- DAL 'request_tenant' fields are special, the altomatically filer all
records based on their default value.
- db._common_fields.append(Field('owner')) allows to add fields to ALL
tables
- DAL ignores repeated fields with same names

- web2py_ajax.html is more modular, thanks Anthony
- request.is_local
- request.is_http
- new sessions2trash.py thanks Jim Karsten
- corrupted cache files are automatically deleted
- new simpler API gluon.contrib.AuthorizeNet.procss(...)
- fixed recaptcha (as they released new API)
- messages in validators have default internationalization
- No more Auth(globals(),db), just Auth(db). Same for Crud and
Service.
- scripts/access.wsgi allows apache+mod_wsgi to delegate
authentication of any URL to any web2py app
- json now supports T(...)
- scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
- web2py HTTP responses now set: "X-Powered-By: web2py", thanks Bruno
- mostly fixed generic.pdf. You can view any page in PDF if you have
pdflatex installed or if your html follows the pyfpdf convention.
- auth.settings.extra_fields['auth_user'].append(Field('country'))
allows to extend auth_* tables without need of definiting a custom
auth_* table. Must be placed before auth.define_tables()
- {{=response.toolbar()}} to help you debug applications
- web based shell now supports object modifications (but no
redefinitions of non-serializable types)
- jQuery 1.6.1
- Lots of bug fixes

Jason Brower

unread,
Jun 1, 2011, 2:40:47 PM6/1/11
to web...@googlegroups.com, Massimo Di Pierro

Me does a dance. Thanks!

contatog...@gmail.com

unread,
Jun 1, 2011, 2:54:51 PM6/1/11
to web...@googlegroups.com
All new features will be documented? How will it be? Will be collaborativedocumentation?
_____________________________________________
Gilson Filho

pbreit

unread,
Jun 1, 2011, 2:56:51 PM6/1/11
to web...@googlegroups.com
Great release. I've been waiting for a stable release to move into production which I will probably stay with for awhile.

Massimo Di Pierro

unread,
Jun 1, 2011, 3:30:43 PM6/1/11
to web2py-users
Give it a day or to since new bugs always popup after a release with
so many changes.

szimszon

unread,
Jun 1, 2011, 3:38:44 PM6/1/11
to web...@googlegroups.com
- URL(...,user_signature=True), LOAD(...,user_signature=True) can sign
urls and @auth.requires_signature() will check the signature for any
decorated action.

Sorry for a stupid question but what is an url signature how does it work?

Massimo Di Pierro

unread,
Jun 1, 2011, 3:48:49 PM6/1/11
to web2py-users
Not a stupid question. Consider this code:

def index():
if user_has_permission_to_call_other():
link = A('click',_href=URL('other'))
else:
link = DIV('do nothing')
return dict()

def other():
if not user_has_permission_to_call_other():
redirect(URL('index'))
return dict()

The code is checking twice whether the
user_has_permission_to_call_other. You must check twice else you
display the link to users who do not have access or you expose the url
to users who do not have access. The same problem applies to
callbacks. Now you can do:

def index():
if user_has_permission_to_call_other():
link = A('click',_href=URL('other',user_signature=True))
else:
link = DIV('do nothing')
return dict()

@auth.requires_signature()
def other():
return dict()

Now the check is done in one single place. The code is faster and
cleaner.

The url in the link is "signed" by appending a ?_signature=<code> that
is only valid for this user during this session. Even if URL('other')
where to be made public accidentally, nobody else could access it. The
signature (the <code> string) is a HMAC hash using private key for the
session. It contains a hash of the full url including all parameters
passed to it.

Niphlod

unread,
Jun 1, 2011, 3:59:02 PM6/1/11
to web2py-users
from what I can see it pushes further variuos uses of the "old"
functions "from gluon.html import verifyURL" to verify the hashed URL
and URL(hmac_key='...') to generate the hashed one. Basically it's a
method that "appends" a variable (as
"_signature=djhdsajhdasjhdasjhdas" parameter in the URL) to allow only
the designated user access the specified URL. (nice for protecting
some ajax calls, for example ^_^)

Pystar

unread,
Jun 1, 2011, 4:31:59 PM6/1/11
to web2py-users
auth.settings.extra_fields['auth_user'].append(Field('country'))

does this new release allow me to remove fields from the auth table?
e.g. auth.settings.extra_fields['auth_user'].remove(Field('country'))?
Thanks Max, great release.

Massimo Di Pierro

unread,
Jun 1, 2011, 4:56:29 PM6/1/11
to web2py-users
You can add fields before the table is defined. You cannot add or
remove fields after the table is defined. You also cannot remove
fields before the table is defined. I could add this but it would be
less transparent that just make a custom table.

pbreit

unread,
Jun 1, 2011, 5:02:27 PM6/1/11
to web...@googlegroups.com
I saw in the changesets some notes about salts and smart_hashes. Is it now possible to salt password hashes?

Pystar

unread,
Jun 1, 2011, 5:11:05 PM6/1/11
to web2py-users
Ok, if I can not do
"auth.settings.extra_fields['auth_user'].remove(Field('country'))? "
can I do something like similar to this "SQLFORM(database.table,
fields["a", "b"])"?
Since I can not remove fields from the auth table, then I can add the
fields I want and display them only.
Thanks

On Jun 1, 9:56 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:

Massimo Di Pierro

unread,
Jun 1, 2011, 5:14:34 PM6/1/11
to web2py-users
There is nothing new in this respect. I think you can salt the
password in this way:

import uuid
session._salt = session._salt or str(uuid.uuid4()
auth.settings.extra_fields['auth_user'].append(Field('salt',writable=False,readable=False,default=session._salt))
auth.define_tables()
...
if auth.user: session._salt=auth.user.salt
db.auth_user.password.requires=CRYPT(auth.settings.hmac_key
+session._salt)

give it a try.

Grigory Antonov

unread,
Jun 1, 2011, 3:56:46 PM6/1/11
to web2py-users
Hi, please, give some comments about new features:
> - "from gluon import *" imports in every python module a web2py
> environment (A, DIV,..SQLFORM, DAL, Field,...) including
> current.request, current.response, current.session, current.T,
> current.cache, thanks Jonathan.
While using ide's like pycharm, there are some problems with
completion and discover of web2py internal variables like request,
response, this new feature should improve ide support, but it's
happened so that in the code we use response and request, and "from
gluon import *" feature imports current.response and current.request.
How can I fix this? I mean what should I place in gluon to help ide
understand "request" without "current"?


> - request.is_local
If I understand correctly this function checks whether app is working
on localhost, if so, then maybe it will be really simple to add
another feature - while working on localhost(mostly development mode),
when something raises an error, show not link to ticket, but straight
debug info page, just skip "clicking on ticket link" step - this will
speed up dev process.

Thank you for making web2py better )

Sebastian E. Ovide

unread,
Jun 1, 2011, 6:33:17 PM6/1/11
to web...@googlegroups.com
WAW ! impressive ....
--
Sebastian E. Ovide



Stifan Kristi

unread,
Jun 1, 2011, 6:37:47 PM6/1/11
to web...@googlegroups.com
awesome, great job, everyone, thank you so much

Massimo Di Pierro

unread,
Jun 1, 2011, 7:09:47 PM6/1/11
to web2py-users
hmmm. I responded already but my response does not show. trying
again...

On Jun 1, 2:56 pm, Grigory Antonov <antono...@gmail.com> wrote:
> Hi, please, give some comments about new features:> - "from gluon import *" imports in every python module a web2py
> > environment (A, DIV,..SQLFORM, DAL, Field,...) including
> > current.request, current.response, current.session, current.T,
> > current.cache, thanks Jonathan.
>
> While using ide's like pycharm,  there are some problems with
> completion and discover of web2py internal variables like request,
> response, this new feature should improve ide support, but it's
> happened so that in the code we  use response and request, and "from
> gluon import *" feature  imports current.response and current.request.
> How can I fix this? I mean what should I place in gluon to help ide
> understand "request" without "current"?

I think you can do

if False:
from gluon import *; globals().update(current.__dict__)

but I did not try.

> > - request.is_local
>
> If I understand correctly this function checks whether app is working
> on localhost, if so, then maybe it will be really simple to add
> another feature - while working on localhost(mostly development mode),
> when something raises an error, show not link to ticket, but straight
> debug info page, just skip "clicking on ticket link" step - this will
> speed up dev process.

The problem is that one cannot reliably determine whether the client
is on localhost.
request.is_local is a guess, not a certainty. Moreover the user may be
local but not the administrator since there may be more users local on
the same machine.

Pierre Thibault

unread,
Jun 1, 2011, 7:28:10 PM6/1/11
to web...@googlegroups.com
But there is another cool feature in the trunk. If you look in gluon/custom_import.py, you will see two new functions: is_tracking_changes and track_changes. Call track_changes with True and web2py will track the changes made to all Python module source files you are using. The new importer will automatically reload the last version available at the next import statement. Of course, is_tracking_changes() gives the current status.

What could be better? Well, the import tracking feature is generic so you can use it in any Python project. If you want to use it outside web2py, use the version available at http://code.google.com/p/neo-i...

Take a look at Martin's blog: http://martin.tecnodoc.com.ar/default/post/2011/05/13/20_optimize-your-web2py-app-using-the-new-import-method
--


A+

-------------
Pierre
My blog and profile (http://pierrethibault.posterous.com)
YouTube page (http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2)

szimszon

unread,
Jun 2, 2011, 2:47:42 AM6/2/11
to web...@googlegroups.com
Thanks

Miguel Lopes

unread,
Jun 2, 2011, 4:11:32 AM6/2/11
to web...@googlegroups.com
On Wed, Jun 1, 2011 at 7:40 PM, Jason Brower <enco...@gmail.com> wrote:

Me does a dance. Thanks!

And yes it makes rain :-)

Praneeth Bodduluri

unread,
Jun 2, 2011, 7:08:02 AM6/2/11
to web...@googlegroups.com

Also available on pypi, get it while it's hot.

Plumo

unread,
Jun 3, 2011, 9:11:49 AM6/3/11
to web...@googlegroups.com
some really nice features there that make web2py more like typical python scripts. Fantastic!  

Alessandro Iob

unread,
Jun 3, 2011, 3:40:45 PM6/3/11
to web...@googlegroups.com
I have tried the new modules import feature (from mymodule import *, looks for mymodule in applications/thisapp/ modules first and then in sys.path. No more need for local_import) and it works wonderfully on OS/X but not at all on Windows. Below you can find the traceback.
 
web2py™Version 1.96.2 (2011-06-03 16:11:39)
PythonPython 2.5.4: C:\web2py\web2py.exe

Traceback (most recent call last):
File "gluon/restricted.py", line 184, in restricted
File "C:/web2py/applications/castalia/controllers/default.py", line 2, in <module>
File "gluon/custom_import.py", line 280, in __call__
File "gluon/custom_import.py", line 125, in __call__
ImportError: No module named selfgroup.castalia

Any suggestion?
Thank you

Massimo Di Pierro

unread,
Jun 3, 2011, 7:54:31 PM6/3/11
to web2py-users
please open a ticken on google code

On Jun 3, 2:40 pm, Alessandro Iob <alessandro....@gmail.com> wrote:
> I have tried the new modules import feature (from mymodule import *, looks
> for mymodule in applications/thisapp/ modules first and then in sys.path. No
> more need for local_import) and it works wonderfully on OS/X but not at all
> on Windows. Below you can find the traceback.
>
> web2py™Version 1.96.2 (2011-06-03 16:11:39)PythonPython 2.5.4:
> C:\web2py\web2py.exe
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 184, in restricted
>   File "C:/web2py/applications/castalia/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/castalia/controllers/default.py>, line 2, in <module>

Pierre Thibault

unread,
Jun 4, 2011, 6:20:21 PM6/4/11
to web...@googlegroups.com
2011/6/3 Alessandro Iob <alessan...@gmail.com>


Hello Alessandro,

I wrote this code but I don't have Windows to do testing. I suspect it is a problem related to os.stat.

Can you run this code on your machine and gave me the result?

import os
print os.stat("path to the module you want to import").st_mtime

Alessandro Iob

unread,
Jun 5, 2011, 3:59:42 AM6/5/11
to web...@googlegroups.com
Hi Pierre,

this is the output of the code from the web2py application shell:

web2py Shell Version 1.96.2 (2011-06-03 16:11:39)
In [1] : from selfgroup.castalia import config

Traceback (most recent call last):
  File "gluon/contrib/shell.py", line 233, in run
  File "<string>", line 1, in <module>
  File "gluon/custom_import.py", line 280, in __call__
  File "gluon/custom_import.py", line 125, in __call__
ImportError: No module named selfgroup.castalia

In [2] : import os
In [3] : print os.stat("C:\web2py\\applications\Castalia\modules\selfgroup\castalia\__init__.py").st_mtime

1304593994.0
.

Thank you very much,
Alessandro

weheh

unread,
Jun 5, 2011, 10:46:03 AM6/5/11
to web2py-users
Amazing release! Congrats to all who helped. I came across some stuff
while testing:

- If I change auth=Auth(globals(),db) to auth=Auth(db) I get a ticket:

Traceback (most recent call last):
File "N:\web2py\gluon\restricted.py", line 188, in restricted
exec ccode in environment
File "N:/web2py/applications/YAKiToMe/models/0_1_db.py", line 15, in
<module>
auth=Auth(db)
File "N:\web2py\gluon\tools.py", line 782, in __init__
auth = session.auth
AttributeError: 'NoneType' object has no attribute 'auth'

- Where do you recommend I put the gluon import *? Does it belong in
every controller or just one of the models? I tried a couple of
different places but the results in Eclipse were confusing.

pbreit

unread,
Jun 5, 2011, 11:12:16 AM6/5/11
to web...@googlegroups.com
I have this:

from gluon.tools import Auth
auth = Auth(db)

weheh

unread,
Jun 5, 2011, 1:49:54 PM6/5/11
to web2py-users
I already had

from gluon.tools import *

# the new way
auth=Auth(db) # this causes error

# the old way
auth=Auth(globals(),db) # still works

Pierre Thibault

unread,
Jun 5, 2011, 1:51:07 PM6/5/11
to web...@googlegroups.com
2011/6/5 Alessandro Iob <alessan...@gmail.com>

Hi Pierre,

this is the output of the code from the web2py application shell:

web2py Shell Version 1.96.2 (2011-06-03 16:11:39)
In [1] : from selfgroup.castalia import config

Traceback (most recent call last):
  File "gluon/contrib/shell.py", line 233, in run
  File "<string>", line 1, in <module>
  File "gluon/custom_import.py", line 280, in __call__
  File "gluon/custom_import.py", line 125, in __call__
ImportError: No module named selfgroup.castalia

In [2] : import os
In [3] : print os.stat("C:\web2py\\applications\Castalia\modules\selfgroup\castalia\__init__.py").st_mtime

1304593994.0
.

Thank you very much,
Alessandro

That seems OK. I don't know. My power is very limited here because I don't have a Windows machine. I guess someone else will have to debug it. In that case, I'll be happy to assist.  What else can I say??

Alessandro Iob

unread,
Jun 5, 2011, 4:43:12 PM6/5/11
to web...@googlegroups.com
If I'll find some free time I'll have a look at the code.

Thank you very much for the help!

On 5/6/11 19:51 , Pierre Thibault wrote:
> 2011/6/5 Alessandro Iob <alessan...@gmail.com
> <mailto:alessan...@gmail.com>>

> <http://pierrethibault.posterous.com>
> YouTube page (http://www.youtube.com/user/tubetib)
> <http://www.youtube.com/user/tubetib>
> Twitter (http://twitter.com/pierreth2) <http://twitter.com/pierreth2>
>

Massimo Di Pierro

unread,
Jun 5, 2011, 9:08:29 PM6/5/11
to web2py-users
If this s the problem, I have a possible fix in trunk.Please give it a
try. Yet I am not convinced this is the problem.

On Jun 4, 5:20 pm, Pierre Thibault <pierre.thibau...@gmail.com> wrote:
> 2011/6/3 Alessandro Iob <alessandro....@gmail.com>
>
>
>
>
>
>
>
>
>
> > I have tried the new modules import feature (from mymodule import *, looks
> > for mymodule in applications/thisapp/ modules first and then in sys.path. No
> > more need for local_import) and it works wonderfully on OS/X but not at all
> > on Windows. Below you can find the traceback.
>
> > web2py™Version 1.96.2 (2011-06-03 16:11:39)PythonPython 2.5.4:
> > C:\web2py\web2py.exe
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 184, in restricted
> >   File "C:/web2py/applications/castalia/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/castalia/controllers/default.py>, line 2, in <module>
> >   File "gluon/custom_import.py", line 280, in __call__
> >   File "gluon/custom_import.py", line 125, in __call__
> > ImportError: No module named selfgroup.castalia
>
> > Any suggestion?
>
> > Thank you
>
> Hello Alessandro,
>
> I wrote this code but I don't have Windows to do testing. I suspect it is a
> problem related to os.stat.
>
> Can you run this code on your machine and gave me the result?
>
> import os
> print os.stat("*path to the module you want to import*").st_mtime
> --
>
> A+
>
> -------------
> Pierre
> My blog and profile
> (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com>

Alessandro Iob

unread,
Jun 6, 2011, 3:46:53 AM6/6/11
to web...@googlegroups.com
No, it does not work. And the problem is not related to the _DateTrackerImporter as I'm not using the track_changes options.

I've made some tests and I've found that in _Web2pyImporter.__call__ the code reaches the "import like 'from x import a, b, ...'" section with the vars set to:

name = selfgroup.castalia 
caller_file_name = C:\w2p\web2py\applications\castalia\controllers/default.py 
self.web2py_path = C:\w2p\web2py 
match_app_dir = <_sre.SRE_Match object at 0x018B7420> 
modules_prefix = applications.castalia.modules
module_prefix + '.' + name = applications.castalia.modules.selfgroup.castalia 
fromlist = ('config',) 
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py', 'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.

Pierre Thibault

unread,
Jun 6, 2011, 9:42:34 AM6/6/11
to web...@googlegroups.com
2011/6/6 Alessandro Iob <alessan...@gmail.com>

No, it does not work. And the problem is not related to the _DateTrackerImporter as I'm not using the track_changes options.

I've made some tests and I've found that in _Web2pyImporter.__call__ the code reaches the "import like 'from x import a, b, ...'" section with the vars set to:

name = selfgroup.castalia 
caller_file_name = C:\w2p\web2py\applications\castalia\controllers/default.py 
self.web2py_path = C:\w2p\web2py 
match_app_dir = <_sre.SRE_Match object at 0x018B7420> 
modules_prefix = applications.castalia.modules
module_prefix + '.' + name = applications.castalia.modules.selfgroup.castalia 
fromlist = ('config',) 
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py', 'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.

There is something weird here. You said that:


module_prefix + '.' + name = applications.castalia.modules.selfgroup.castalia

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)


But the error is:

raises the ImportError exception (No module named castalia.modules.selfgroup.castalia).

I would expect "No module named applications.castalia.modules.selfgroup.castalia".

Why is "applicaitons" missing?

--

Alessandro Iob

unread,
Jun 6, 2011, 10:02:18 AM6/6/11
to web...@googlegroups.com
I really do not know why, but that's the error. A mistery for me.

On 6/6/11 15:42 , Pierre Thibault wrote:
> 2011/6/6 Alessandro Iob <alessan...@gmail.com
> <mailto:alessan...@gmail.com>>


>
> No, it does not work. And the problem is not related to the

> *_DateTrackerImporter as I'm not using the track_changes options.*
>
> **I've made some tests and I've found that in

> *applications*.castalia.modules.selfgroup.castalia".


>
> Why is "applicaitons" missing?
>
> --
>
>
> A+
>
> -------------
> Pierre
> My blog and profile (http://pierrethibault.posterous.com)

Pierre Thibault

unread,
Jun 6, 2011, 10:05:43 AM6/6/11
to web...@googlegroups.com
2011/6/6 Alessandro Iob <alessan...@gmail.com>

I really do not know why, but that's the error. A mistery for me.



Can you trace the super call?
 

Massimo Di Pierro

unread,
Jun 6, 2011, 10:23:11 AM6/6/11
to web2py-users
I do not understand this line:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

does not look like a valid Python statement to me.

On Jun 6, 9:05 am, Pierre Thibault <pierre.thibau...@gmail.com> wrote:
> 2011/6/6 Alessandro Iob <alessandro....@gmail.com>
>
> > I really do not know why, but that's the error. A mistery for me.
>
> Can you trace the super call?
>
>
>
>
>
>
>
>
>
> > On 6/6/11 15:42 , Pierre Thibault wrote:
>
> >> 2011/6/6 Alessandro Iob <alessandro....@gmail.com
> >> <mailto:alessandro....@gmail.com>>
> (http://pierrethibault.posterous.com)<http://pierrethibault.posterous.com>

Alessandro Iob

unread,
Jun 6, 2011, 10:33:52 AM6/6/11
to web...@googlegroups.com
"applications.castalia.modules.selfgroup.castalia" is just the value you
get from "module_prefix + '.' + name", that's the value passed to the
__import__ call.

Pierre Thibault

unread,
Jun 6, 2011, 10:34:30 AM6/6/11
to web...@googlegroups.com
2011/6/6 Massimo Di Pierro <massimo....@gmail.com>
I do not understand this line:

module_prefix + '.' + name =
applications.castalia.modules.selfgroup.castalia

does not look like a valid Python statement to me.
--

I interpreted this as the value of the expression module_prefix + '.' + name is "applications.castalia.modules.selfgroup.castalia". I think this what Alessandro wanted to express.

Alessandro Iob

unread,
Jun 6, 2011, 10:34:37 AM6/6/11
to web...@googlegroups.com
I'll try, but the super is really just the standard __import__ method.

On 6/6/11 16:05 , Pierre Thibault wrote:
> 2011/6/6 Alessandro Iob <alessan...@gmail.com
> <mailto:alessan...@gmail.com>>
>
> I really do not know why, but that's the error. A mistery for me.
>
>
>
> Can you trace the super call?
>
> On 6/6/11 15:42 , Pierre Thibault wrote:
>
> 2011/6/6 Alessandro Iob <alessan...@gmail.com
> <mailto:alessan...@gmail.com>

> <mailto:alessan...@gmail.com <mailto:alessan...@gmail.com>>>

Pierre Thibault

unread,
Jun 6, 2011, 10:37:03 AM6/6/11
to web...@googlegroups.com
2011/6/6 Alessandro Iob <alessan...@gmail.com>

I'll try, but the super is really just the standard __import__ method.



What is the value of name there?

Alessandro Iob

unread,
Jun 6, 2011, 10:47:16 AM6/6/11
to web...@googlegroups.com
the name arg passed to _PYTHON_STANDARD_IMPORTER has value
"applications.castalia.modules.selfgroup.castalia".

On 6/6/11 16:37 , Pierre Thibault wrote:
> 2011/6/6 Alessandro Iob <alessan...@gmail.com

> <mailto:alessan...@gmail.com>>


>
> I'll try, but the super is really just the standard __import__ method.
>
>
>
> What is the value of name there?
> --
>
>
> A+
>
> -------------
> Pierre
> My blog and profile (http://pierrethibault.posterous.com)

Pierre Thibault

unread,
Jun 6, 2011, 11:06:00 AM6/6/11
to web...@googlegroups.com
2011/6/6 Alessandro Iob <alessan...@gmail.com>

the name arg passed to _PYTHON_STANDARD_IMPORTER has value
"applications.castalia.modules.selfgroup.castalia".


OK. If you open a Python console, what does give you:

import sys

sys.path.append("C:\w2p\web2py")

import applications.castalia.modules.selfgroup.castalia

?
 

Alessandro Iob

unread,
Jun 6, 2011, 11:22:15 AM6/6/11
to web...@googlegroups.com
I've tested it with a python 2.6 interpreter. It returns the same error
as in web2py.

I've also created a simple module under applications/castalia/modules
but I can not import it too.

Alessandro Iob

unread,
Jun 6, 2011, 11:37:39 AM6/6/11
to web...@googlegroups.com
Found something: the application folder is named 'Castalia' with the
first char in uppercase, while the importer tries to import it as
'applications.castalia....', in lowercase.

I've tried from the python shell to import using
applications.Castalia..... and it worked.

On 6/6/11 17:06 , Pierre Thibault wrote:

Pierre Thibault

unread,
Jun 6, 2011, 11:44:03 AM6/6/11
to web...@googlegroups.com
2011/6/6 Alessandro Iob <alessan...@gmail.com>

Found something: the application folder is named 'Castalia' with the first char in uppercase, while the importer tries to import it as 'applications.castalia....', in lowercase.

I've tried from the python shell to import using applications.Castalia..... and it worked.

Problem solved?

Alessandro Iob

unread,
Jun 6, 2011, 11:54:07 AM6/6/11
to web...@googlegroups.com
No, because the web2py code (under Windows only) keeps trying to import
it in lowercase. I can just rename the application (and it works that
way), but I think this is just a workaround and not a solution to a
problem that should not exist.

On 6/6/11 17:44 , Pierre Thibault wrote:
> 2011/6/6 Alessandro Iob <alessan...@gmail.com

> <mailto:alessan...@gmail.com>>


>
> Found something: the application folder is named 'Castalia' with the
> first char in uppercase, while the importer tries to import it as
> 'applications.castalia....', in lowercase.
>
> I've tried from the python shell to import using
> applications.Castalia..... and it worked.
>
>
> Problem solved?
>
>
> --
>
>
> A+
>
> -------------
> Pierre
> My blog and profile (http://pierrethibault.posterous.com)

Pierre Thibault

unread,
Jun 6, 2011, 3:35:22 PM6/6/11
to web...@googlegroups.com
2011/6/6 Alessandro Iob <alessan...@gmail.com>

No, it does not work. And the problem is not related to the _DateTrackerImporter as I'm not using the track_changes options.

I've made some tests and I've found that in _Web2pyImporter.__call__ the code reaches the "import like 'from x import a, b, ...'" section with the vars set to:

name = selfgroup.castalia 
caller_file_name = C:\w2p\web2py\applications\castalia\controllers/default.py 
self.web2py_path = C:\w2p\web2py 
match_app_dir = <_sre.SRE_Match object at 0x018B7420> 
modules_prefix = applications.castalia.modules
module_prefix + '.' + name = applications.castalia.modules.selfgroup.castalia 
fromlist = ('config',) 
level = -1

then the call to

super(_Web2pyImporter, self).__call__(
modules_prefix+"."+name, globals, locals, fromlist, level
)

raises the ImportError exception (No module named castalia.modules.selfgroup.castalia).
The sys.path seems correct:

['', 'C:\\w2p\\web2py\\site-packages', 'C:\\w2p\\web2py', 'C:\\w2p\\web2py\\gluon', 'C:\\w2p\\web2py\\library.zip']

No clue.



When you are using "Castalia" as the name of your application, is all code values above appears with "castalia" in lower case?

Alessandro Iob

unread,
Jun 6, 2011, 3:43:37 PM6/6/11
to web...@googlegroups.com
Yes

On 6/6/11 21:35 , Pierre Thibault wrote:
> 2011/6/6 Alessandro Iob <alessan...@gmail.com

> <mailto:alessan...@gmail.com>>


>
> No, it does not work. And the problem is not related to the

> *_DateTrackerImporter as I'm not using the track_changes options.*
>
> **I've made some tests and I've found that in

Alessandro Iob

unread,
Jun 7, 2011, 10:43:14 AM6/7/11
to web...@googlegroups.com
I have fixed the problem adding the following code in one of my models:

import os
os.environ['PYTHONCASEOK'] = '1'

It makes ignore path case on operating systems with case-insensitive
file-systems (namely Win32 and OS/X with the default fs).

Do you think it should be added, with a proper os test, to the importer
code?

On 6/6/11 21:35 , Pierre Thibault wrote:
> 2011/6/6 Alessandro Iob <alessan...@gmail.com

> <mailto:alessan...@gmail.com>>


>
> No, it does not work. And the problem is not related to the

> *_DateTrackerImporter as I'm not using the track_changes options.*
>
> **I've made some tests and I've found that in

Pierre Thibault

unread,
Jun 7, 2011, 10:57:37 AM6/7/11
to web...@googlegroups.com
2011/6/7 Alessandro Iob <alessan...@gmail.com>

I have fixed the problem adding the following code in one of my models:

import os
os.environ['PYTHONCASEOK'] = '1'

It makes ignore path case on operating systems with case-insensitive file-systems (namely Win32 and OS/X with the default fs).

Do you think it should be added, with a proper os test, to the importer code?



No. Now that we know the problem, or that we have enough information to easily locate the lines of code in problem, we can fix these lines. We need someone who can do it on Windows.

I don't like the idea of global change of the Python environment. A local fix is far better solution and it should not very difficult to do in this case.

Thank you for your collaboration.
Reply all
Reply to author
Forward
0 new messages