Start New Discussion within our Software Development Community

Hi, I am new to Python and am looking into web development frameworks i.e. Pyramid.
Is there anyone here who is familiar with this Framework using MongoDB?

I am using pymongo and Ming I follwed a tutorial here.
I am getting an AttributeError: 'str' object has no attribute '_auto_ensure_indexes' in this code :

from ming import Session
from ming.datastore import DataStore
from ming.orm import ThreadLocalORMSession
from ming.orm import Mapper

session = Session
DBSession = ThreadLocalORMSession(session)

def init_mongo(engine):
    server, database = engine
    datastore = DataStore(server, database=database)
    session.bind = datastore
    Mapper.compile_all()

# Here we just ensure indexes on all our mappers at startup.
    for mapper in Mapper.all_mappers():
        session.ensure_indexes(mapper.collection) # <-- Error on this line

# Flush changes and close all connections
    DBSession.flush()
    DBSession.close_all()

from .user import User

I have no clue to what is causing the error.. can some one please help me?
Thank you

I found the solution...

It is actualy datastore = DataStore(server, database=database) that was causing the problem.. I just replaced it with datastore = create_datastore(server+'/'+database) and now it works fine... still not sure why...

This question has already been answered. Start a new discussion instead.