The problem is that dal+mongo does not handle references right because of 
this. It must be refactored.

On Tuesday, 23 October 2012 12:27:56 UTC-5, Adi wrote:
>
> my fault.... Niphlod clarified that can't use mongodb for Auth 
> functionality, so I left that part with mysql, otherwise created table 
> (colletion), inserted records and displayed smartgrid. All worked fine, 
> except viewing record details from smartgrid. 
>
>  1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
>
> Traceback (most recent call last):
>   File "/Users/adnan/web2py209/gluon/restricted.py", line 212, in restricted
>     exec ccode in environment
>   File "/Users/adnan/web2py209/applications/mango/controllers/test.py" 
> <http://127.0.0.1:8000/admin/default/edit/mango/controllers/test.py>, line 
> 13, in <module>
>   File "/Users/adnan/web2py209/gluon/globals.py", line 188, in <lambda>
>     self._caller = lambda f: f()
>   File "/Users/adnan/web2py209/applications/mango/controllers/test.py" 
> <http://127.0.0.1:8000/admin/default/edit/mango/controllers/test.py>, line 9, 
> in test
>     grid=SQLFORM.smartgrid(db_m.post)
>   File "/Users/adnan/web2py209/gluon/sqlhtml.py", line 2376, in smartgrid
>     user_signature=user_signature, **kwargs)
>   File "/Users/adnan/web2py209/gluon/sqlhtml.py", line 1853, in grid
>     record = table(request.args[-1]) or redirect(URL('error'))
>   File "/Users/adnan/web2py209/gluon/dal.py", line 7650, in __call__
>     limitby=(0,1),for_update=for_update).first()
>   File "/Users/adnan/web2py209/gluon/dal.py", line 8788, in select
>     return adapter.select(self.query,fields,attributes)
>   File "/Users/adnan/web2py209/gluon/dal.py", line 5077, in select
>     self._select(query,fields,attributes)
>   File "/Users/adnan/web2py209/gluon/dal.py", line 5061, in _select
>     mongoqry_dict = self.expand(query)
>   File "/Users/adnan/web2py209/gluon/dal.py", line 4985, in expand
>     raise SyntaxError, 'second argument must be of type ObjectId or an 
> objectid representable integer'
> SyntaxError: second argument must be of type ObjectId or an objectid 
> representable integer
>
>
>
>
>
>
> On Tuesday, October 23, 2012 8:47:14 AM UTC-4, Adi wrote:
>>
>> Installed mongodb, pymongo driver from source on mac osx 10.7.5, and 
>> created a fresh application. Tried to create a new user from admin panel, 
>> and got first error bellow. Record got inserted though. After I used option 
>> "Lost password" from the menu, got second error underneath. 
>>
>> <type 'exceptions.OverflowError'> BSON can only handle up to 8-byte ints
>>
>> Traceback (most recent call last):
>>   File "/Users/adnan/web2py209/gluon/restricted.py", line 212, in restricted
>>     exec ccode in environment
>>   File "/Users/adnan/web2py209/applications/mango/controllers/default.py" 
>> <http://127.0.0.1:8000/admin/default/edit/mango/controllers/default.py>, 
>> line 77, in <module>
>>   File "/Users/adnan/web2py209/gluon/globals.py", line 188, in <lambda>
>>     self._caller = lambda f: f()
>>   File "/Users/adnan/web2py209/applications/mango/controllers/default.py" 
>> <http://127.0.0.1:8000/admin/default/edit/mango/controllers/default.py>, 
>> line 39, in user
>>     return dict(form=auth())
>>   File "/Users/adnan/web2py209/gluon/tools.py", line 1235, in __call__
>>     return getattr(self, args[0])()
>>   File "/Users/adnan/web2py209/gluon/tools.py", line 2241, in register
>>     self.add_membership(group_id, form.vars.id)
>>   File "/Users/adnan/web2py209/gluon/tools.py", line 3035, in add_membership
>>     record = membership(user_id=user_id, group_id=group_id)
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 7657, in __call__
>>     return 
>> self._db(query).select(limitby=(0,1),for_update=for_update).first()
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 8788, in select
>>     return adapter.select(self.query,fields,attributes)
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 5093, in select
>>     for k,record in enumerate(mongo_list_dicts):
>>   File "build/bdist.macosx-10.7-intel/egg/pymongo/cursor.py", line 799, in 
>> next
>>     if len(self.__data) or self._refresh():
>>   File "build/bdist.macosx-10.7-intel/egg/pymongo/cursor.py", line 750, in 
>> _refresh
>>     self.__uuid_subtype))
>>   File "build/bdist.macosx-10.7-intel/egg/pymongo/message.py", line 134, in 
>> query
>>     encoded = bson.BSON.encode(query, False, uuid_subtype)
>>   File "build/bdist.macosx-10.7-intel/egg/bson/__init__.py", line 566, in 
>> encode
>>     return cls(_dict_to_bson(document, check_keys, uuid_subtype))
>>   File "build/bdist.macosx-10.7-intel/egg/bson/__init__.py", line 475, in 
>> _dict_to_bson
>>     elements.append(_element_to_bson(key, value, check_keys, uuid_subtype))
>>   File "build/bdist.macosx-10.7-intel/egg/bson/__init__.py", line 426, in 
>> _element_to_bson
>>     raise OverflowError("BSON can only handle up to 8-byte ints")
>> OverflowError: BSON can only handle up to 8-byte ints
>>
>>
>> Frames 
>>    
>>    -  
>>    
>>    *File /Users/adnan/web2py209/gluon/restricted.py in restricted at 
>>    line 212* code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/applications/mango/controllers/default.py in 
>>    <module> at line 77* code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/globals.py in <lambda> at line 188* 
>>    code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/applications/mango/controllers/default.py in user 
>> at 
>>    line 39* code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/tools.py in __call__ at line 1235* 
>>    code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/tools.py in register at line 2241* 
>>    code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/tools.py in add_membership at line 
>>    3035* code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in __call__ at line 7657* 
>>    code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in select at line 8788* code 
>>    arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in select at line 5093* code 
>>    arguments variables 
>>     -  
>>    
>>    *File 
>>    
>> /Users/adnan/web2py209/build/bdist.macosx-10.7-intel/egg/pymongo/cursor.py 
>>    in next at line 799* code arguments variables 
>>     -  
>>    
>>    *File 
>>    
>> /Users/adnan/web2py209/build/bdist.macosx-10.7-intel/egg/pymongo/cursor.py 
>>    in _refresh at line 750* code arguments variables 
>>     -  
>>    
>>    *File 
>>    
>> /Users/adnan/web2py209/build/bdist.macosx-10.7-intel/egg/pymongo/message.py 
>>    in query at line 134* code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/build/bdist.macosx-10.7-intel/egg/bson/__init__.py 
>>    in encode at line 566* code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/build/bdist.macosx-10.7-intel/egg/bson/__init__.py 
>>    in _dict_to_bson at line 475* code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/build/bdist.macosx-10.7-intel/egg/bson/__init__.py 
>>    in _element_to_bson at line 426* code arguments variables 
>>     Function argument list 
>>    
>>    (key='group_id', value=24921443489256489473621663847L, 
>>    check_keys=False, uuid_subtype=3)
>>     Code listing 
>>    
>>    421.
>>    422.
>>    423.
>>    424.
>>    425.
>>    426.
>>    
>>    427.
>>    428.
>>    429.
>>    430.
>>    
>>            return BSONINT + name + struct.pack("<i", value)
>>        # 2to3 will convert long to int here since there is no long in 
>> python3.
>>        # That's OK. The previous if block will match instead.
>>        if isinstance(value, long):
>>            if value > MAX_INT64 or value < MIN_INT64:
>>                raise OverflowError("BSON can only handle up to 8-byte ints")
>>    
>>            return BSONLON + name + struct.pack("<q", value)
>>        if isinstance(value, datetime.datetime):
>>            if value.utcoffset() is not None:
>>                value = value - value.utcoffset()
>>    
>>    
>>
>>
>>
>>
>>
>> <type 'exceptions.SyntaxError'> second argument must be of type ObjectId 
>> or an objectid representable integer
>>
>> Traceback (most recent call last):
>>   File "/Users/adnan/web2py209/gluon/restricted.py", line 212, in restricted
>>     exec ccode in environment
>>   File "/Users/adnan/web2py209/applications/mango/controllers/appadmin.py" 
>> <http://127.0.0.1:8000/admin/default/edit/mango/controllers/appadmin.py>, 
>> line 463, in <module>
>>   File "/Users/adnan/web2py209/gluon/globals.py", line 188, in <lambda>
>>     self._caller = lambda f: f()
>>   File "/Users/adnan/web2py209/applications/mango/controllers/appadmin.py" 
>> <http://127.0.0.1:8000/admin/default/edit/mango/controllers/appadmin.py>, 
>> line 280, in update
>>     2), ignore_common_filters=True).select().first()
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 8788, in select
>>     return adapter.select(self.query,fields,attributes)
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 5077, in select
>>     self._select(query,fields,attributes)
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 5061, in _select
>>     mongoqry_dict = self.expand(query)
>>   File "/Users/adnan/web2py209/gluon/dal.py", line 4985, in expand
>>     raise SyntaxError, 'second argument must be of type ObjectId or an 
>> objectid representable integer'
>> SyntaxError: second argument must be of type ObjectId or an objectid 
>> representable integer
>>
>>
>>    -  
>>    
>>    *File /Users/adnan/web2py209/gluon/restricted.py in restricted at 
>>    line 212* code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/applications/mango/controllers/appadmin.py in 
>>    <module> at line 463* code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/globals.py in <lambda> at line 188* 
>>    code arguments variables 
>>     -  
>>    
>>    *File 
>>    /Users/adnan/web2py209/applications/mango/controllers/appadmin.py in 
>> update 
>>    at line 280* code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in select at line 8788* code 
>>    arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in select at line 5077* code 
>>    arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in _select at line 5061* 
>>    code arguments variables 
>>     -  
>>    
>>    *File /Users/adnan/web2py209/gluon/dal.py in expand at line 4985* code 
>>    arguments variables 
>>     Function argument list 
>>    
>>    (self=<gluon.dal.MongoDBAdapter object>, expression=<Query {'_id': 
>>    '24921443470809745399912112230'}>, field_type=None)
>>     Code listing 
>>    
>>    4980.
>>    4981.
>>    4982.
>>    4983.
>>    4984.
>>    4985.
>>    
>>    4986.
>>    4987.
>>    4988.
>>    4989.
>>    
>>                        else:
>>                            try:
>>                                #But a direct id is also possible
>>                                expression.second = 
>> ObjectId(expression.second)
>>                            except:
>>                                raise SyntaxError, 'second argument must be 
>> of type ObjectId or an objectid representable integer'
>>    
>>                    elif expression.second == 0:
>>                        expression.second = 
>> ObjectId('000000000000000000000000')
>>                    return expression.op(expression.first, expression.second)
>>            if isinstance(expression, Field):
>>    
>>    
>>

-- 



Reply via email to