Repository: web2py/web2py

Issue:
Getting error editing files through web when running Web2Py from source
Steps to reproduce error:

Install a fresh version of Mint 17.3 64-bit (Single, large ext4 '/', and a small swap partition)
Install git

```
$ sudo apt-get install git
```

Clone repo

```
$ git clone --recursive https://github.com/web2py/web2py.git
(Web2Py Commit cbd8c63b, Dal Commit 60e97e7c)
```

Run Web2Py

```
$ python web2py.py
Set password
```

Login

```
Firefox: 127.0.0.1:8000
My Sites --> Enter Password
```

Try to edit a file

```
My Sites --> Examples (Edit) --> Edit button of default.py (Under Controllers)
```

Result: A popup that says "An error occured, please reload the page"

![web2py - mint 17 3 64-bit-2016-05-25-09-21-00](https://cloud.githubusercontent.com/assets/3195851/15545992/6ed401e2-225b-11e6-97fc-50a34a6dabda.png)

Viewing source code through the web interface works fine for any file. Editing doesn't work on any file (not just default.py).

I also tried this on Mint 17.1 64-bit, and Fedora 23, as well as the chromium browser - all give the same results.

PS. Apparently this is issue 1337 :)



Discussion:
Have you take a looks at the admin app errors?

One of the first thing to do is make sure permissions are properly setted
up (as I am not sure you are running in "prod" like environment or not).

In prod you need to make sure www-data is the owner of all the files...

Richard

On Wed, May 25, 2016 at 11:42 AM, terminator14 notifications@github.com
wrote:

> Steps to reproduce error:
> 
> Install a fresh version of Mint 17.3 64-bit (Single, large ext4 '/', and a
> small swap partition)
> Install git
> 
> $ sudo apt-get install git
> 
> Clone repo
> 
> $ git clone --recursive https://github.com/web2py/web2py.git
> (Web2Py https://github.com/web2py/web2py.git(Web2Py Commit cbd8c63b, Dal Commit 60e97e7c)
> 
> Run Web2Py
> 
> $ python web2py.py
> Set password
> 
> Login
> 
> Firefox: 127.0.0.1:8000
> My Sites --> Enter Password
> 
> Try to edit a file
> 
> My Sites --> Examples (Edit) --> Edit button of default.py (Under Controllers)
> 
> Result: A popup that says "An error occured, please reload the page"
> 
> [image: web2py - mint 17 3 64-bit-2016-05-25-09-21-00]
> https://cloud.githubusercontent.com/assets/3195851/15545992/6ed401e2-225b-11e6-97fc-50a34a6dabda.png
> 
> Viewing source code through the web interface works fine for any file.
> Editing doesn't work on any file (not just default.py).
> 
> I also tried this on Mint 17.1 64-bit, and Fedora 23, as well as the
> chromium browser - all give the same results.
> 
> PS. Apparently this is issue 1337 :)
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly or view it on GitHub
> https://github.com/web2py/web2py/issues/1337

All files and folders in the web2py folder (my git repo root folder) are owned by the same user that I am running the web2py web server with. Changing everything over to be owned by www-data wouldn't let me run it as that user anymore (as expected, I got permission error), so I tried running the web2py web server as root with `sudo python web2py.py`, which ran fine, but I still get issues trying to edit files in the web interface. Whatever the issue is, it doesn't appear to be related to unix permissions.

I also tried opening the "error logs" web page for the app that I was trying to edit files on, but that showed nothing - 0 errors. Any other place I can search for errors?

I experiment sometimes issue with authentication in admin app... I use to
clear navitagor cache and authentication token (cookies) and it helps fix
the issue... There had also issue with authentication in admin app in the
past... Another thing you can do is to make sure you download the last
tagged version which is 2.14.6 as the trunk as you appear to had download
may contain bugs that we are not aware of...

