I'm trying to use MongoDB for the first time. I looked at this 
<https://stackoverflow.com/questions/21674013/can-mongodbs-embedded-documents-be-modeled-in-web2py-dal>
 link 
as one of the guidance. but ended up with an error.
My code below:

from gluon import current
from pymongo import MongoClient
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
from gluon.custom_import import track_changes
track_changes(True)
db = DAL('mongodb://username:password@localhost/test', pool_size=0)
Post = db.define_table('post',
                       Field('author', 'reference auth_user', default=auth.
user_id, writable=False, readable=False),
                       Field('comments', 'text', requires=IS_NOT_EMPTY(),
                             default ="Hi there it's me", notnull=False),
                       auth.signature
                       )




Error:

  File "/home/maurice/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/maun/web2py/applications/boyeve/models/db2.py" 
<http://127.0.0.1:8000/admin/default/edit/boys_eve/models/db2.py>, line 12, in 
<module>
    db = DAL('mongodb://username:password@localhost/test', pool_size=0)
  File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 169, in 
__call__
    obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 474, in 
__init__
    "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 454, in 
__init__
    self._adapter = adapter(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/__init__.py", 
line 40, in __call__
    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/base.py", line 
52, in __init__
    self.reconnect()
  File "/usr/local/lib/python2.7/dist-packages/pydal/helpers/classes.py", line 
184, in _reconnect_and_configure
    self._configure_on_first_reconnect()
  File "/usr/local/lib/python2.7/dist-packages/pydal/adapters/mongo.py", line 
79, in _configure_on_first_reconnect
    "serverStatus")['version']
  File "/usr/local/lib/python2.7/dist-packages/pymongo/database.py", line 611, 
in command
    read_preference) as (sock_info, slave_ok):
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 
1101, in _socket_for_reads
    with self._get_socket(server) as sock_info:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 
1058, in _get_socket
    with server.get_socket(self.__all_credentials) as sock_info:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/pymongo/pool.py", line 1006, in 
get_socket
    sock_info.check_auth(all_credentials)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/pool.py", line 677, in 
check_auth
    auth.authenticate(credentials, self)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/auth.py", line 563, in 
authenticate
    auth_func(credentials, sock_info)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/auth.py", line 540, in 
_authenticate_default
    return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
  File "/usr/local/lib/python2.7/dist-packages/pymongo/auth.py", line 262, in 
_authenticate_scram
    res = sock_info.command(source, cmd)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/pool.py", line 579, in 
command
    unacknowledged=unacknowledged)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/network.py", line 150, 
in command
    parse_write_concern_error=parse_write_concern_error)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 155, 
in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
OperationFailure: Authentication failed.


I need help to solve this

Regards

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to