[web2py] Re: MongoDB Adapter error in select

2012-05-21 Thread Francisco Costa
requested here: 
https://groups.google.com/d/topic/web2py/pqdYpUbMXKQ/discussion

On Monday, May 14, 2012 2:35:43 AM UTC+1, Massimo Di Pierro wrote:

 I think you can already

 db.table.insert(**dict())

 Are you asking for something different?

 On Saturday, 12 May 2012 05:25:02 UTC-5, Francisco Costa wrote:

 It works Massimo!
 In MongoDb is also common to insert dicts, can we also have that?

 At the moment it only saves in the string format (check player Field)
 { _id : ObjectId(4fae3839b34f4brf5a31), city : Madrid, club 
 : Real Madrid, *player : {'n_goals': 43, 'name': 'Ronaldo'}* }



 On Friday, May 11, 2012 9:16:58 PM UTC+1, Massimo Di Pierro wrote:

 One more try please.

 On Friday, 11 May 2012 06:04:52 UTC-5, Francisco Costa wrote:

 Thanks Massimo. Please let me know if you need more help in debugging it

 On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall 
 fix it tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)



[web2py] Re: MongoDB Adapter error in select

2012-05-15 Thread Krzysztof Mulica
I'm guessing he's looking for something like I am, 

http://cookbook.mongodb.org/patterns/count_tags/ 

{
title : A blog post,
author : Kristina,
content : ...,
tags : [MongoDB, Map/Reduce, Recipe]
}



using DAL, how would I go about inserting that list, what wouldd the type 
be in the model definition?

On Sunday, May 13, 2012 8:35:43 PM UTC-5, Massimo Di Pierro wrote:

 I think you can already

 db.table.insert(**dict())

 Are you asking for something different?

 On Saturday, 12 May 2012 05:25:02 UTC-5, Francisco Costa wrote:

 It works Massimo!
 In MongoDb is also common to insert dicts, can we also have that?

 At the moment it only saves in the string format (check player Field)
 { _id : ObjectId(4fae3839b34f4brf5a31), city : Madrid, club 
 : Real Madrid, *player : {'n_goals': 43, 'name': 'Ronaldo'}* }



 On Friday, May 11, 2012 9:16:58 PM UTC+1, Massimo Di Pierro wrote:

 One more try please.

 On Friday, 11 May 2012 06:04:52 UTC-5, Francisco Costa wrote:

 Thanks Massimo. Please let me know if you need more help in debugging it

 On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall 
 fix it tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)



[web2py] Re: MongoDB Adapter error in select

2012-05-13 Thread Massimo Di Pierro
I think you can already

db.table.insert(**dict())

Are you asking for something different?

On Saturday, 12 May 2012 05:25:02 UTC-5, Francisco Costa wrote:

 It works Massimo!
 In MongoDb is also common to insert dicts, can we also have that?

 At the moment it only saves in the string format (check player Field)
 { _id : ObjectId(4fae3839b34f4brf5a31), city : Madrid, club 
 : Real Madrid, *player : {'n_goals': 43, 'name': 'Ronaldo'}* }



 On Friday, May 11, 2012 9:16:58 PM UTC+1, Massimo Di Pierro wrote:

 One more try please.

 On Friday, 11 May 2012 06:04:52 UTC-5, Francisco Costa wrote:

 Thanks Massimo. Please let me know if you need more help in debugging it

 On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall fix 
 it tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)



[web2py] Re: MongoDB Adapter error in select

2012-05-12 Thread Francisco Costa
It works Massimo!
In MongoDb is also common to insert dicts, can we also have that?

At the moment it only saves in the string format (check player Field)
{ _id : ObjectId(4fae3839b34f4brf5a31), city : Madrid, club : 
Real Madrid, *player : {'n_goals': 43, 'name': 'Ronaldo'}* }



On Friday, May 11, 2012 9:16:58 PM UTC+1, Massimo Di Pierro wrote:

 One more try please.

 On Friday, 11 May 2012 06:04:52 UTC-5, Francisco Costa wrote:

 Thanks Massimo. Please let me know if you need more help in debugging it

 On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall fix 
 it tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)



