[web2py] Mongodb Error

2018-10-30 Thread lbjc1978
I'm trying to use MongoDB for the first time. I looked at this 

 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" 
, line 12, in 

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.


Re: [web2py] Mongodb error in appadmin

2013-03-21 Thread Mike Veltman
On 03/21/2013 08:06 PM, Alan Etkin wrote:
>
> I would love to have some pointers about how though define mongo in
> db.py in a proper nosql way.
>
>
> Could you open an issue at the project page?
>

Done :-) Issue 1401
: Mongodb error
in appadmin If more info needed or some testing is needed just ask.

I will play with mongo and web2py anyway.


> If you can, please provide:
>
> - The relevant part of the model
> - A possible set of data which would reproduce the error
> - Your mongodb driver, database server, web2py and Python versions
>
> The MongoDB DAL adapter does some automatic type mapping for id
> fields. I belive the issue could be realted to that.
>
> -- 
>  
> ---
> 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/groups/opt_out.
>  
>  

-- 

--- 
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/groups/opt_out.




Re: [web2py] Mongodb error in appadmin

2013-03-21 Thread Alan Etkin

>
> I would love to have some pointers about how though define mongo in 
> db.py in a proper nosql way. 
>

Could you open an issue at the project page?

If you can, please provide:

- The relevant part of the model
- A possible set of data which would reproduce the error
- Your mongodb driver, database server, web2py and Python versions

The MongoDB DAL adapter does some automatic type mapping for id fields. I 
belive the issue could be realted to that.

-- 

--- 
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/groups/opt_out.




Re: [web2py] Mongodb error in appadmin

2013-03-21 Thread Mike Veltman

Op 21-03-13 17:50, Niphlod schreef:
> seems to me that a lot of people are interested in using mongodb but
> really few are contributing back with tests and patches.
>
> BTW: you DO know that Mongo generally doesn't play well with joins,
> right ? Using references in mongodb is not a smart design.
>

Mongodb as far as I know does not have joins :) But it did accept it, so
I decided to post the error.

But this is mysql database design that I did put over 1 on 1

I have to redo the database design to be nicer to Mongo (I am just
looking up to the conversion, even though I now have both databases so
its just a matter of writing a copy and past program after I created the
new database structure in mongo) .

I would love to have some pointers about how though define mongo in
db.py in a proper nosql way.

Thanks for the remark btw :) 

> -- 
>  
> ---
> 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/groups/opt_out.
>  
>  

-- 

--- 
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/groups/opt_out.




Re: [web2py] Mongodb error in appadmin

2013-03-21 Thread Niphlod
seems to me that a lot of people are interested in using mongodb but really 
few are contributing back with tests and patches.

BTW: you DO know that Mongo generally doesn't play well with joins, right ? 
Using references in mongodb is not a smart design.

-- 

--- 
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/groups/opt_out.




[web2py] Mongodb error in appadmin

2013-03-21 Thread Mike Veltman

Created the following table

