[web2py] Re: email_auth works on web2py server, but not GAE - ANSWER: No sockets in the sandbox, no smtp connections! That's all. No email_auth on GAE

2012-01-26 Thread Alan Etkin
Some built-in web2py functions have conditional commands for
addressing AppEngine compatibility issues, it seems that this is not
performed for the email authentication. Perhaps this problem could
added to the web2py issues list?

On 26 ene, 02:43, pattu  wrote:
> I didn't get much success in getting logging to work with the GAE -
> there is a slice for it, but it all is pretty complicated.
>
> BUT... I tried the following code in the interactive console on the
> dev engine:
>
> import smtplib
>
> host = 'gmail.com'
> port = 587
>
> server = smtplib.SMTP(host, port)
> server.help
>
> AND got a traceback:
>
> "/home/pattu/google_appengine/google/appengine/ext/admin/__init__.py",
> line 317, in post
>     exec(compiled_code, globals())
>   File "", line 7, in 
>   File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
>     (code, msg) = self.connect(host, port)
>   File "/usr/lib/python2.6/smtplib.py", line 295, in connect
>     self.sock = self._get_socket(host, port, self.timeout)
>   File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
>     return socket.create_connection((port, host), timeout)
> AttributeError: 'module' object has no attribute 'create_connection'
>
> Googling about sockets and google app engine lead you to the following
> informative threads:
>
> http://code.google.com/appengine/docs/python/runtime.html:
>
> The Sandbox
> ... (snip,snip) ...
> An App Engine application cannot:
> ... (snip,snip) ...
> open a socket or access another host directly. An application can use
> the App Engine URL fetch service to make HTTP and HTTPS requests to
> other hosts on ports 80 and 443, respectively.
>
> So SMTP auth on 587 will not work, you must use the GAE email
> interface as documented other places.
>
> Life goes on.  A bit of a shame for me, because for a little app,
> deployment on GAE seems like the easiest answer.   GAE is a special
> environment with special restrictions.
>
> Web2py really shines for the quick little app development... but
> decent lowend python shared hosting seems to be a bit hard to find at
> this time.  Several places I have wandered to imply the need to get
> Apache configured... not really a fun job for a quick little app.
>
> - pattu
>
> On Jan 24, 8:24 pm, Alan Etkin  wrote:
>
> > You could try printing this command's output to the console in
> > development:
>
> > ...
> > server.login(email, password)
> > ...
>
> > It is in line 29 of /gluon/contrib/
> > login_methods/email_auth.py
>
> > gluon/contrib/login_methods/email_auth.py
>
> > On 23 ene, 13:48,pattu wrote:
>
> > > Hi -
>
> > > Fairly silently.  In the case of running the dev_appserver.py -
> > > submitting a correct email and password to login form just shows a
> > > very quick response of invalid login (flash message).  Compared to
> > > running the web2py built in web server the response is too fast to let
> > > me believe that my computer talked to the smtp server I am validating
> > > against.. i.e. the request just failed as a failed login.  But I am
> > > testing against my organization's smtp and against the gmail smtp,
> > > which work fine with the web2py built in server.
>
> > > I am not an experienced python debugger, and my attempts to try and
> > > step through the smtplib code fail with the GAE - funny errors like
> > > non-ascii characters in the source files, which make me think that
> > > debugger I tried (winpdb) didn't like the GAE environment.
>
> > > The deployed application also shares the same problem.
>
> > > Somehow debugging whether GAE is letting a TLS request go through
> > > correctly seems puzzling.  I was fairly interested in using the GAE
> > > because it came with an easy https access option, (I don't mind the
> > > appspot subdomain).  I have a short term app that I wanted security
> > > for.  Googling I've seen some mentions that sockets are not
> > > implemented fully on GAE, but I don't know if that is currently the
> > > case.  I would be delighted to get an error message or exception - let
> > > me know how to turn that on if it exists in inside the smtplib, for
> > > example.
>
> > > There could be some silly mistake I am making - I have made a few
> > > hundred so far, but because the implementation in this case seems so
> > > simple, I think that GAE might be at fault.  Is there a workaround do
> > > you think?  In anycase this development process has really been fun -
> > > web2py is a nice environment to work in.
>
> > > On Jan 23, 7:21 pm, Massimo Di Pierro 
> > > wrote:
>
> > > > Did you try it? How does it fail?
>
> > > > On Jan 23, 4:07 am,pattu wrote:
>
> > > > > Hi -
>
> > > > > I have found 150 answers to different questions already by googling my
> > > > > way through this list, but I didn't find anything addressing
> > > > > email_auth (using an smtp server).  Here is code that works fine
> > > > > running the web2py server, but seems to fail both on the GAE
> > > > > development server and also deployed.  I might have missed something,
> >