[web2py] Re: MongoDB Adapter error in select

2012-05-11 Thread Francisco Costa
Thanks Massimo. Please let me know if you need more help in debugging it

On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall fix it 
 tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)



[web2py] Re: MongoDB Adapter error in select

2012-05-11 Thread Francisco Costa
the latest DAL produces this error

users = mongo(mongo.user.age==18).select()
  File /opt/web2py/gluon/dal.py, line 8004, in select
return adapter.select(self.query,fields,attributes)
  File /opt/web2py/gluon/dal.py, line 4528, in select
colnames = [fix(column) for column in mongo_list_dicts[0]]
  File 
/usr/local/lib/python2.7/dist-packages/pymongo-2.1.1-py2.7-linux-x86_64.egg/pymongo/cursor.py,
 line 402, in __getitem__
raise IndexError(no such item for Cursor instance)
IndexError: no such item for Cursor instance




On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall fix it 
 tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)




 On Thursday, May 10, 2012 11:58:36 PM UTC+1, Massimo Di Pierro wrote:

 What's the model?

 On Thursday, 10 May 2012 16:27:51 UTC-5, Francisco Costa wrote:

 I found another problem!!

 if you do this:
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)

 and then select
 users = mongo(mongo.user.age==18).select()

 you don't have the field city in one of the rows, so you get this 
 error:

 users = mongo(mongo.user.age==18).select()
   File /opt/web2py/gluon/dal.py, line 8123, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4700, in select
 return processor(rows,fields,colnames,False)
   File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Jack'



 On Thursday, May 10, 2012 10:16:32 PM UTC+1, Francisco Costa wrote:

 Just add a '\' at the end of line 4664 and your are done!

 Great job Massimo!


 On Thursday, May 10, 2012 9:12:48 PM UTC+1, Massimo Di Pierro wrote:

 This helps. I have another attempt to fix this in trunk. Hard to test 
 it since I do not have mongodb installed.

 On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-11 Thread Massimo Di Pierro
One more try please.

On Friday, 11 May 2012 06:04:52 UTC-5, Francisco Costa wrote:

 Thanks Massimo. Please let me know if you need more help in debugging it

 On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote:

 Now I understand better where all these problems come from. I shall fix 
 it tonight.

 On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)



