I'm trying to use MongoDB with Web2py, and for that I started with authentication, but this one appearing errors that I do not understand.
In a relational database, Web2py creates the authentication tables, in MongoDB the collections are not being created automatically.
Below is the code and error when I try to login:
db.py
db = DAL("mongodb://localhost/primer", check_reserved=["mongodb_nonreserved",], adapter_args={"safe":False})
from gluon.tools import Auth, Service, PluginManager
auth = Auth(db)
service = Service()
plugins = PluginManager()
auth.settings.remember_me_form = False
auth.settings.actions_disabled=['register','change_password','request_reset_password','retrieve_username','profile']
auth.define_tables(username=True)
from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods = [ldap_auth(server='localhost', port='10389', base_dn='ou=people,o=empresa,dc=com,dc=br')]
Authentication is by LDAP, and works perfectly in a relational database, which has the auth_user
table.
However, when logging in using MongoDB, the following error appears:
Traceback (most recent call last): File "C: \ Users \ Rafa \ Desktop \ web2py-10-06-2015p4 \ applications \ contract \ controllers / appadmin.py", line 249, in select nrows = db (query, ignore_common_filters = True) .count () File "C: \ Users \ Rafa \ Desktop \ web2py-10-06-2015p4 \ gluon \ packages \ dal \ pydal \ objects.py", line 2016, in count return db._adapter.count (self.query, distinct) File "C: \ Users \ Rafa \ Desktop \ web2py-10-06-2015p4 \ gluon \ packages \ dal \ pydal \ adapters \ mongo.py", line 200, in count count = True, snapshot = snapshot) ['count']) File "C: \ Users \ Rafa \ Desktop \ web2py-10-06-2015p4 \ gluon \ packages \ dal \ pydal \ adapters \ mongo.py", line 319, in select sort = mongosort_list, snapshot = snapshot) .count ()} File "C: \ Python27 \ lib \ site-packages \ pymongo \ collection.py", line 929, in find return Cursor (self, * args, ** kwargs) TypeError: init () got an unexpected keyword argument 'snapshot'
The database "primer" is created and only has 2 collections "posts" and "system.indexes"
Can anyone help me with this error to be able to use authentication using MongoDB in Web2py?