[web2py] Re: email_auth works on web2py server, but not GAE - ANSWER: No sockets in the sandbox, no smtp connections! That's all. No email_auth on GAE

2012-01-25 Thread pattu
I didn't get much success in getting logging to work with the GAE -
there is a slice for it, but it all is pretty complicated.

BUT... I tried the following code in the interactive console on the
dev engine:

import smtplib


host = 'gmail.com'
port = 587

server = smtplib.SMTP(host, port)
server.help


AND got a traceback:

"/home/pattu/google_appengine/google/appengine/ext/admin/__init__.py",
line 317, in post
exec(compiled_code, globals())
  File "", line 7, in 
  File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "/usr/lib/python2.6/smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
AttributeError: 'module' object has no attribute 'create_connection'

Googling about sockets and google app engine lead you to the following
informative threads:

http://code.google.com/appengine/docs/python/runtime.html :

The Sandbox
... (snip,snip) ...
An App Engine application cannot:
... (snip,snip) ...
open a socket or access another host directly. An application can use
the App Engine URL fetch service to make HTTP and HTTPS requests to
other hosts on ports 80 and 443, respectively.


So SMTP auth on 587 will not work, you must use the GAE email
interface as documented other places.

Life goes on.  A bit of a shame for me, because for a little app,
deployment on GAE seems like the easiest answer.   GAE is a special
environment with special restrictions.

Web2py really shines for the quick little app development... but
decent lowend python shared hosting seems to be a bit hard to find at
this time.  Several places I have wandered to imply the need to get
Apache configured... not really a fun job for a quick little app.

- pattu



On Jan 24, 8:24 pm, Alan Etkin  wrote:
> You could try printing this command's output to the console in
> development:
>
> ...
> server.login(email, password)
> ...
>
> It is in line 29 of /gluon/contrib/
> login_methods/email_auth.py
>
> gluon/contrib/login_methods/email_auth.py
>
> On 23 ene, 13:48,pattu wrote:
>
>
>
>
>
>
>
> > Hi -
>
> > Fairly silently.  In the case of running the dev_appserver.py -
> > submitting a correct email and password to login form just shows a
> > very quick response of invalid login (flash message).  Compared to
> > running the web2py built in web server the response is too fast to let
> > me believe that my computer talked to the smtp server I am validating
> > against.. i.e. the request just failed as a failed login.  But I am
> > testing against my organization's smtp and against the gmail smtp,
> > which work fine with the web2py built in server.
>
> > I am not an experienced python debugger, and my attempts to try and
> > step through the smtplib code fail with the GAE - funny errors like
> > non-ascii characters in the source files, which make me think that
> > debugger I tried (winpdb) didn't like the GAE environment.
>
> > The deployed application also shares the same problem.
>
> > Somehow debugging whether GAE is letting a TLS request go through
> > correctly seems puzzling.  I was fairly interested in using the GAE
> > because it came with an easy https access option, (I don't mind the
> > appspot subdomain).  I have a short term app that I wanted security
> > for.  Googling I've seen some mentions that sockets are not
> > implemented fully on GAE, but I don't know if that is currently the
> > case.  I would be delighted to get an error message or exception - let
> > me know how to turn that on if it exists in inside the smtplib, for
> > example.
>
> > There could be some silly mistake I am making - I have made a few
> > hundred so far, but because the implementation in this case seems so
> > simple, I think that GAE might be at fault.  Is there a workaround do
> > you think?  In anycase this development process has really been fun -
> > web2py is a nice environment to work in.
>
> > On Jan 23, 7:21 pm, Massimo Di Pierro 
> > wrote:
>
> > > Did you try it? How does it fail?
>
> > > On Jan 23, 4:07 am,pattu wrote:
>
> > > > Hi -
>
> > > > I have found 150 answers to different questions already by googling my
> > > > way through this list, but I didn't find anything addressing
> > > > email_auth (using an smtp server).  Here is code that works fine
> > > > running the web2py server, but seems to fail both on the GAE
> > > > development server and also deployed.  I might have missed something,
> > > > but I have tried to be exhaustive here:
>
> > > > ###
> > > >  #
> > > > #Test this out:  Doesn't work on GAE in development or on Appspot... =-
> > > > (
> > > > ###
> > > >  #
> > > > #
> > > > #
> > > > from gluon.contrib.login_methods.email_auth import email_auth
>
> > > > #Try

[web2py] Re: email_auth works on web2py server, but not GAE

2012-01-24 Thread Alan Etkin
You could try printing this command's output to the console in
development:

...
server.login(email, password)
...

It is in line 29 of /gluon/contrib/
login_methods/email_auth.py

gluon/contrib/login_methods/email_auth.py

On 23 ene, 13:48, pattu  wrote:
> Hi -
>
> Fairly silently.  In the case of running the dev_appserver.py -
> submitting a correct email and password to login form just shows a
> very quick response of invalid login (flash message).  Compared to
> running the web2py built in web server the response is too fast to let
> me believe that my computer talked to the smtp server I am validating
> against.. i.e. the request just failed as a failed login.  But I am
> testing against my organization's smtp and against the gmail smtp,
> which work fine with the web2py built in server.
>
> I am not an experienced python debugger, and my attempts to try and
> step through the smtplib code fail with the GAE - funny errors like
> non-ascii characters in the source files, which make me think that
> debugger I tried (winpdb) didn't like the GAE environment.
>
> The deployed application also shares the same problem.
>
> Somehow debugging whether GAE is letting a TLS request go through
> correctly seems puzzling.  I was fairly interested in using the GAE
> because it came with an easy https access option, (I don't mind the
> appspot subdomain).  I have a short term app that I wanted security
> for.  Googling I've seen some mentions that sockets are not
> implemented fully on GAE, but I don't know if that is currently the
> case.  I would be delighted to get an error message or exception - let
> me know how to turn that on if it exists in inside the smtplib, for
> example.
>
> There could be some silly mistake I am making - I have made a few
> hundred so far, but because the implementation in this case seems so
> simple, I think that GAE might be at fault.  Is there a workaround do
> you think?  In anycase this development process has really been fun -
> web2py is a nice environment to work in.
>
> On Jan 23, 7:21 pm, Massimo Di Pierro 
> wrote:
>
> > Did you try it? How does it fail?
>
> > On Jan 23, 4:07 am, pattu  wrote:
>
> > > Hi -
>
> > > I have found 150 answers to different questions already by googling my
> > > way through this list, but I didn't find anything addressing
> > > email_auth (using an smtp server).  Here is code that works fine
> > > running the web2py server, but seems to fail both on the GAE
> > > development server and also deployed.  I might have missed something,
> > > but I have tried to be exhaustive here:
>
> > > ###
> > >  #
> > > #Test this out:  Doesn't work on GAE in development or on Appspot... =-
> > > (
> > > ###
> > >  #
> > > #
> > > #
> > > from gluon.contrib.login_methods.email_auth import email_auth
>
> > > #Try with default - same as auth.settings.login_methods =
> > > [email_auth(server="gmail.com:587", domain="@gmail.com")]
>
> > > auth.settings.login_methods = [email_auth()]
> > > auth.settings.actions_disabled=['register','change_password','request_reset
> > >  _password',
> > > 'profile']
>
> > > Has anybody used email_auth on gae?  Or does anyone know why it fails,
> > > and any ideas how to start debugging this?
>
> > > Patrick
>
>


[web2py] Re: email_auth works on web2py server, but not GAE

2012-01-23 Thread pattu
Hi -

Fairly silently.  In the case of running the dev_appserver.py -
submitting a correct email and password to login form just shows a
very quick response of invalid login (flash message).  Compared to
running the web2py built in web server the response is too fast to let
me believe that my computer talked to the smtp server I am validating
against.. i.e. the request just failed as a failed login.  But I am
testing against my organization's smtp and against the gmail smtp,
which work fine with the web2py built in server.

I am not an experienced python debugger, and my attempts to try and
step through the smtplib code fail with the GAE - funny errors like
non-ascii characters in the source files, which make me think that
debugger I tried (winpdb) didn't like the GAE environment.

The deployed application also shares the same problem.

Somehow debugging whether GAE is letting a TLS request go through
correctly seems puzzling.  I was fairly interested in using the GAE
because it came with an easy https access option, (I don't mind the
appspot subdomain).  I have a short term app that I wanted security
for.  Googling I've seen some mentions that sockets are not
implemented fully on GAE, but I don't know if that is currently the
case.  I would be delighted to get an error message or exception - let
me know how to turn that on if it exists in inside the smtplib, for
example.

There could be some silly mistake I am making - I have made a few
hundred so far, but because the implementation in this case seems so
simple, I think that GAE might be at fault.  Is there a workaround do
you think?  In anycase this development process has really been fun -
web2py is a nice environment to work in.


On Jan 23, 7:21 pm, Massimo Di Pierro 
wrote:
> Did you try it? How does it fail?
>
> On Jan 23, 4:07 am, pattu  wrote:
>
> > Hi -
>
> > I have found 150 answers to different questions already by googling my
> > way through this list, but I didn't find anything addressing
> > email_auth (using an smtp server).  Here is code that works fine
> > running the web2py server, but seems to fail both on the GAE
> > development server and also deployed.  I might have missed something,
> > but I have tried to be exhaustive here:
>
> > ### 
> > #
> > #Test this out:  Doesn't work on GAE in development or on Appspot... =-
> > (
> > ### 
> > #
> > #
> > #
> > from gluon.contrib.login_methods.email_auth import email_auth
>
> > #Try with default - same as auth.settings.login_methods =
> > [email_auth(server="gmail.com:587", domain="@gmail.com")]
>
> > auth.settings.login_methods = [email_auth()]
> > auth.settings.actions_disabled=['register','change_password','request_reset 
> > _password',
> > 'profile']
>
> > Has anybody used email_auth on gae?  Or does anyone know why it fails,
> > and any ideas how to start debugging this?
>
> > Patrick
>
>


[web2py] Re: email_auth works on web2py server, but not GAE

2012-01-23 Thread Massimo Di Pierro
Did you try it? How does it fail?

On Jan 23, 4:07 am, pattu  wrote:
> Hi -
>
> I have found 150 answers to different questions already by googling my
> way through this list, but I didn't find anything addressing
> email_auth (using an smtp server).  Here is code that works fine
> running the web2py server, but seems to fail both on the GAE
> development server and also deployed.  I might have missed something,
> but I have tried to be exhaustive here:
>
> ### 
> #
> #Test this out:  Doesn't work on GAE in development or on Appspot... =-
> (
> ### 
> #
> #
> #
> from gluon.contrib.login_methods.email_auth import email_auth
>
> #Try with default - same as auth.settings.login_methods =
> [email_auth(server="gmail.com:587", domain="@gmail.com")]
>
> auth.settings.login_methods = [email_auth()]
> auth.settings.actions_disabled=['register','change_password','request_reset 
> _password',
> 'profile']
>
> Has anybody used email_auth on gae?  Or does anyone know why it fails,
> and any ideas how to start debugging this?
>
> Patrick