You may consider downloading web2py form the web2py web site instead of
using git repo depending if your intentions is not to develop web2py I
think it the recommanded way...

Richard

On Thu, May 26, 2016 at 3:10 PM, terminator14 notifications@github.com
wrote:

> All files and folders in the web2py folder (the git repo root folder) are
> owned by the same user that I am running the web2py web server with.
> Changing everything over to be owned by www-data wouldn't let me run it as
> that user anymore (as expected, I got permission error), so I tried running
> the web2py web server as root with sudo python web2py.py, which ran fine,
> but I still get issues trying to edit files in the web interface. Whatever
> the issue is, it doesn't appear to be related to unix permissions.
> 
> I also tried opening the "error logs" web page for the app that I was
> trying to edit files on, but that showed nothing - 0 errors. Any other
> place I can search for errors?
> 
> —
> You are receiving this because you commented.
> Reply to this email directly or view it on GitHub
> https://github.com/web2py/web2py/issues/1337#issuecomment-221965749

I tried clearing all firefox cache and cookies - didn't help.
Checking out tag R-2.14.6, the problem is gone - I can edit files in the web interface without a problem.
I have confirmed this on 2 different computers.
Looks like a regression.
I have no problem using R-2.14.6, but you guys might want to look into what broke in the last few commits - the ones that came after R-2.14.6.
You want me to keep this issue open?

Terminator14,

I think we are aware of the situation as they actually try to integrate the
"new" pyDAL that get under big refactoring since a couples of months, so I
guess you just experiment some of the remaining issue that may be present
because of that.

Regards

Richard

On Thu, May 26, 2016 at 3:30 PM, terminator14 notifications@github.com
wrote:

> I tried clearing all firefox cache and cookies - didn't help.
> Checking out tag R-2.14.6, the problem is gone - I can edit files in the
> web interface without a problem.
> I have confirmed this on 2 different computers.
> Looks like a regression.
> I have no problem using R-2.14.6, but you guys might want to look into
> what broke in the last few commits - the ones that came after R-2.14.6.
> You want me to keep this issue open?
> 
> —
> You are receiving this because you commented.
> Reply to this email directly or view it on GitHub
> https://github.com/web2py/web2py/issues/1337#issuecomment-221970492

Ok cool.
Can I close the issue, or do you want it open as a reminder that this needs to be looked at?

I don't feel we have all what is required to reproduce the issue... If you
can pull out more data from your experimentation like the last commit tag
of the build you had tried and experiment the issue with...

On Thu, May 26, 2016 at 3:37 PM, terminator14 notifications@github.com
wrote:

> Ok cool.
> Can I close the issue, or do you want it open as a reminder that this
> needs to be looked at?
> 
> —
> You are receiving this because you commented.
> Reply to this email directly or view it on GitHub
> https://github.com/web2py/web2py/issues/1337#issuecomment-221972314

