no module named py

David Hláčik david at
Thu Jun 5 00:26:25 CEST 2008

Hello, what this beautifull mesage which is messing me whole day means :

*python: error <type 'instance'>, ('No module named py',), No module named

as a result of class which is called from

To be detailed ... news server inn is calling that when doing
autentification , it calls where instance of my class is
hooked into inn , when authentification begins it calls method
authenticate(arguments) from pdg.

I will provide as many information as needed to solve this mistery, becouse
i really need to solve it.

#!/usr/bin/env python

import ldap
from nnrpd import syslog
class news:

        server = 'ldap://'
        user_dn = 'cn=pdg,ou=Operators,o=Polarion'
        user_pw = 'Pdg1'

        connectcodes = {   'READPOST':200,

        authcodes = {  'ALLOWED':281,

        def newsauth(self,match_username,match_password):
                base_dn = 'ou=Users,o=Polarion'
                filter = "(uid=" +  match_username +  ")"
                attrs = ['userPassword']

                try :
                        l = ldap.initialize(self.server)
                        l.bind_s(self.user_dn, self.user_pw)
                        raw_res = l.search_s( base_dn, ldap.SCOPE_SUBTREE,
filter, attrs )
                except ldap.SERVER_DOWN:
                        print "Error, server down"
                        return 2
                except ldap.INVALID_CREDENTIALS:
                        print "Error, invalid credentials"
                        return 2
                except ldap.LDAPError, e:
                        print "Error, %s" % e
                for results in raw_res:
                        (cn,search) = results
                        for password in search["userPassword"]:
                                if password == match_password: return 1

                return 0

        def authenticate(self, attributes):

                # just for debugging purposes
                syslog('notice', 'nnrpd_auth authenticate() invoked:
hostname %s, ipaddress
 %s, interface %s, user %s' % (\
                        attributes['hostname'], \
                        attributes['ipaddress'], \
                        attributes['interface'], \

                        syslog('notice', "result %s" %
                except Exception, msg:
                        syslog('notice', "error %s, %s, %s" %
                # do username passworld authentication
                #if self.newsauth(attributes['user'],
                #    syslog('notice', 'authentication by username
                #    return ( self.authcodes['ALLOWED'], 'No error' )
                #    syslog('notice', 'authentication by username failed')
                #    return ( self.authcodes['DENIED'], 'Access Denied!')


nnrpd_auth_py :

# Sample authentication and authorization class. It defines all methods
# to nnrpd.
# Import functions exposed by nnrpd. This import must succeed, or nothing
# will work!
from nnrpd import *
from pdg import *

myauth = news()

# ...and try to hook up on nnrpd. This would make auth object methods
# to nnrpd.
    syslog('notice', "authentication module successfully hooked into nnrpd")
except Exception, errmsg:
    syslog('error', "Cannot obtain nnrpd hook for authentication method: %s"
% errmsg[0])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list