On Apr 14, 2011, at 3:30 AM, Mike Giles wrote:
> 
> That doesn't seem to work.  First, I believe web2py will be looking
> for an application named _ah to handle the request (versus a controler
> named _ah in myapp).  Assuming there is a way to resolve that (which
> would be great to know),

This is done with web2py's routing function. Using the parametric router, for 
example, you just need to set the default application name and then _ah will be 
treated as a controller name.

Copy router.example.py to routes.py and make a router like this:

routers = dict(

    # base router
    BASE = dict(
        default_application = 'welcome',
    ),
)

...changing 'welcome' as appropriate. You can perform other routing functions 
as you like, of course.

> the second issue is that to deal with inbound
> mail requests you need to subclass InboundMailHandler from Google so
> that you can pull apart the various pieces of the email message with
> ease.

Once your mail() function in the _ah controller gets control, you can call your 
subclassed helper (put it in modules if that's convenient for you). 

The main thing is that you have to invoke web2py through gaehandler for a 
request to use the framework.

> 
> I based this on the simple piece of code in the Google docs (http://
> code.google.com/appengine/docs/python/mail/receivingmail.html) and it
> seems like I have to figure out how to get that to run through web2py
> so that it picks up all the stuff that should be in the environment.
> Perhaps it's as simple as changing the WSGI calls at the bottom of it:
> 
> application = webapp.WSGIApplication([ReportHandler.mapping()],
> debug=True)
> 
> def main():
>    run_wsgi_app(application)
> if __name__ == "__main__":
>    main()
> 
> All I know is that I seem to be outside the basic usage path which is
> tough on your first experience with a new framework.



> 
> -Mike
> 
> On Apr 13, 11:12 pm, Jonathan Lundell <[email protected]> wrote:
>> On Apr 13, 2011, at 4:06 PM, Mike Giles wrote:
>> 
>> 
>> 
>>> I'm playing around with web2py for the first time on a project that is
>>> using GAE to accept and process inbound email.  When mail comes in to
>>> GAE, you need to tell it what piece of code to run in your app.yaml to
>>> handle it:
>> 
>>> - url: /_ah/mail/.+
>>>  script: applications/myapp/modules/incoming.py
>>>  login: admin
>> 
>>> So my first question is where should I put the code that will handle
>>> this mail?  Is it a module?  A controller?
>> 
>> I think you want something like this:
>> 
>> - url: /_ah/mail/.+
>>  script: gaehandler.py
>> 
>> Create a controller named _ah.py, with a function mail(), and look in 
>> request.args(0) for the email address.
>> 
>> I think.
>> 


Reply via email to