mongodb - python app doesn't recognize module -


i'm building python app, , i'm trying index.py file import guestbookdoa.py file. when run index file, import error saying:

line 3, no module named guestbookdao

here index.py file:

import bottle import pymongo import guestbookdao  #this default route, our index page.  here need read documents mongodb. @bottle.route('/') def guestbook_index():     mynames_list = guestbook.find_names()     return bottle.template('index', dict(mynames = mynames_list))  #we post new entries route can insert them mongodb @bottle.route('/newguest', method='post') def insert_newguest():     name = bottle.request.forms.get("name")     email = bottle.request.forms.get("email")     guestbook.insert_name(name,email)     bottle.redirect('/')   #this setup connection  #first, setup connection string. server running on computer localhost ok connection_string = "mongodb://localhost" #next, let pymongo know mongodb connection want use.  pymongo manage connection pool connection = pymongo.mongoclient(connection_string) #now want set context names database created using mongo interactive shell database = connection.names #finally, let out data access object class built acts our data layer know guestbook = guestbookdao.guestbookdao(database)  bottle.debug(true) bottle.run(host='localhost', port=8082)  

and here guestbookdao.py file:

import string  class guestbookdao(object):  #initialize our dao class database , set mongodb collection want use     def __init__(self, database):         self.db = database         self.mynames = database.mynames  #this function handle finding of names     def find_names(self):         l = []         each_name in self.mynames.find():             l.append({'name':each_name['name'], 'email':each_name['email']})          return l  #this function handle insertion of names     def insert_name(self,newname,newemail):         newname = {'name':newname,'email':newemail}         self.mynames.insert(newname) 


Comments