[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread kokoyo
Hi Massimo, i did it and get output (test on user_auth table):

mongoqry_dict ={'email': 'myem...@gmail.com'}
mongofields_dict = SON([('id':1), ('first_name':1),  ('last_name':
1),  ('email':1), ('password':1), ('registration_key':
1), ('reset_password_key':1), ('registration_id':1) ])
mongo_list_dicts = pymongo.cursor.Cursor object at 9a809aa



On Thursday, May 10, 2012 1:52:02 PM UTC+9, Massimo Di Pierro wrote:

 Should be an easy fix but I need your help. Before line 4711 of dal.py

 return processor(rows,fields,colnames,False)

 can you add

 print rows
 print fields
 print colnames

 what is the output when it fails?


 On Wednesday, 9 May 2012 05:42:56 UTC-5, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field

 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in 
 trunk that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in 
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return 
 the 
 columns in the order web2py think it does. Can you print the input of 
 the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 

Re: [web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Francisco Costa
I've enumerated fields and colnames and they are like this:

fields:
id
text
integer
string


colnames:
city
age
_id
name


 I believe they don't match and thats why there's this error:


File /opt/web2py/gluon/dal.py, line 8134, in select
return adapter.select(self.query,fields,attributes)
File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
File /opt/web2py/gluon/dal.py, line 1681, in parse
self.parse_value(value, fields[j].type,blob_decode)
File /opt/web2py/gluon/dal.py, line 1575, in parse_value
return self.parsemap[key](value,field


_type)
  File /opt/web2py/gluon/dal.py, line 1641, in parse_id

return int(value)
ValueError: invalid literal for int() with base 10: 'Toronto'




Francisco Costa
http://franciscocosta.com



On Thu, May 10, 2012 at 7:03 AM, kokoyo hoatre2...@gmail.com wrote:

 Hi Massimo, i did it and get output (test on user_auth table):

 mongoqry_dict ={'email': 'myem...@gmail.com'}
 mongofields_dict = SON([('id':1), ('first_name':1),  ('last_name':
 1),  ('email':1), ('password':1), ('registration_key':
 1), ('reset_password_key':1), ('registration_id':1) ])
 mongo_list_dicts = pymongo.cursor.Cursor object at 9a809aa



 On Thursday, May 10, 2012 1:52:02 PM UTC+9, Massimo Di Pierro wrote:

 Should be an easy fix but I need your help. Before line 4711 of dal.py

 return processor(rows,fields,**colnames,False)

 can you add

 print rows
 print fields
 print colnames

 what is the output when it fails?


 On Wednesday, 9 May 2012 05:42:56 UTC-5, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fiel**ds,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
  return processor(rows,fields,colnames**,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field


 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select

 return adapter.select(self.query,fiel**ds,attributes)

   File /opt/web2py/gluon/dal.py, line 4711, in select

 return processor(rows,columns,False)

   File /opt/web2py/gluon/dal.py, line 1675, in parse

 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in
 trunk that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the
 code in trunk. Anyway, something goes wrong in the parse(self, rows,
 fields, colnames, blob_decode=True) function. I suspect mongo does not
 return the columns in the order web2py think it does. Can you print the
 input of the parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:**27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).**select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and
 everything is correct:
  db.user.find()
 { _id : ObjectId(**4fa80feea34feb34f800), city :
 Toronto, age : NumberLong(66), name : John }
 { _id : ObjectId(**4fa80feea34feb34f801), city :
 Boston, age : NumberLong(43), name : Mark }
 { _id : ObjectId(**4fa80feea34feb34f802), city :
 Detroit, age 

[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Massimo Di Pierro
Please try trunk again.

On Thursday, 10 May 2012 01:03:22 UTC-5, kokoyo wrote:

 Hi Massimo, i did it and get output (test on user_auth table):

 mongoqry_dict ={'email': 'myem...@gmail.com'}
 mongofields_dict = SON([('id':1), ('first_name':1),  ('last_name':
 1),  ('email':1), ('password':1), ('registration_key':
 1), ('reset_password_key':1), ('registration_id':1) ])
 mongo_list_dicts = pymongo.cursor.Cursor object at 9a809aa



 On Thursday, May 10, 2012 1:52:02 PM UTC+9, Massimo Di Pierro wrote:

 Should be an easy fix but I need your help. Before line 4711 of dal.py

 return processor(rows,fields,colnames,False)

 can you add

 print rows
 print fields
 print colnames

 what is the output when it fails?


 On Wednesday, 9 May 2012 05:42:56 UTC-5, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field

 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in 
 trunk that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in 
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the 
 code in trunk. Anyway, something goes wrong in the parse(self, rows, 
 fields, colnames, blob_decode=True) function. I suspect mongo does not 
 return the columns in the order web2py think it does. Can you print 
 the 
 input of the parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : 
 Toronto, age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : 
 Detroit, age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : 
 Detroit, age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return 

[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Francisco Costa
Still not working. I think Fields order is wrong.

At the end of the select() function I write this:

a = []
for f in fields:
a.append(f.type)
return dict(rows=rows, fields=a, colnames=colnames)

and I got this:

colnames:
city
age
_id
name
fields:
id
text
integer
string
rows:
Toronto
66L
24652490551171733682233802752L
John




[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Massimo Di Pierro
This helps. I have another attempt to fix this in trunk. Hard to test it 
since I do not have mongodb installed.

On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Francisco Costa
Just add a '\' at the end of line 4664 and your are done!

Great job Massimo!


On Thursday, May 10, 2012 9:12:48 PM UTC+1, Massimo Di Pierro wrote:

 This helps. I have another attempt to fix this in trunk. Hard to test it 
 since I do not have mongodb installed.

 On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Francisco Costa
I found another problem!!

if you do this:
mongo.user.insert(name='Jim',  age=18, city='Detroit')
mongo.user.insert(name='Jack', age=18)

and then select
users = mongo(mongo.user.age==18).select()

you don't have the field city in one of the rows, so you get this error:

users = mongo(mongo.user.age==18).select()
  File /opt/web2py/gluon/dal.py, line 8123, in select
return adapter.select(self.query,fields,attributes)
  File /opt/web2py/gluon/dal.py, line 4700, in select
return processor(rows,fields,colnames,False)
  File /opt/web2py/gluon/dal.py, line 1681, in parse
self.parse_value(value, fields[j].type,blob_decode)
  File /opt/web2py/gluon/dal.py, line 1575, in parse_value
return self.parsemap[key](value,field_type)
  File /opt/web2py/gluon/dal.py, line 1641, in parse_id
return int(value)
ValueError: invalid literal for int() with base 10: 'Jack'



On Thursday, May 10, 2012 10:16:32 PM UTC+1, Francisco Costa wrote:

 Just add a '\' at the end of line 4664 and your are done!

 Great job Massimo!


 On Thursday, May 10, 2012 9:12:48 PM UTC+1, Massimo Di Pierro wrote:

 This helps. I have another attempt to fix this in trunk. Hard to test it 
 since I do not have mongodb installed.

 On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Massimo Di Pierro
What's the model?

On Thursday, 10 May 2012 16:27:51 UTC-5, Francisco Costa wrote:

 I found another problem!!

 if you do this:
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)

 and then select
 users = mongo(mongo.user.age==18).select()

 you don't have the field city in one of the rows, so you get this error:

 users = mongo(mongo.user.age==18).select()
   File /opt/web2py/gluon/dal.py, line 8123, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4700, in select
 return processor(rows,fields,colnames,False)
   File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Jack'



 On Thursday, May 10, 2012 10:16:32 PM UTC+1, Francisco Costa wrote:

 Just add a '\' at the end of line 4664 and your are done!

 Great job Massimo!


 On Thursday, May 10, 2012 9:12:48 PM UTC+1, Massimo Di Pierro wrote:

 This helps. I have another attempt to fix this in trunk. Hard to test it 
 since I do not have mongodb installed.

 On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Francisco Costa
i didn't understand your question..
This is the complete code

import sys
import time
from gluon.dal import DAL, Field
mongo = DAL('mongodb://localhost:27017/sapo')
mongo.define_table('user',
 Field('name', 'text'),
 Field('age',  'integer'),
 Field('city', 'string')
 )

def insert_users():
mongo.user.insert(name='John', age=66, city='Toronto')
mongo.user.insert(name='Mark', age=43, city='Boston')
mongo.user.insert(name='Tom',  age=43, city='Detroit')
mongo.user.insert(name='Jim',  age=18, city='Detroit')
mongo.user.insert(name='Jack', age=18)
mongo.user.insert(name='Eric', city='Boston')
return 'users in database'

def find_users():
users = mongo(mongo.user.age==18).select()
return dict(users=users)




On Thursday, May 10, 2012 11:58:36 PM UTC+1, Massimo Di Pierro wrote:

 What's the model?

 On Thursday, 10 May 2012 16:27:51 UTC-5, Francisco Costa wrote:

 I found another problem!!

 if you do this:
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)

 and then select
 users = mongo(mongo.user.age==18).select()

 you don't have the field city in one of the rows, so you get this error:

 users = mongo(mongo.user.age==18).select()
   File /opt/web2py/gluon/dal.py, line 8123, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4700, in select
 return processor(rows,fields,colnames,False)
   File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Jack'



 On Thursday, May 10, 2012 10:16:32 PM UTC+1, Francisco Costa wrote:

 Just add a '\' at the end of line 4664 and your are done!

 Great job Massimo!


 On Thursday, May 10, 2012 9:12:48 PM UTC+1, Massimo Di Pierro wrote:

 This helps. I have another attempt to fix this in trunk. Hard to test 
 it since I do not have mongodb installed.

 On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-10 Thread Massimo Di Pierro
Now I understand better where all these problems come from. I shall fix it 
tonight.

On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote:

 i didn't understand your question..
 This is the complete code

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/sapo')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==18).select()
 return dict(users=users)




 On Thursday, May 10, 2012 11:58:36 PM UTC+1, Massimo Di Pierro wrote:

 What's the model?

 On Thursday, 10 May 2012 16:27:51 UTC-5, Francisco Costa wrote:

 I found another problem!!

 if you do this:
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)

 and then select
 users = mongo(mongo.user.age==18).select()

 you don't have the field city in one of the rows, so you get this 
 error:

 users = mongo(mongo.user.age==18).select()
   File /opt/web2py/gluon/dal.py, line 8123, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4700, in select
 return processor(rows,fields,colnames,False)
   File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Jack'



 On Thursday, May 10, 2012 10:16:32 PM UTC+1, Francisco Costa wrote:

 Just add a '\' at the end of line 4664 and your are done!

 Great job Massimo!


 On Thursday, May 10, 2012 9:12:48 PM UTC+1, Massimo Di Pierro wrote:

 This helps. I have another attempt to fix this in trunk. Hard to test 
 it since I do not have mongodb installed.

 On Thursday, 10 May 2012 08:39:22 UTC-5, Francisco Costa wrote:

 Still not working. I think Fields order is wrong.

 At the end of the select() function I write this:

 a = []
 for f in fields:
 a.append(f.type)
 return dict(rows=rows, fields=a, colnames=colnames)

 and I got this:

 colnames:
 city
 age
 _id
 name
 fields:
 id
 text
 integer
 string
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John




[web2py] Re: MongoDB Adapter error in select

2012-05-09 Thread Francisco Costa
I've enumerated fields and colnames and they are like this:

fields:
id
text
integer
string


colnames:
city
age
_id
name


 I believe they don't match and thats why there's this error:

File /opt/web2py/gluon/dal.py, line 8134, in select
return adapter.select(self.query,fields,attributes)
File /opt/web2py/gluon/dal.py, line 4711, in select
return processor(rows,fields,colnames,False)
File /opt/web2py/gluon/dal.py, line 1681, in parse
self.parse_value(value, fields[j].type,blob_decode)
File /opt/web2py/gluon/dal.py, line 1575, in parse_value
return self.parsemap[key](value,field

_type)
  File /opt/web2py/gluon/dal.py, line 1641, in parse_id

return int(value)
ValueError: invalid literal for int() with base 10: 'Toronto'





On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in the 
 rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-09 Thread kokoyo
Hi  Costa , first im sorry for my wrong post above,It should be a new post 
with new question. Actually i have same problem like you, 
i did a quick test and have not solved this issue yet, here is what i did:

set driver to use mongodb in: DB.py :

if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
#db = DAL('sqlite://storage.sqlite')
db = DAL('mongodb://localhost:27017/foo') 


Click Register on menu to put a new User into mongo, submit:
type 'exceptions.ValueError' invalid literal for int() with base 10: '
koko'

Go to web2py appadmin admindatabase, open 
auth_userhttp://127.0.0.1:8000/test/appadmin/insert/db/auth_user
 table:
Invalid Query 
invalid literal for int() with base 10: 'koko' 


Use mongo console to run query :
db.auth_user.find({})

new user is alread inserted into db,-- insert is done.
but the error happens when mapping value and key or key type in DAL, im not 
sure, the type of value is not match. looks like DAL understands ID field 
is FirstName field.


   - 
   
   *File C:\w2py3\gluon\dal.py in parse_id at line 1641* code arguments 
   variables
   Function argument list
   
   (self=gluon.dal.MongoDBAdapter object, value='koko', field_type='id')
   Code listing
   
   1636.
   1637.
   1638.
   1639.
   1640.
   1641.
   
   1642.
   1643.
   1644.
   1645.
   
   if not self.dbengine=='google:datastore':
   value = bar_decode_string(value)
   return value
   
   def parse_id(self, value, field_type):
   return int(value)
   
   
   def parse_integer(self, value, field_type):
   return int(value)
   
   Variablesbuiltininttype 'int'value'koko'
   







On Wednesday, May 9, 2012 7:42:56 PM UTC+9, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field

 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in 
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return 
 the 
 columns in the order web2py think it does. Can you print the input of 
 the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), 

[web2py] Re: MongoDB Adapter error in select

2012-05-09 Thread Francisco Costa
Lets hope Massimo fix that today in trunk

On Wednesday, May 9, 2012 12:28:50 PM UTC+1, kokoyo wrote:

 Hi  Costa , first im sorry for my wrong post above,It should be a new 
 post with new question. Actually i have same problem like you, 
 i did a quick test and have not solved this issue yet, here is what i did:

 set driver to use mongodb in: DB.py :

 if not request.env.web2py_runtime_gae:
 ## if NOT running on Google App Engine use SQLite or other DB
 #db = DAL('sqlite://storage.sqlite')
 db = DAL('mongodb://localhost:27017/foo') 


 Click Register on menu to put a new User into mongo, submit:
 type 'exceptions.ValueError' invalid literal for int() with base 
 10: 'koko'

 Go to web2py appadmin admindatabase, open 
 auth_userhttp://127.0.0.1:8000/test/appadmin/insert/db/auth_user
  table:
 Invalid Query 
 invalid literal for int() with base 10: 'koko' 


 Use mongo console to run query :
 db.auth_user.find({})

 new user is alread inserted into db,-- insert is done.
 but the error happens when mapping value and key or key type in DAL, im not 
 sure, the type of value is not match. looks like DAL understands ID field 
 is FirstName field.


- 

*File C:\w2py3\gluon\dal.py in parse_id at line 1641* code arguments 
variables
Function argument list

(self=gluon.dal.MongoDBAdapter object, value='koko', field_type='id')
Code listing

1636.
1637.
1638.
1639.
1640.
1641.

1642.
1643.
1644.
1645.

if not self.dbengine=='google:datastore':
value = bar_decode_string(value)
return value

def parse_id(self, value, field_type):
return int(value)


def parse_integer(self, value, field_type):
return int(value)

Variablesbuiltininttype 'int'value'koko'








 On Wednesday, May 9, 2012 7:42:56 PM UTC+9, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field

 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in 
 trunk that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in 
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return 
 the 
 columns in the order web2py think it does. Can you print the input of 
 the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return 

[web2py] Re: MongoDB Adapter error in select

2012-05-09 Thread kokoyo
Seems DAL alway looks the first column if all tables is ID field   (after 
remove _id column from mongo)
{ _id : ObjectId(4de83c816afb62e8367163b1), first_name : koko, 
last_name:yo, password } *
*

On Wednesday, May 9, 2012 7:42:56 PM UTC+9, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field

 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in 
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return 
 the 
 columns in the order web2py think it does. Can you print the input of 
 the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-09 Thread Massimo Di Pierro
Should be an easy fix but I need your help. Before line 4711 of dal.py

return processor(rows,fields,colnames,False)

can you add

print rows
print fields
print colnames

what is the output when it fails?


On Wednesday, 9 May 2012 05:42:56 UTC-5, Francisco Costa wrote:

 I've enumerated fields and colnames and they are like this:

 fields:
 id
 text
 integer
 string


 colnames:
 city
 age
 _id
 name


  I believe they don't match and thats why there's this error:

 File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
 File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,fields,colnames,False)
 File /opt/web2py/gluon/dal.py, line 1681, in parse
 self.parse_value(value, fields[j].type,blob_decode)
 File /opt/web2py/gluon/dal.py, line 1575, in parse_value
 return self.parsemap[key](value,field

 _type)
   File /opt/web2py/gluon/dal.py, line 1641, in parse_id

 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'





 On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in 
 the rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return 
 the 
 columns in the order web2py think it does. Can you print the input of 
 the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-08 Thread Francisco Costa
Now i get this error:


  File /opt/web2py/gluon/dal.py, line 8134, in select
return adapter.select(self.query,fields,attributes)
  File /opt/web2py/gluon/dal.py, line 4711, in select
return processor(rows,fields,colnames,False)
  File /opt/web2py/gluon/dal.py, line 1681, in parse
self.parse_value(value, fields[j].type,blob_decode)
  File /opt/web2py/gluon/dal.py, line 1575, in parse_value
return self.parsemap[key](value,field_type)
  File /opt/web2py/gluon/dal.py, line 1641, in parse_id
return int(value)
ValueError: invalid literal for int() with base 10: 'Toronto'


Return in this order:


colnames:
city
age
_id
name
fields:
gluon.dal.Field object at 0x24fe0d0
gluon.dal.Field object at 0x1b25790
gluon.dal.Field object at 0x186cbd0
gluon.dal.Field object at 0x24fe090
rows:
Toronto
66L
24652490551171733682233802752L
John

On Monday, May 7, 2012 11:40:36 PM UTC+1, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in the 
 rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-08 Thread kokoyo
Hello, i got this error when tried pymongo and web2py:
On Linux:
type 'exceptions.ImportError' cannot import name son
.

rows = self.dbset(field == value, ignore_common_filters = 
self.ignore_common_filters).select(limitby=(0, 1))
  File /home/kokoyo/webapps/w2p/web2py/gluon/dal.py, line 8134, in select
return adapter.select(self.query,fields,attributes)
  File /home/kokoyo/webapps/w2p/web2py/gluon/dal.py, line 4675, in select
tablename, mongoqry_dict , mongofields_dict, mongosort_list, limitby_limit, 
limitby_skip = self._select(query,fields,attributes)
  File /home/kokoyo/webapps/w2p/web2py/gluon/dal.py, line 4611, in _select
from pymongo import son
ImportError: cannot import name son

Code listing

4606.
4607.
4608.
4609.
4610.
4611.

4612.
4613.
4614.
4615.

return ','.join(self.represent(item,field_type) for item in 
expression)
else:
return expression

def _select(self,query,fields,attributes):
from pymongo import son


for key in set(attributes.keys())-set(('limitby','orderby')):
raise SyntaxError, 'invalid select attribute: %s' % key

But its OK on Windows.
googling and found this: 
https://github.com/mongodb/mongo-snippets/blob/master/sharding/simple-setup.py

try:
# new pymongo
from bson.son import SON
except ImportError:
# old pymongo
from pymongo.son import SON


tried on Linux:

from bson.son import SON 
from pymongo.son import SON 

no error.
i dont know why  from pymongo import son 
does not work on Linux. any idea?


On Tuesday, May 8, 2012 7:40:36 AM UTC+9, Massimo Di Pierro wrote:

 Please try again.

 On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in the 
 rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code 
 in trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return 

[web2py] Re: MongoDB Adapter error in select

2012-05-07 Thread Massimo Di Pierro
Your linennumbers do not much the code in trunk. Please try the code in 
trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
colnames, blob_decode=True) function. I suspect mongo does not return the 
columns in the order web2py think it does. Can you print the input of the 
parse function?

