[Zope] sending e-mail in external methods

Jonathan dev101 at magma.ca
Fri Jul 8 10:31:44 EDT 2005


How about setting the proxy role of your Register script to 'Manager'? (to 
allow Register to invoke your external method)

Jonathan

----- Original Message ----- 
From: "Susana Beatson" <sbeatson at gmail.com>
To: <zope at zope.org>
Sent: Friday, July 08, 2005 9:59 AM
Subject: [Zope] sending e-mail in external methods


> Hello everybody,
> I am a new zope user that has received an application to maintain and
> I'm learning about zope at the same time.
> One of the features of the app requires users to subscribe to receive
> a newsletter.
> A user is presented with a very simple form
> <form method="post" tal:attributes="action
> string:${here/absolute_url}/Register" metal:fill-slot="content">
> Name: <input name="name" type="text" tal:attributes="value
> request/name|nothing">
> <br />
> <br />
> Email address: <input name="email" type="text" tal:attributes="value
> request/email|nothing">
> <br />
> <br />
> <input type="submit" name="add" value="Submit">
> </form>
>
> The code for Register simply validates the input and calls a function
> defined in an external module to send an e-mail to the person sending
> the request, to verify ownership of the e-mail address.
> This code is something like:
>
> errors = []
> name = form.get('name','').strip()
> email = form.get('email','').strip()
> if not context.validateForm(email, name):
>    errors.append('- Problems occurred with input data')
> if errors:
>    errors.insert(0,'The following problems require correcting:')
>    return context.register_index(messages=errors)
>
> import md5
> from Products.PythonScripts.standard import url_quote
>
> sendEmail(['%s <%s>' % (name,email)],
>    None,
>    'Newsletter Registration Request',
>    """
> Thank you for requesting more information about our Newsletter.
> Blah, blah, blah. To complete your registration please click on the link 
> below
>
> %s/register/Register2?email=%s&name=%s&hash=%s
>
> Once you have done so, you will receive an e-mail confirming your 
> registration.
>
> If you have any problems please email %s
> """ % (
>        container.absolute_url(),
>        url_quote(email),
>        url_quote(name),
>        md5.new('%s%s%sSomeHashHiddenPassword' %
> (url_quote(email),url_quote(name))).hexdigest(),
> container.email_from_address),
>      '')
>
> return context.register_index(name=name, email=email, message="A
> confirmation email has been sent to the address you provided.")
>
> The problem I have is that the sendEmail() function always requires
> the user to be logged in as manager of the portal to work. Whenever I
> click on the "Submit" button, I am asked to log in and the code will
> only proceed after successful log in. The same happens with Register2
> that also sends an e-mail to confirm successful registration. When the
> user receives the e-mail to confirm his data and clicks on the link,
> he gets added to the database successfully and he should be sent an
> e-mail. But again, that only happens if the user is logged in as
> manager.
> As I am new to zope I'm sure I'm missing on something important about
> external methods, can anyone help?
> Thanks in advance,
> Squig.
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
> 




More information about the Zope mailing list