[web2py] Re: admin interface + GAE

2012-11-24 Thread dlypka
Yes, not a bug but these are issues which come up when messing with the 
admin interface on GAE.
NOTE that the issues occur when running locally using the GAE SDK as well.

So I assume the correct approach is to run it once as a normal web2py app 
i.e. python web2py.py to get those special files
to write out.  Then subsequent dev_appserver.py runs should work...

On Monday, November 19, 2012 11:15:58 PM UTC-6, dlypka wrote:
>
> I had to work around this problem in tools.py in my web2py 1.9x code.
> Maybe this issue is still in 2.x
>
> @staticmethod
>
> def get_or_create_key(filename=None):
>
> request = current.request
>
> if not filename:
>
> filename = os.path.join(request.folder,'private','auth.key')
>
> if os.path.exists(filename):
>
> key = open(filename,'r').read().strip()
>
> else:
>
> key = web2py_uuid()
>
> *#* open(filename,'w').write(key) *# dlypka workaround - this crashes on 
> GAE, not allowing to write to a file!!*
>
> return key
>
> --
>
> Also a similar issue here: in In admin\controllers\default.py
>
> #Get crontab
>
> cronfolder = apath('%s/cron' % app, r=request)
>
> if not os.path.exists(cronfolder): os.mkdir(cronfolder)
>
> crontab = apath('%s/cron/crontab' % app, r=request)
>
> #if not os.path.exists(crontab): # dlypka patch for GAE - safe_write() 
> fails on gae
>
> #safe_write(crontab, '#crontab')
>
>
> On Monday, November 19, 2012 9:22:36 PM UTC-6, Massimo Di Pierro wrote:
>>
>> Please open a ticken about this. I will be able to look at it later 
>> tomorrow.
>>
>> On Monday, 19 November 2012 10:57:27 UTC-6, Sebastian Cambeo wrote:
>>>
>>> might it be, that "users.create_login_url(request.env.path_info)" in 
>>> "check_credentials" needs some kind of file access?
>>>
>>> Anyhow this request appears to trigger the error
>>>
>>

-- 





[web2py] Re: admin interface + GAE

2012-11-21 Thread Massimo Di Pierro
You are right. This is a different problem. Please open a ticket about it, 
if not done already and I will check later today or tomorrow.

On Wednesday, 21 November 2012 11:08:55 UTC-6, Sebastian Cambeo wrote:
>
> I don't know if we understand us correctly. I don't use get_or_create_key 
> anywhere and I am not referring to dlypka posts (I think our problems are 
> not related).
>
> However my problem remains existing: If you deploy web2py trunk/stable 
> with no other changes than altering the app.yaml in order to use the admin 
> interface it fails due to forbidden calls in "check_credentials".
>
> Sebastian
>

-- 





[web2py] Re: admin interface + GAE

2012-11-21 Thread Sebastian Cambeo
I don't know if we understand us correctly. I don't use get_or_create_key 
anywhere and I am not referring to dlypka posts (I think our problems are 
not related).

However my problem remains existing: If you deploy web2py trunk/stable with 
no other changes than altering the app.yaml in order to use the admin 
interface it fails due to forbidden calls in "check_credentials".

Sebastian

-- 





[web2py] Re: admin interface + GAE

2012-11-21 Thread Massimo Di Pierro
This is not a bug!

1) First of all, for new apps, do not use get_or_create_key any more. The 
new web2py had better security using salted password. You do not need a key.

2) If you must use a key (because you have a legacy app or because you want 
to use hmac) the key must be saved on a file. You should save it on the 
host (by running the app locally once) and then deploy on GAE. 

Massimo


On Tuesday, 20 November 2012 03:28:23 UTC-6, Sebastian Cambeo wrote:
>
> http://code.google.com/p/web2py/issues/detail?id=1177
>

-- 





[web2py] Re: admin interface + GAE

2012-11-20 Thread Sebastian Cambeo
http://code.google.com/p/web2py/issues/detail?id=1177

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread dlypka
I had to work around this problem in tools.py in my web2py 1.9x code.
Maybe this issue is still in 2.x

@staticmethod

def get_or_create_key(filename=None):

request = current.request

if not filename:

filename = os.path.join(request.folder,'private','auth.key')

if os.path.exists(filename):

key = open(filename,'r').read().strip()

else:

key = web2py_uuid()

*#* open(filename,'w').write(key) *# dlypka workaround - this crashes on 
GAE, not allowing to write to a file!!*

return key

--

Also a similar issue here: in In admin\controllers\default.py

#Get crontab

cronfolder = apath('%s/cron' % app, r=request)

if not os.path.exists(cronfolder): os.mkdir(cronfolder)

crontab = apath('%s/cron/crontab' % app, r=request)

#if not os.path.exists(crontab): # dlypka patch for GAE - safe_write() 
fails on gae

#safe_write(crontab, '#crontab')


On Monday, November 19, 2012 9:22:36 PM UTC-6, Massimo Di Pierro wrote:
>
> Please open a ticken about this. I will be able to look at it later 
> tomorrow.
>
> On Monday, 19 November 2012 10:57:27 UTC-6, Sebastian Cambeo wrote:
>>
>> might it be, that "users.create_login_url(request.env.path_info)" in 
>> "check_credentials" needs some kind of file access?
>>
>> Anyhow this request appears to trigger the error
>>
>

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Massimo Di Pierro
Please open a ticken about this. I will be able to look at it later 
tomorrow.

On Monday, 19 November 2012 10:57:27 UTC-6, Sebastian Cambeo wrote:
>
> might it be, that "users.create_login_url(request.env.path_info)" in 
> "check_credentials" needs some kind of file access?
>
> Anyhow this request appears to trigger the error
>

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Sebastian Cambeo
might it be, that "users.create_login_url(request.env.path_info)" in 
"check_credentials" needs some kind of file access?

Anyhow this request appears to trigger the error

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Massimo Di Pierro
Strange. this is a gae error.

On Monday, 19 November 2012 03:16:46 UTC-6, Sebastian Cambeo wrote:
>
> What comes as a surprise to me is that the admin interface is working in 
> the GAE SDK emulation...
>
> The error log:
>
> In FILE: 
> /base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py
>
> Traceback (most recent call last):
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/restricted.py",
>  line 212, in restricted
> exec ccode in environment
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py",
>  line 37, in 
> if gluon.fileutils.check_credentials(request):
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/fileutils.py",
>  line 345, in check_credentials
> % users.create_login_url(request.env.path_info)
>   File 
> "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/users.py",
>  line 256, in create_login_url
> raise NotAllowedError
> NotAllowedError
>
>

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Sebastian Cambeo
What comes as a surprise to me is that the admin interface is working in 
the GAE SDK emulation...

The error log:

In FILE: 
/base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/restricted.py", 
line 212, in restricted
exec ccode in environment
  File 
"/base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py",
 line 37, in 
if gluon.fileutils.check_credentials(request):
  File 
"/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/fileutils.py", 
line 345, in check_credentials
% users.create_login_url(request.env.path_info)
  File 
"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/users.py", 
line 256, in create_login_url
raise NotAllowedError
NotAllowedError

-- 





[web2py] Re: admin interface + GAE

2012-11-18 Thread Massimo Di Pierro
Can you show use a traceback from the GAE logs. Admin is readonly on GAE.

On Sunday, 18 November 2012 12:53:49 UTC-6, Sebastian Cambeo wrote:
>
> Is it possible to use the admin interface on GAE? I get internal errors 
> although I changed the app.yaml accordingly
>
> Thank You!
>
> Sebastian
>

--