~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/mail/helpers.py

  • Committer: Curtis Hovey
  • Date: 2011-08-12 15:57:11 UTC
  • mto: This revision was merged to the branch mainline in revision 13685.
  • Revision ID: curtis.hovey@canonical.com-20110812155711-eij9jv9r14lzzewg
Extracted ProcessMailLayer from test_system_documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
 
163
163
def ensure_not_weakly_authenticated(signed_msg, context,
164
164
                                    error_template='not-signed.txt',
165
 
                                    no_key_template='key-not-registered.txt'):
 
165
                                    no_key_template='key-not-registered.txt',
 
166
                                    error_templates=None):
166
167
    """Make sure that the current principal is not weakly authenticated.
167
168
 
168
169
    NB: While handling an email, the authentication state is stored partly in
179
180
    if IWeaklyAuthenticatedPrincipal.providedBy(cur_principal):
180
181
        if signed_msg.signature is None:
181
182
            error_message = get_error_message(
182
 
                error_template, context=context)
 
183
                error_template, error_templates=error_templates,
 
184
                context=context)
183
185
        else:
184
186
            import_url = canonical_url(
185
187
                getUtility(ILaunchBag).user) + '/+editpgpkeys'
186
188
            error_message = get_error_message(
187
 
                no_key_template, import_url=import_url,
188
 
                context=context)
 
189
                no_key_template, error_templates,
 
190
                import_url=import_url, context=context)
189
191
        raise IncomingEmailError(error_message)
190
192
 
191
193