mdb.define_table('syscommands',

Field('commandname', type='string',
  unique=True,
  label=T('Commandname')),
Field('commandline', type='string',
  label=T('Command')),
Field('host_id', mdb.hoststable,
  comment="Like nim or hmc server.",
  label=T('Destination Host ID')),
Field('description', type='string',
  label=T('Description')),
Field('fase','string',
  comment="Fase 1 is storage, Fase 2 is Profile Creation, Fase 3
is VIO deployment, Fase 4 is Lpar deployment..",
  label=T('Fase')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
format='%(commandname)s',
migrate=settings.migrate)


# Table rules for command
mdb.syscommands.fase.requires = IS_IN_SET(['1', '2', '3', '4'])
#mdb.syscommands.host_id.requires = IS_NOT_EMPTY()
mdb.syscommands.commandname.requires = IS_NOT_EMPTY()
mdb.syscommands.host_id.requires = IS_IN_DB(mdb, 'hoststable.id',
'hoststable.hostname')
mdb.syscommands.commandline.requires = IS_NOT_EMPTY()


it revers to this table

mdb.define_table('hoststable',

Field('hostname', type='string',
  unique=True,
  label=T('Hostname')),
Field('description', type='string',
  label=T('Description')),
Field('netboot', type='string',
  label=T('Netboot information')),
Field('ip', type='string',
  default='192.168.1.x',
  label=T('IP Address')),
Field('connectcmd', type='string',
  default='ssh',
  label=T('Connection command')),
Field('useraccount', type='string',
  default='root',
  label=T('Default User')),
Field('created_on','datetime',default=request.now,
  label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
  label=T('Modified On'),writable=False,readable=False,
  update=request.now),
format='%(hostname)s',
migrate=settings.migrate)


# Table Hosts rules
mdb.hoststable.hostname.requires = IS_NOT_EMPTY()
mdb.hoststable.ip.requires = IS_NOT_EMPTY()


Then when I create a record in appadmin and after that change this item

It throws this error.


  Ticket ID

127.0.0.1.2013-03-21.17-03-38.3cfba30b-5706-4bdb-af50-faa6be3ed179


 uncaught exception when
updating rows: MongoDB can only handle up to 8-byte ints


  Version

web2py^(TM) Version 2.4.5-stable+timestamp.2013.03.18.22.46.22
Python  Python 2.7.3: /usr/bin/python2.7 (prefix: /usr)


  Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.



Traceback (most recent call last):
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/restricted.py",
 line 212, in restricted
exec ccode in environment
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py",
 line 410, in 
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/globals.py",
 line 194, in 
self._caller = lambda f: f()
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py",
 line 277, in update
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/sqlhtml.py",
 line 1527, in accepts
self.id_field_name]).update(**fields)
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py",
 line 9834, in update
ret = db._adapter.update(tablename,self.query,fields)
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py",
 line 5450, in update
raise RuntimeError("uncaught exception when updating rows: %s" % e)
RuntimeError: uncaught exception when updating rows: MongoDB can only handle up 
to 8-byte ints



-- 

--- 
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/groups/opt_out.




[web2py] Mongodb error in appadmin

2013-03-21 Thread Mike Veltman
The action I have a table/collection with 3 objects

In the table this is reverenced as

 Field('host_id', mdb.hoststable,
  comment="Like nim or hmc server.",
  label=T('Destination Host ID')),

But when in appadmin I select a other object to change then it throws a
error.

The error


  Ticket ID

127.0.0.1.2013-03-21.15-46-39.9f2786b5-d69c-4e31-a6c9-dd76f3692e59


 uncaught exception when
updating rows: MongoDB can only handle up to 8-byte ints


  Version

web2py^(TM) Version 2.4.5-stable+timestamp.2013.03.18.22.46.22
Python  Python 2.7.3: /usr/bin/python2.7 (prefix: /usr)


  Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.



Traceback (most recent call last):
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/restricted.py",
 line 212, in restricted
exec ccode in environment
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py",
 line 410, in 
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/globals.py",
 line 194, in 
self._caller = lambda f: f()
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/applications/adeploy/compiled/controllers_appadmin_update.py",
 line 277, in update
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/sqlhtml.py",
 line 1527, in accepts
self.id_field_name]).update(**fields)
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py",
 line 9834, in update
ret = db._adapter.update(tablename,self.query,fields)
  File 
"/home/mv1965/Documents/development/eclipse/workspacejuno/w2pdeploy/gluon/dal.py",
 line 5450, in update
raise RuntimeError("uncaught exception when updating rows: %s" % e)
RuntimeError: uncaught exception when updating rows: MongoDB can only handle up 
to 8-byte ints


-- 

--- 
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/groups/opt_out.




[web2py] mongodb error

2012-09-30 Thread Jose Galvez
I am trying to run through the image blog example from the docs using 
mongodb. when I try to upload an image I get the follwoing error 
 strings in documents must be valid 
UTF-8 and when I look at crated document: 
(self=Collection(Database(Connection('localhost', 27017), u'db1'), 
u'image'), doc_or_docs={'_id': ObjectId('5067ae9955a5d848e00be9b4'), 
'file': u'image.file.946df6ec3010e611.6772696c6c2e6a7067.jpg', 'file_blob': 
'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c\x0b\x0b\x0c\x19\x12...E\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x00QE\x14\x01\xff\xd9',
 
'title': u'redneck gril'}, manipulate=True, safe=True, check_keys=True, 
continue_on_error=False, **kwargs={})


it looks like it is not properly encoding the file_blob object.


Any suggestions on how to fix this?

--