[Grok-dev] send mail queryUtility ComponentLookupError todoplus

DIVINE, PAUL (PAUL) paul.divine at alcatel-lucent.com
Fri Aug 20 05:24:34 EDT 2010


Hello grokkers,
I am using the great book "Grok 1.0" of Carlos de la Guardia, at the 
chapter 11 "Key Concepts Behind Grok". The purpose is to send email.

When I add a project, the program is supposed to send a mail but,
the following Error is displayed.


Module todo_plus.app:177 in send_email         
<<      msg["To"] = ','.join(recipient)
        msg["Subject"] = email.Header.Header(subject, 'UTF-8')
        mailer = getUtility(IMailDelivery, 'todoplus')
        mailer.send(sender, recipient, msg.as_string())>>  mailer = getUtility(IMailDelivery, 'todoplus')
Module zope.component._api:171 in getUtility        
<<      if utility is not None:
            return utility
        raise ComponentLookupError(interface, name)
   
    def queryUtility(interface, name='', default=None, context=None):>>  raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass zope.sendmail.interfaces.IMailDelivery>, 'todoplus')


The corresponding source is the following.
    msg = email.MIMEText.MIMEText(body.encode('UTF-8'), 'plain', 'UTF-8')
    msg["From"] = sender
    msg["To"] = ','.join(recipient)
    msg["Subject"] = email.Header.Header(subject, 'UTF-8')
    mailer = getUtility(IMailDelivery, 'todoplus')
    mailer.send(sender, recipient, msg.as_string())

Thanks in advance for your help.
Paul


The following lines give some details.


pl6320:~/npo/testgrok/todo/src/todo_plus# cat setup.py
from setuptools import setup, find_packages
import sys, os

version = '0.0'

setup(name='todo_plus',
      version=version,
      description="",
      long_description="""\
""",
      classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
      keywords='',
      author='',
      author_email='',
      url='',
      license='',
      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
      include_package_data=True,
      zip_safe=False,
      install_requires=[
          'todo',
          'zc.sourcefactory',
          'zope.sendmail',
          # -*- Extra requirements: -*-
      ],
      entry_points="""
      # -*- Entry points: -*-
      """,
      )





pl6320:~/npo/testgrok/todo/src/todo_plus/todo_plus# cat configure.zcml
<configure xmlns="http://namespaces.zope.org/zope"
           xmlns:mail="http://namespaces.zope.org/mail"
           xmlns:grok="http://namespaces.zope.org/grok">
  <include package="grok" />
  <includeDependencies package="." />
  <grok:grok package="." />
   <mail:smtpMailer
     name="todoplus.smtp"
     hostname="mailhost.xxxxx"
     port="25"
     username="xxxxx"
     password="xxxx"
     />
 <mail:queuedDelivery
     name="mailer"
     permission="zope.Public"
     mailer="todoplus.smtp"
     queuePath="mailqueue"
     />

</configure>


More information about the Grok-dev mailing list