On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and everything 
 is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, age 
 : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, age : 
 NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, age 
 : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, age 
 : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : NumberLong(18), 
 name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, name 
 : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-07 Thread Francisco Costa
I think that the mongofields_dict.keys() don't match to the data in the rows

mongofields_dict:
id
name
age
city
rows:
Toronto
66L
24652490551171733682233802752L
John


On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code in 
 trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, age 
 : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, age 
 : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, age 
 : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, age 
 : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : NumberLong(18), 
 name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, name 
 : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-07 Thread Massimo Di Pierro
Thanks for your help and check on this. I just committed a fix in trunk 
that should address it. Please let me know.

On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in the 
 rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code in 
 trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, age 
 : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : NumberLong(18), 
 name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-07 Thread Francisco Costa
missing a colon at the end of the line 4677

if key == 'id'


and now I get this error

  File /opt/web2py/gluon/dal.py, line 8134, in select
return adapter.select(self.query,fields,attributes)
  File /opt/web2py/gluon/dal.py, line 4711, in select
return processor(rows,columns,False)
  File /opt/web2py/gluon/dal.py, line 1675, in parse
for j,colname in enumerate(colnames):
TypeError: 'bool' object is not iterable


maybe because of the False on line 4711




On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in the 
 rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code in 
 trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : NumberLong(18), 
 name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'




