Forums

Updating web2py

Hi guys, I just noticed that web2py just released version 2.6.1. When do you think you'll update the automatic website-create tool to the latest version?

Also, side note: I tried updating the web2py version myself in the "admin" interface (the button on the right side), and my site's admin doesn't work anymore. I tried copying the files listed below:

Attention all users: For pre 2.6 applications to work with web2py >=2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and views/appadmin.html from the welcome app to your own apps (all of them).

But that didn't help. My site still works, but the administrative interface does not! I guess I'll downgrade and let the professionals do the upgrading.

Hmm, following those instructions should work. Did you restart the web app after copying the files?

So just to see if the problem was with the installer or with my apps, I started a completely fresh web2py installation for mattspence.pythonanywhere.com.

I let it install, then I went to the admin interface and clicked "upgrade to 2.6.1". It started downloading, but then it gave me "Internal error. Ticket issued. admin/..." error page. I can navigate to the website ok, but I can't load the administrative interface.

And I'm pretty sure this isn't my apps, since this is just the standard install with welcome, examples and admin!

Thanks giles.

edit: I also tried restarting the website in the Web tab. No luck.

OK, I'll take a look -- it might take a while, though -- Friday evening here, but I'm on the support rota for this weekend so I'll give it a go tomorrow and try to work out what's up.

No rush!

Just a quick update (still no rush), I wrote to the web2py google group, and Massimo said that he had left out an admin file in 2.6.1. So he's updated it to 2.6.2. That might solve it.

Ah, that would explain it!

Afraid that didn't solve it : ( I tried a fresh install, then upgrading to 2.6.2, and it gave me a similar error. I pasted the error message here: http://pastebin.com/uABGmGgV

But again, this can wait until next week.

OK -- I'll take a look tomorrow.

Gosh, that's an error message and a half!

I see that there's been some discussion on the web2py list, and Massimo suggested you (or someone with a suspiciously similar name) reload the web app -- did you reload it this second time as well?

Hey, yes, that was me. I'm still getting the error even after reloading all of my domains multiple times. Try it out: https://mattspence.pythonanywhere.com/admin/

Not sure why it doesn't work for me on a fresh install but seems to work for Massimo and others!

Massimo says

You can see in /home/mattspence/web2py/applications/admin/controllers/default.py line
from gluon.tools import Config
Now check if gluon/tools.py contains class Config. I know it is there in 2.6.1 and 2.6.2.

I checked out /home/mattspence/web2py/gluon/tools.py and there actually is no class Config! Not sure why that could be.

edit: I just tried using the command line to update web2py

wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip

reloaded my site, and everything works perfectly. So something is going wrong in the updating when using the GUI button in the admin interface so that the gluon/tools.py isn't updating to the latest version (among other files, possibly).

Anyway...problem solved.

Glad to hear it's solved! We're talking to Massimo about this and we'll see if there's a way of making this process a bit easier for everyone next time.

Is there anything else I need to do? When I remove the old web2py folder and replace it the way (wget) you wrote I get an error.

What's the error? That process should work just fine.

So, if you're updating web2py and you have old applications, I would recommend doing the following in bash. Imagine your application name is FRISBEE:

mv web2py web2py_backup
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cp -avr web2py_backup/applications/FRISBEE web2py/applications
cp web2py/applications/welcome/static/js/web2py.js web2py/applications/FRISBEE/static/js/web2py.js
cp web2py/applications/welcome/controllers/appadmin.py web2py/applications/FRISBEE/controllers/appadmin.py 
cp web2py/applications/welcome/views/appadmin.html web2py/applications/FRISBEE/views/appadmin.html

cp -avr will copy recursively, try to preserve attributes, and show which files are moved (and where). Do steps 4-7 for each application you have.

Hi all-

I've updated the instructions somewhat to carry over routes.py and re-set your password (which isn't carried over). (If you haven't set routes.py, you can delete the line)

rm web2py_src.zip
rm -r web2py_backup
mv web2py web2py_backup
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cp -avr web2py_backup/applications/FRISBEE web2py/applications
cp -av web2py_backup/routes.py web2py 
cd web2py
python -c "from gluon.widget import console; console();"
python -c "import hashlib; print 'password=\"%s\"' % (hashlib.md5('MYADMINPASSWORD').hexdigest(),)" > parameters_443.py

Do line 6 for each of your applications (replacing FRISBEE with the app name). Do line 7 only if you've created routes.py (which sets a default navigation for your page so it's not default/appname/index.html). Change the last line to your actual admin password instead of MYADMINPASSWORD.

IF you're updating from a version of web2py before 2.6 (i.e., 2.5.2 or before), then you need to do these steps as well for each application (replace FRISBEE with your app name):

cp web2py/applications/welcome/static/js/web2py.js web2py/applications/FRISBEE/static/js/web2py.js
cp web2py/applications/welcome/controllers/appadmin.py web2py/applications/FRISBEE/controllers/appadmin.py 
cp web2py/applications/welcome/views/appadmin.html web2py/applications/FRISBEE/views/appadmin.html

That should do it!

That's fantastic, thanks Matt!

Hi, I had the problem described before (after trying to upgrade web2py version), had an error, could not access admin interface), and I did all the bash commands described in the previous post.

Now it looks like everything is ok - web2py version is now upgraded to 2.7.4, but there is one problem. I cannot read (see the content) any of the files in the applications folder (even the welcome application), using web2py administrative interface. I can see the file, but when I try to view or edit the content of the file, I don't get any error, but the file seems to be empty. When I try to edit the same file file through pythonanywhere files section, i can see all the contents of the same file.

It seems to be some kind of problem with access rights for the files. Or am I just missing something?

Nope. If you can see and edit the files in the Files view, then you have correct permissions. Perhaps you could ask the web2py list about this.

Hi all-

This is an update to mattspence's post. After having some trouble to update the web2py folder containing all my apps, I decided to move my applications out of web2py folder.

For example, instead of having

|_web2py # containing web2py source files with default applications
   |_...  
   |_applications
      |_admin # Default web2py application
      |_welcome # Default web2py application
      |_app1 # Custom application 1
      |_app2 # Custom application 2
      |_...

I prefer :

|_web2py # containing web2py source files with default applications
   |_...  
   |_applications
      |_admin # Default web2py application
      |_welcome # Default web2py application


|_web2py_apps #folder containing all my custom apps
    |_app1 # Custom application 1
    |_app2 # Custom application 2
    |_...

This is possible by using symlinks : In web2py_apps folder, simply create a script containing these lines :

1
2
3
4
5
6
#!/usr/bin/bash
for D in *; do
    if [ -d "${D}" ]; then
                ln -s ./web2py_apps/"${D}" ../web2py/applications/"${D}" 
    fi
done

When you upgrade web2py, you can simply replace web2py folder with the new version (think to backup your routes.py file!) and recreate all symlinks by running the script in web2py_apps folder