In gluon/main.py somewhere around line 77 the variable web2py_path is
being set as follows:
web2py_path = os.environ.get('web2py_path', os.getcwd())
This variable is later used to read in the file VERSION. For simply
running web2py this works beautifully.
However I'm writing a small script that's supposed to prepopulated a
database with initial values. This script's location is:
/web2py/applications/my-app/prepopulate_db.py
This script does some magic to add /web2py to the sys.path so that I can
do:
from gluon.shell import exec_environment
from within it. However this fails with the error:
web2py_version = open(os.path.join(web2py_path, 'VERSION'),
'r').read()
IOError: [Errno 2] No such file or directory: '/web2py/
applications/my-app/VERSION'
The culprit is the os.getcwd() in web2py_path initialization. I am not
sure why os.getcwd() is used here. Unless there's an explicit reason for
it, could we consider changing it to?
web2py_path = os.environ.get('web2py_path',
os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
That would allow scripts that depend on exec_environment to be run from
anywhere instead of being forced to be run from /web2py.
--
Guido
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---