ich schreibe mir gerade ein kleines Prog mit Anbidung an MongoDB, nun ist es fast fertig und ich sitze hier wie ein Ochs vorm Tor bei einem (denke ich mal) ziemlich einfachern Problem und komme nicht weiter.
Hier mal der Code:
Code: Alles auswählen
import pymongo
import time
class diaryDB:
def __init__(self):
self.connection = pymongo.Connection('localhost', 27017)
self.db = self.connection['diary']
self.collection = self.db['diary_entry']
def insert(self, topic='empty', post='empty'):
insert = {'Topic': topic,
'Post': post,
'made': time.strftime("%Y, %a the %d th at %H:%M")}
self.collection.save(insert)
def take(self):
counter = self.collection.count()
if counter == 0:
pass
else:
x = 1
base = {}
for i in self.collection.find():
base.update({x:[i['Topic'], i['Post'], i['made']]})
x += 1
return base
Code: Alles auswählen
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.2/tkinter/__init__.py", line 1402, in __call__
return self.func(*args)
File "**********/Documents/Aptana Studio 3 Workspace/Diary2.0/window.py", line 62, in make_entries
self.but_left['command'] = database.diaryDB.insert(self, top_ic.get(), self.window.get('1.0', 'end'))
File "********/Documents/Aptana Studio 3 Workspace/Diary2.0/database.py", line 20, in insert
self.collection.save(insert)
AttributeError: 'diary_entry' object has no attribute 'collection'
Ich würde mich freuen wenn mir da jemand sagen kann wo ich den Fehler habe, denn ich sehe ihn nicht.
Danke im Voraus.