Commit 5246d80 works, but the next commit (be1845a Merge pull request #1327 from leonelcamara/ditch26) does not.

Not sure if it's helpful, but it looks like these were the files that were touched between those 2 commits:

```
.travis.yml
LICENSE
applications/admin/LICENSE
applications/admin/controllers/wizard.py
applications/examples/controllers/simple_examples.py
applications/examples/views/default/examples.html
applications/examples/views/default/who.html
gluon/cache.py
gluon/contrib/appconfig.py
gluon/contrib/autolinks.py
gluon/contrib/login_methods/browserid_account.py
gluon/contrib/login_methods/dropbox_account.py
gluon/contrib/login_methods/janrain_account.py
gluon/contrib/login_methods/loginradius_account.py
gluon/contrib/login_methods/loginza.py
gluon/contrib/login_methods/oneall_account.py
gluon/contrib/login_methods/rpx_account.py
gluon/contrib/ordereddict.py
gluon/contrib/redis_scheduler.py
gluon/contrib/simplejson.py
gluon/contrib/simplejson/LICENSE.txt
gluon/contrib/simplejson/__init__.py
gluon/contrib/simplejson/decoder.py
gluon/contrib/simplejson/encoder.py
gluon/contrib/simplejson/ordered_dict.py
gluon/contrib/simplejson/scanner.py
gluon/contrib/simplejson/tool.py
gluon/contrib/simplejsonrpc.py
gluon/contrib/spreadsheet.py
gluon/contrib/stripe.py
gluon/globals.py
gluon/main.py
gluon/scheduler.py
gluon/serializers.py
gluon/tests/test_appadmin.py
gluon/tools.py
gluon/validators.py
setup.py
tox.ini
```

All I did was `git diff --name-only 5246d80 be1845a` - I'm not sure if that shows what changed in the dal sub-module, or if it even matters if something changed there.

If there's anything else I can provide that would be helpful, let me know, but I'm fairly certain the problem should be reproducible, as I've tried the latest commit on different distros, and different browsers, and they all have the same problem.

I have the same problem here. 

In the admin app errors:

> Count 5
> File default.py
> Error TypeError: 'module' object is not callable
> 
> Details:
> 
> Tiquete de Erro for "admin"
> Número do Ticket
> 10.13.1.151.2016-06-03.09-43-25.5af1e9ea-54e3-4923-841a-ed93654802b3
> 
> <type 'exceptions.TypeError'> 'module' object is not callable
> 
> Versão
> web2py™ Version 2.14.6-stable+timestamp.2016.05.09.19.18.48
> Python    Python 2.7.5: /usr/bin/uwsgi (prefix: /usr)
> Traceback
> 1. Traceback (most recent call last):
> 2.   File "/opt/web2py/gluon/restricted.py", line 227, in restricted
> 3.     exec ccode in environment
> 4.   File "/opt/web2py/applications/admin/controllers/default.py", line 2000, in <module>
> 5.   File "/opt/web2py/gluon/globals.py", line 411, in <lambda>
> 6.     self._caller = lambda f: f()
> 7.   File "/opt/web2py/applications/admin/controllers/default.py", line 833, in edit
> 8.     return response.json(file_details)
> 9.   File "/opt/web2py/gluon/globals.py", line 655, in json
> 10.     return json(data, default=default or custom_json)
> 11. TypeError: 'module' object is not callable
> 12. 

Hi , i am having the same issue , when checking out /clone from git 

We know. Wait a few days, the fix is coming
Il 11 giu 2016 8:35 AM, "kalmen chia" notifications@github.com ha scritto:

> Hi , i am having the same issue , when checking out /clone from git
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> https://github.com/web2py/web2py/issues/1337#issuecomment-225340329, or mute
> the thread
> https://github.com/notifications/unsubscribe/AAHdB5ghQSpcSEGXixANsCRedE4pt0G3ks5qKldEgaJpZM4Imq0E
> .


Resolving patch:
diff --git a/gluon/contrib/shell.py b/gluon/contrib/shell.py
--- a/gluon/contrib/shell.py
+++ b/gluon/contrib/shell.py
@@ -48,7 +48,7 @@
 UNPICKLABLE_TYPES = [
     types.ModuleType,
     type,
-    ClassType
+    ClassType,
     types.FunctionType,
 ]
 
diff --git a/gluon/globals.py b/gluon/globals.py
--- a/gluon/globals.py
+++ b/gluon/globals.py
@@ -40,7 +40,7 @@
 import cgi
 import copy
 import tempfile
-import json
+import json as json_parser
 
 
 FMT = '%a, %d-%b-%Y %H:%M:%S PST'
@@ -215,7 +215,7 @@ def parse_post_vars(self):
 
         if is_json:
             try:
-                json_vars = json.load(body)
+                json_vars = json_parser.load(body)
             except:
                 # incoherent request bodies can still be parsed "ad-hoc"
                 json_vars = {}


Test patch: