[web2py] Error writing an auth_event

2012-02-02 Thread pbreit
My code is erroring and it looks like the culprit is the logging of an 
auth_event. It's happening on a lightly customized auth_user Profile update.



Traceback (most recent call last):
  File /opt/web2py/gluon/restricted.py, line 204, in restricted
exec ccode in environment
  File /opt/web2py/applications/init/controllers/default.py 
https://pricetack.com/admin/edit/init/controllers/default.py, line 133, in 
module
  File /opt/web2py/gluon/globals.py, line 172, in lambda
self._caller = lambda f: f()
  File /opt/web2py/applications/init/controllers/default.py 
https://pricetack.com/admin/edit/init/controllers/default.py, line 85, in user
form = auth()
  File /opt/web2py/gluon/tools.py, line 1159, in __call__
return getattr(self,args[0])()
  File /opt/web2py/gluon/tools.py, line 2431, in profile
onvalidation=onvalidation, hideerror=self.settings.hideerror):
  File /opt/web2py/gluon/sqlhtml.py, line 1088, in accepts
hideerror=hideerror,
  File /opt/web2py/gluon/html.py, line 1807, in accepts
status = self._traverse(status,hideerror)
  File /opt/web2py/gluon/html.py, line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /opt/web2py/gluon/html.py, line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /opt/web2py/gluon/html.py, line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /opt/web2py/gluon/html.py, line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File /opt/web2py/gluon/html.py, line 756, in _traverse
newstatus = self._validate()
  File /opt/web2py/gluon/html.py, line 1572, in _validate
(value, errors) = validator(value)
  File /opt/web2py/gluon/validators.py, line 549, in __call__
elif str(rows[0]._id) != str(self.record_id):
  File /opt/web2py/gluon/dal.py, line 5459, in __getattr__
return self[key]
  File /opt/web2py/gluon/dal.py, line 5450, in __getitem__
return dict.__getitem__(self, key)
KeyError: '_id'



Function argument list

(self=Row {'auth_event': gluon.dal.Set object at 0x2...embership': 
gluon.dal.Set object at 0x2207210}, key='_id')
Code listing

5445.
5446.
5447.
5448.
5449.
5450.

5451.
5452.
5453.
5454.

elif m:
try:
return dict.__getitem__(self, m.group(1))[m.group(2)]
except (KeyError,TypeError):
key = m.group(2)
return dict.__getitem__(self, key)


def __call__(self,key):
return self.__getitem__(key)

VariablesselfRow {'auth_event': gluon.dal.Set object at 0x2...embership': 
gluon.dal.Set object at 0x2207210}dict.__getitem__method '__getitem__' 
of 'dict' objectsbuiltindicttype 'dict'key'_id'


Re: [web2py] Error writing an auth_event

2012-02-02 Thread Carlos Costa
Hard to guess withou the model, but looks like its related to the
membership.

2012/2/2 pbreit pbreitenb...@gmail.com

 My code is erroring and it looks like the culprit is the logging of an
 auth_event. It's happening on a lightly customized auth_user Profile update.



 Traceback (most recent call last):
   File /opt/web2py/gluon/restricted.py, line 204, in restricted
 exec ccode in environment
   File /opt/web2py/applications/init/controllers/default.py 
 https://pricetack.com/admin/edit/init/controllers/default.py, line 133, in 
 module
   File /opt/web2py/gluon/globals.py, line 172, in lambda
 self._caller = lambda f: f()
   File /opt/web2py/applications/init/controllers/default.py 
 https://pricetack.com/admin/edit/init/controllers/default.py, line 85, in 
 user
 form = auth()
   File /opt/web2py/gluon/tools.py, line 1159, in __call__
 return getattr(self,args[0])()
   File /opt/web2py/gluon/tools.py, line 2431, in profile
 onvalidation=onvalidation, hideerror=self.settings.hideerror):
   File /opt/web2py/gluon/sqlhtml.py, line 1088, in accepts
 hideerror=hideerror,
   File /opt/web2py/gluon/html.py, line 1807, in accepts
 status = self._traverse(status,hideerror)
   File /opt/web2py/gluon/html.py, line 749, in _traverse
 newstatus = c._traverse(status,hideerror) and newstatus
   File /opt/web2py/gluon/html.py, line 749, in _traverse
 newstatus = c._traverse(status,hideerror) and newstatus
   File /opt/web2py/gluon/html.py, line 749, in _traverse
 newstatus = c._traverse(status,hideerror) and newstatus
   File /opt/web2py/gluon/html.py, line 749, in _traverse
 newstatus = c._traverse(status,hideerror) and newstatus
   File /opt/web2py/gluon/html.py, line 756, in _traverse
 newstatus = self._validate()
   File /opt/web2py/gluon/html.py, line 1572, in _validate
 (value, errors) = validator(value)
   File /opt/web2py/gluon/validators.py, line 549, in __call__
 elif str(rows[0]._id) != str(self.record_id):
   File /opt/web2py/gluon/dal.py, line 5459, in __getattr__
 return self[key]
   File /opt/web2py/gluon/dal.py, line 5450, in __getitem__
 return dict.__getitem__(self, key)
 KeyError: '_id'



 Function argument list

 (self=Row {'auth_event': gluon.dal.Set object at 0x2...embership':
 gluon.dal.Set object at 0x2207210}, key='_id')
 Code listing

 5445.
 5446.
 5447.
 5448.
 5449.
 5450.

 5451.
 5452.
 5453.
 5454.

 elif m:
 try:
 return dict.__getitem__(self, m.group(1))[m.group(2)]
 except (KeyError,TypeError):
 key = m.group(2)
 return dict.__getitem__(self, key)


 def __call__(self,key):
 return self.__getitem__(key)

 VariablesselfRow {'auth_event': gluon.dal.Set object at
 0x2...embership': gluon.dal.Set object at 0x2207210}dict.__getitem__method
 '__getitem__' of 'dict' objectsbuiltindicttype 'dict'key'_id'




-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


Re: [web2py] Error writing an auth_event

2012-02-02 Thread pbreit
I'm not really using memberships and I have auto group creation turned off:

auth.settings.create_user_groups = False

It works OK in my dev environment so it has something to do with my 
production data.

One thing I noticed is that it looks like it might be trying to validate 
NOT_IN_DB. Since it's a Profile update, it should certainly account for the 
current auth_user's email already being in the DB.



*File /opt/web2py/gluon/validators.py in __call__ at line 549* code 
arguments variables
Function argument list

(self=gluon.validators.IS_NOT_IN_DB object, value='pb@com')
Code listing

544.
545.
546.
547.
548.
549.

550.
551.
552.
553.

if len(rows)  0:
if isinstance(self.record_id, dict):
for f in self.record_id:
if str(getattr(rows[0], f)) != str(self.record_id[f]):
return (value, translate(self.error_message))
elif str(rows[0]._id) != str(self.record_id):

return (value, translate(self.error_message))
return (value, None)



Re: [web2py] Error writing an auth_event

2012-02-02 Thread Carlos Costa
Looking the code above, elif is hit when len(rows) = 0.
So I am stuck here, how could it retrive any value if the lenght is zero?
Must look this whole code to understand it.

2012/2/2 pbreit pbreitenb...@gmail.com

 I'm not really using memberships and I have auto group creation turned off:

 auth.settings.create_user_groups = False

 It works OK in my dev environment so it has something to do with my
 production data.

 One thing I noticed is that it looks like it might be trying to validate
 NOT_IN_DB. Since it's a Profile update, it should certainly account for the
 current auth_user's email already being in the DB.



 *File /opt/web2py/gluon/validators.py in __call__ at line 549* code
 arguments variables
 Function argument list

 (self=gluon.validators.IS_NOT_IN_DB object, value='pb@com')
 Code listing

 544.
 545.
 546.
 547.
 548.
 549.

 550.
 551.
 552.
 553.

 if len(rows)  0:
 if isinstance(self.record_id, dict):
 for f in self.record_id:
 if str(getattr(rows[0], f)) != str(self.record_id[f]):
 return (value, translate(self.error_message))

 elif str(rows[0]._id) != str(self.record_id):

 return (value, translate(self.error_message))
 return (value, None)




-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


Re: [web2py] Error writing an auth_event

2012-02-02 Thread pbreit
I moved form = auth() to the top of the function which seems to have 
fixed it (I have some other code in the user() function that required me to 
create the form before the return).