Web2py - Auth - Mongodb Authentication

Asked

Viewed 121 times

2

I’m trying to use Mongodb with Web2py, and for that I started with authentication, but there are some errors that I don’t understand.

In a relational database, Web2py creates the authentication tables, in Mongodb Collections are not being created automatically.

Below follows the code and error when I try to log in:

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 table auth_user.

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"

Could someone help me with this error to be able to use Mongodb authentication in Web2py?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.