Massimo,

You are understandably cautious about using absolute urls, but sending
verification mails is one place where we really need them.

Currently, in tools.py line 646 you insert only the key into the
verification message; how about inserting the validation_url as well?

Line 360 could then be something like
   auth.messages.verify_email = \
      'Click on the link: %(validate_url)s/%(key)s to verify your
email'

I would be happy to suggest a patch, but I don't want to sneak in a
fullurl() helper... ;-)

Cheers,
-Peter

On Feb 9, 3:56 pm, Peter <peter.kleyn...@gmail.com> wrote:
> Hi Chris,
>
> AFAIK you only need to configure the mailer as documented in the
> tools.py source. There is an error in the docstring in the Mail class,
> use the example code in the Auth class.
> Check if you can reach the mail server that you configure by running
> "telnet <server> 25" and check that you get a connection on that port.
> Ehmm, I have ZERO experience on GAE, can't help you with mail settings
> there...
>
> # in db.py:
>
> from gluon.tools import Mail, Auth, Crud
> mail=Mail()
> mail.settings.server='smtp.yourprovider.tld:25'
> mail.settings.sender='....@somewhere.com'
> # only configure login if you need smtp authentication
> # check your regular mail setup
> mail.settings.login='username:password'
>
> # plus, after the line... auth=Auth(globals(),db)
> auth.settings.mailer=mail
>
> def fullurl(a=None,c=None,f=None,r=None,args=[],vars={}):
>     return '%s://%s%s' % (r.env.wsgi_url_scheme,r.env.http_host,URL
> (a=a,c=c,f=f,r=r,args=args,vars=vars))
>
> auth.messages.verify_email = \
>     'Click on the link ' + fullurl(r=request,f='user',args=
> ['verify_email']) + '/%(key)s to verify your email'
>
> These two last lines are necessary because Massimo maybe wasn't really
> really /really/ ready with the Auth verify code yet... ;-)
>
> That should do the trick...  If you want to bypass user validation,
> ie, grant access without entering the validation string, you can
> simply use the web db admin to clear the validation_key field for that
> user.
>
> If you run into any problems, please post. I'm in Amsterdam GMT+1 so
> timewise that's closer than you may think. ;-)
>
> Cheers,
> -Peter
>
> On Feb 9, 2:59 pm, murray3 <ch...@murraypost.net> wrote:
>
> > Peter,
> > thanks for this I will have a go later (I'm in Dublin GMT), just one
> > thing
> > what needs to be set up to get the code to send the registration email
> > other wise when you enable authentication you are locking yourself out
> > as you can't register or login?
> > regards
> > chris
>
> > On Feb 8, 11:32 pm, Peter <peter.kleyn...@gmail.com> wrote:
>
> > > Chris, this is something I was working on, based on the t2.pdf
> > > example... See if it is of any use to you. The indentation will be
> > > screwed up pretty badly, I'm afraid...
>
> > > These instructions replicate the puppy example in the
> > > T2.PDF docs, pages 7-11, for the new tools.py
> > > environment in web2py 1.56
>
> > > 0. From the admin interface, add new app 'puppy'
>
> > > 1. Define table 'puppy' and create a crud instance
>
> > > # db.py:
>
> > > db.define_table('puppy',
> > >     SQLField('name'),
> > >     SQLField('image','upload') )
> > > db.puppy.name.requires=IS_NOT_EMPTY()
>
> > > from gluon.tools import Mail, Auth, Crud
> > > crud=Crud(globals(),db)
>
> > > 2. Enable a RESTful interface through crud
>
> > > # controllers/default.py:
>
> > > def data():
> > >     return dict(form=crud())
>
> > > def download():
> > >     return response.download(request,db)
>
> > > 3. Go tohttp://localhost:8000/puppy/default/data/create/puppy
> > > to see a 'create puppy' form and play around with the default CRUD
> > > interface
>
> > > 4. Create a template for the CRUD pages
>
> > > # views/default/data.html
>
> > > {{extend 'layout.html'}}
> > > {{=form}}
> > > <p>You are now using the data.html template.</p>
>
> > > ...and retry the CRUD URLs; the nice admin/session/etc buttons showed
> > > earlier should be missing now...
>
> > > 5. Define a combo page that shows items + a create form
>
> > > # views/default/customcreate.html
> > > {{extend 'layout.html'}}
>
> > > <div class="frame">
> > > <h2>Post the image of a Puppy</h2>
> > > {{=form}}
> > > </div>
> > > <div class="frame">
> > > <h2>Puppies</h2>
> > > {{=items}}
> > > </div>
> > > <p>You are now using the customcreate.html template.</p>
>
> > > # controllers/default.py
> > > def customcreate():
> > >     form = crud.create('puppy')
> > >     items = crud.select('puppy', linkto=URL(r=request,f='data',args=
> > > ['read']))
> > >     return dict(form=form, items=items)
>
> > > 6. Optionally include the "search" widget from t2.py?
> > > (see t2.pdf, page 9)
> > > (the high-level stuff such as search, comments, etc has gracefully
> > > been split out of tools.py)
>
> > > 7. Add authentication
>
> > > # in models/db.py:
> > > # define your own auth_user table so you can extend it later...
> > > # you can also set auth.settings.table_user later, but you may lose
> > > users already registered (?)
> > > db.define_table('auth_user',
> > >     SQLField('first_name',length=32,default=''),
> > >     SQLField('last_name',length=50,default=''),
> > >     SQLField('email',requires=IS_EMAIL()),
> > >     SQLField('password','password',requires=CRYPT()),
> > >     SQLField('registration_key',length=64),
> > >     SQLField('pic','upload',default=''))    # and add any field you
> > > want...
>
> > > auth=Auth(globals(),db)
> > > auth.settings.table_user=db.auth_user
> > > auth.define_tables()
>
> > > # in controllers/default.py:
> > > def user(): return dict(form=auth())
>
> > > # and add a menu so we can see state
> > > if auth.user: response.menu=[
> > >     ['logout',False,URL(r=request,f='user',args=['logout'])]]
> > > else: response.menu=[
> > >     ['login',False,URL(r=request,f='user',args=['login'])],
> > >     ['register',False,URL(r=request,f='user',args=['register'])]]
>
> > > Go tohttp://localhost:8000/puppy/default/user/registertoregisteras
> > > a user.
> > > Go tohttp://localhost:8000/puppy/default/user/logintologin.
>
> > > 8. Now restrict access to these puppies to logged in users
>
> > > # in controllers/default.py:
>
> > > @auth.requires_login()
> > > def data():
> > >     return dict(form=crud())
>
> > > @auth.requires_login()
> > > def download():
> > >     return response.download(request,db)
>
> > > @auth.requires_login()
> > > def customcreate():
> > >     form = crud.create('puppy')
> > >     items = crud.select('puppy', linkto=URL(r=request,f='data',args=
> > > ['read']))
> > >     return dict(form=form, items=items)
>
> > > (Note: the T2 requires_login had the option of specifying a 'next'
> > > function which
> > > was passed in the vars._destination... This is missing in tools for
> > > now, AFAICT)
>
> > > ---
>
> > > I don't use the authorization stuff yet, powerful as it is, so I'll
> > > leave this to someone else.
> > > For myself, the next stop is subclassing Auth... one reason being to
> > > adapt email registration.
>
> > > Cheers,
> > > -Peter
>
> > > On Feb 8, 6:04 pm, murray3 <ch...@murraypost.net> wrote:
>
> > > > Massimo,
> > > > having trouble getting email registration to work on localhost with
> > > > the T2 Puppies app. What needs to be set up?
>
> > > > Also how do you get the puppies app to run on GAE SDK, I keep getting
> > > > internal error, is it supposed to work?
>
> > > > regards
> > > > chris
>
> > > > On Feb 8, 1:31 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > asap. We need to rewrite T2 to use tools first. if anybody can help
> > > > > please raise your hand.
>
> > > > > Massimo
>
> > > > > On Feb 7, 6:58 pm, murray3 <ch...@murraypost.net> wrote:
>
> > > > > > Could any of you guy's run through the T2 "puppy" example using the
> > > > > > new gluon.tools syntax.
> > > > > > I am missing something (porting my T2 based code) and I'm sure this
> > > > > > would get me restarted.
>
> > > > > > thanks
> > > > > > chris- Hide quoted text -
>
> > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to