[web2py] Re: MongoDB Adapter error in select

2012-05-07 Thread Massimo Di Pierro
Please try again.

On Monday, 7 May 2012 15:48:04 UTC-5, Francisco Costa wrote:

 missing a colon at the end of the line 4677

 if key == 'id'


 and now I get this error

   File /opt/web2py/gluon/dal.py, line 8134, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4711, in select
 return processor(rows,columns,False)
   File /opt/web2py/gluon/dal.py, line 1675, in parse
 for j,colname in enumerate(colnames):
 TypeError: 'bool' object is not iterable


 maybe because of the False on line 4711




 On Monday, May 7, 2012 9:27:35 PM UTC+1, Massimo Di Pierro wrote:

 Thanks for your help and check on this. I just committed a fix in trunk 
 that should address it. Please let me know.

 On Monday, 7 May 2012 15:19:40 UTC-5, Francisco Costa wrote:

 I think that the mongofields_dict.keys() don't match to the data in the 
 rows

 mongofields_dict:
 id
 name
 age
 city
 rows:
 Toronto
 66L
 24652490551171733682233802752L
 John


 On Monday, May 7, 2012 8:42:33 PM UTC+1, Massimo Di Pierro wrote:

 Your linennumbers do not much the code in trunk. Please try the code in 
 trunk. Anyway, something goes wrong in the parse(self, rows, fields, 
 colnames, blob_decode=True) function. I suspect mongo does not return the 
 columns in the order web2py think it does. Can you print the input of the 
 parse function?

 On Monday, 7 May 2012 13:20:39 UTC-5, Francisco Costa wrote:

 So I have this:

 import sys
 import time
 from gluon.dal import DAL, Field
 mongo = DAL('mongodb://localhost:27017/tymr')
 mongo.define_table('user',
  Field('name', 'text'),
  Field('age',  'integer'),
  Field('city', 'string')
  )

 def insert_users():
 mongo.user.insert(name='John', age=66, city='Toronto')
 mongo.user.insert(name='Mark', age=43, city='Boston')
 mongo.user.insert(name='Tom',  age=43, city='Detroit')
 mongo.user.insert(name='Jim',  age=18, city='Detroit')
 mongo.user.insert(name='Jack', age=18)
 mongo.user.insert(name='Eric', city='Boston')
 return 'users in database'

 def find_users():
 users = mongo(mongo.user.age==66).select()
 return dict(users=users)


 after I run *insert_users* I check in MongoDb via terminal and 
 everything is correct:
  db.user.find()
 { _id : ObjectId(4fa80feea34feb34f800), city : Toronto, 
 age : NumberLong(66), name : John }
 { _id : ObjectId(4fa80feea34feb34f801), city : Boston, 
 age : NumberLong(43), name : Mark }
 { _id : ObjectId(4fa80feea34feb34f802), city : Detroit, 
 age : NumberLong(43), name : Tom }
 { _id : ObjectId(4fa80feea34feb34f803), city : Detroit, 
 age : NumberLong(18), name : Jim }
 { _id : ObjectId(4fa80feea34feb34f804), age : 
 NumberLong(18), name : Jack }
 { _id : ObjectId(4fa80feea34feb34f805), city : Boston, 
 name : Eric }

 but when I run *find_users* I get this error:

   File /opt/web2py/gluon/dal.py, line 7578, in select
 return adapter.select(self.query,fields,attributes)
   File /opt/web2py/gluon/dal.py, line 4290, in select
 return self.parse(rows,fields,mongofields_dict.keys(),False)
   File /opt/web2py/gluon/dal.py, line 1600, in parse
 self.parse_value(value, fields[j].type,blob_decode)
   File /opt/web2py/gluon/dal.py, line 1496, in parse_value
 return self.parsemap[key](value,field_type)
   File /opt/web2py/gluon/dal.py, line 1562, in parse_id
 return int(value)
 ValueError: invalid literal for int() with base 10: 'Toronto'