[prev in list] [next in list] [prev in thread] [next in thread] 

List:       trac
Subject:    [Trac] trac 1.0.3 ConfigurationError: Cannot find an implementation of the IEmailSender
From:       Sharif Uddin <shorif2000 () gmail ! com>
Date:       2015-01-22 17:33:11
Message-ID: 816fc514-3c99-41cc-8998-484ffa617dc4 () googlegroups ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I am getting this error. it worked fine on trac 1.0.1


[root@cobra domain]# cat SmtpLdapEmailSender.py
from trac.core import *
from trac.config import IntOption, Option
from trac.notification import SmtpEmailSender
#from trac.notification import IEmailSender, SmtpEmailSender
import ldap

class SmtpLdapEmailSender(SmtpEmailSender):

    #implements(IEmailSender)

    email_ldap_serveruri = Option('notification', 'email_ldap_serveruri', 
'',
                               """AD LDAP Server to use for looking up 
e-mail addresses""")
    email_ldap_port = IntOption('notification', 'email_ldap_port', 389, 
"""AD LDAP Server port""")
    email_ldap_binddn = Option('notification', 'email_ldap_binddn', '',
                               """Bind DN for LDAP lookup. If not given, 
Kerberos auth will be used for current user""")
    email_ldap_bindpw = Option('notification', 'email_ldap_bindpw', '', 
"""Password for non-kerberos auth""")
    email_ldap_basedn = Option('notification', 'email_ldap_basedn', '', 
"""Base DN to use for LDAP searches""")
    
    email_attr = 'mail'
    
    def __init__(self):
        self.log.debug("Initialising LDAP object with URI: ", 
self.email_ldap_serveruri)
        self.ldap_conn=ldap.initialize(self.email_ldap_serveruri)
        
        
    def send(self, from_addr, recipients, message):
        
        if self.email_ldap_binddn != None:
            self.log.info("Binding to LDAP as " + self.email_ldap_binddn)
            self.ldap_conn.bind_s(self.email_ldap_binddn, 
self.email_ldap_bindpw, ldap.AUTH_SIMPLE)
        else:
            self.log.info("Binding to LDAP with Kerberos")
            self.ldap_conn.bind_s()
        
        #Iterate through recipients, checking for correct e-mail addresses 
in LDAP
        #Output in ldapRecipients
        self.log.info("Updating list of recipients")
        new_recipients = []
        for addr in recipients:
            self.log.debug("Searching LDAP server %s for user %s", 
self.email_ldap_serveruri, addr)
            search_string = 'userPrincipalName=' + addr
            result = self.ldap_conn.search_s(self.email_ldap_basedn, 
ldap.SCOPE_SUBTREE, search_string, [self.email_attr])
            
            #result is formatted as a string (result) in a list of [attr 
values], in a dictionary of {attr_name=>attr_values}
            #in a tuple of (DN, Entry), within a list of results. So result 
for principle name jasona@domain.com would be
            #[('CN=Jason Aftalion,OU=TechSupport,OU=Woking,OU=Sites,DC=
domain,DC=com', {'mail': ['Jason.Aftalion@domain.com']})] 
            if result[0][1][self.email_attr][0]:
                self.log.debug("Found e-mail address: " + 
result[0][1][self.email_attr][0])
                new_recipients.append(result[0][1][self.email_attr][0])
            else:
                self.log.debug("Could not find e-mail address")
                new_recipients.append(addr)
            
            
            return super(SmtpLdapEmailSender,self).send(from_addr, 
new_recipients, message)



error in log file

2015-01-22 17:21:47,028 Trac[web_ui] ERROR: Failure sending notification on 
change to ticket #86: ConfigurationError: Cannot find an implementation of 
the <tt>IEmailSender</tt> interface named <tt>SmtpLdapEmailSender</tt>. 
Please check that the Component is enabled or update the option 
<tt>[notification] email_sender</tt> in trac.ini.


-- 
You received this message because you are subscribed to the Google Groups "Trac \
Users" group. To unsubscribe from this group and stop receiving emails from it, send \
an email to trac-users+unsubscribe@googlegroups.com. To post to this group, send \
email to trac-users@googlegroups.com. Visit this group at \
http://groups.google.com/group/trac-users. For more options, visit \
https://groups.google.com/d/optout.


[Attachment #5 (text/html)]

<div dir="ltr">I am getting this error. it worked fine on trac 1.0.1<br><br><br><div \
style="margin-left: 40px;"><span style="font-family: courier \
new,monospace;">[root@cobra </span><span style="font-family: courier \
new,monospace;"><span style="font-family: courier new,monospace;">domain</span>]# cat \
SmtpLdapEmailSender.py</span><br><span style="font-family: courier \
new,monospace;">from trac.core import *</span><br><span style="font-family: courier \
new,monospace;">from trac.config import IntOption, Option</span><br><span \
style="font-family: courier new,monospace;">from trac.notification import \
SmtpEmailSender</span><br><span style="font-family: courier new,monospace;">#from \
trac.notification import IEmailSender, SmtpEmailSender</span><br><span \
style="font-family: courier new,monospace;">import ldap</span><br><span \
style="font-family: courier new,monospace;"></span><br><span style="font-family: \
courier new,monospace;">class SmtpLdapEmailSender(SmtpEmailSender):</span><br><span \
style="font-family: courier new,monospace;"></span><br><span style="font-family: \
courier new,monospace;">&nbsp;&nbsp;&nbsp; #implements(IEmailSender)</span><br><span \
style="font-family: courier new,monospace;"></span><br><span style="font-family: \
courier new,monospace;">&nbsp;&nbsp;&nbsp; email_ldap_serveruri = \
Option('notification', 'email_ldap_serveruri', '',</span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
"""AD LDAP Server to use for looking up e-mail addresses""")</span><br><span \
style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; email_ldap_port = \
IntOption('notification', 'email_ldap_port', 389, """AD LDAP Server \
port""")</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp; email_ldap_binddn = Option('notification', \
'email_ldap_binddn', '',</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
"""Bind DN for LDAP lookup. If not given, Kerberos auth will be used for current \
user""")</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp; email_ldap_bindpw = Option('notification', \
'email_ldap_bindpw', '', """Password for non-kerberos auth""")</span><br><span \
style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; email_ldap_basedn = \
Option('notification', 'email_ldap_basedn', '', """Base DN to use for LDAP \
searches""")</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp; </span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp; email_attr = 'mail'</span><br><span \
style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; </span><br><span \
style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; def \
__init__(self):</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.log.debug("Initialising LDAP object with URI: ", \
self.email_ldap_serveruri)</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.ldap_conn=ldap.initialize(self.email_ldap_serveruri)</span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br><span \
style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; def send(self, \
from_addr, recipients, message):</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.email_ldap_binddn \
!= None:</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.log.info("Binding to LDAP as " + self.email_ldap_binddn)</span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.ldap_conn.bind_s(self.email_ldap_binddn, self.email_ldap_bindpw, \
ldap.AUTH_SIMPLE)</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:</span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.log.info("Binding to LDAP with Kerberos")</span><br><span style="font-family: \
courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.ldap_conn.bind_s()</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #Iterate through \
recipients, checking for correct e-mail addresses in LDAP</span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #Output in \
ldapRecipients</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.log.info("Updating \
list of recipients")</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new_recipients = \
[]</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for addr in \
recipients:</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.log.debug("Searching LDAP server %s for user %s", self.email_ldap_serveruri, \
addr)</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
search_string = 'userPrincipalName=' + addr</span><br><span style="font-family: \
courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
result = self.ldap_conn.search_s(self.email_ldap_basedn, ldap.SCOPE_SUBTREE, \
search_string, [self.email_attr])</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
#result is formatted as a string (result) in a list of [attr values], in a dictionary \
of {attr_name=&gt;attr_values}</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
#in a tuple of (DN, Entry), within a list of results. So result for principle name \
jasona@domain.com would be</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
#[('CN=Jason Aftalion,OU=TechSupport,OU=Woking,OU=Sites,DC=</span><span \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;">domain</span>,DC=com', {'mail': ['Jason.Aftalion@</span><span \
style="font-family: courier new,monospace;"><span style="font-family: courier \
new,monospace;">domain</span>.com']})] </span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if \
result[0][1][self.email_attr][0]:</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.log.debug("Found e-mail address: " + \
result[0][1][self.email_attr][0])</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
new_recipients.append(result[0][1][self.email_attr][0])</span><br><span \
style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
else:</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.log.debug("Could not find e-mail address")</span><br><span style="font-family: \
courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
new_recipients.append(addr)</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span><br><span style="font-family: courier \
new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
return super(SmtpLdapEmailSender,self).send(from_addr, new_recipients, \
message)</span><br></div><br><br><br>error in log file<br><br><div \
style="margin-left: 40px;"><span style="font-family: courier \
new,monospace;">2015-01-22 17:21:47,028 Trac[web_ui] ERROR: Failure sending \
notification on change to ticket #86: ConfigurationError: Cannot find an \
implementation of the &lt;tt&gt;IEmailSender&lt;/tt&gt; interface named \
&lt;tt&gt;SmtpLdapEmailSender&lt;/tt&gt;. Please check that the Component is enabled \
or update the option &lt;tt&gt;[notification] email_sender&lt;/tt&gt; in \
trac.ini.</span><br><span style="font-family: courier \
new,monospace;"></span></div><br><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &quot;Trac \
Users&quot; group.<br /> To unsubscribe from this group and stop receiving emails \
from it, send an email to <a \
href="mailto:trac-users+unsubscribe@googlegroups.com">trac-users+unsubscribe@googlegroups.com</a>.<br \
/> To post to this group, send email to <a \
href="mailto:trac-users@googlegroups.com">trac-users@googlegroups.com</a>.<br /> \
Visit this group at <a \
href="http://groups.google.com/group/trac-users">http://groups.google.com/group/trac-users</a>.<br \
/> For more options, visit <a \
href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br \
/>

------=_Part_276_1896641680.1421947991541--



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic