Re: [web2py] hidden fields ignored in form=crud.update()?

2012-11-24 Thread Annet
Hi Marco,

Thanks for your reply.


This line here: 
>
> ('ERROR','23502', 'null value in column "aboutid" violates not-null 
> constraint') 
>
> it seems that you have set a validator to one of the hidden fields, and 
> since it doesn't seem to a have a default value either, then it's value 
> on submit is null and therefore rejected
>


You're right, I have a validator that validates the combination of nodeID 
and aboutID, both fields are readable/writable False. My first problem was 
the validator not validating, this was solved by setting 
hidden=dict(nodeID=id,aboutID=HOMEABOUTID). The second problem was the one 
described above. Based on your answer: db.aboutText.nodeID.default=id 
db.aboutText.aboutID.default=HOMEABOUTID solved the problem.

Kind regards,

Annet

-- 





Re: [web2py] hidden fields ignored in form=crud.update()?

2012-11-23 Thread Marco Mansilla
This line here:

('ERROR','23502', 'null value in column "aboutid" violates not-null constraint')

it seems that you have set a validator to one of the hidden fields, and
since it doesn't seem to a have a default value either, then it's value
on submit is null and therefore rejected... could you show the table
definition?

> In a function I have the following line of code:
> 
> form=crud.update(table=db.aboutText,hidden=dict(nodeID=id,aboutID=HOMEABOUTID),record=row,next=session.crud_next,deletable=True)
> 
> In the view the hidden fields are rendered correctly:
> 
> 
> 
> 
> When I submit the form I get the following error:
> 
> Ticket ID 
> 
> 127.0.0.1.2012-11-22.16-10-08.6c149a65-a3aa-43b5-b417-a44fe61ce122
>  ('ERROR',
> '23502', 'null value in column "aboutid" violates not-null
> constraint') Version web2py™ (2, 2, 1, datetime.datetime(2012, 10,
> 21, 16, 57, 4), 'stable') Python Python 2.7.1: 
> /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>   
> Traceback 
> 
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 
> Traceback (most recent call last):
>   File "/Users/annet/web2py/gluon/restricted.py", line 212, in
> restricted exec ccode in environment
>   File "/Users/annet/web2py/applications/init/controllers/cmssite.py"
> , line
> 417, in  File "/Users/annet/web2py/gluon/globals.py", line
> 188, in  self._caller = lambda f: f() File
> "/Users/annet/web2py/gluon/tools.py", line 2912, in f return
> action(*a, **b) File
> "/Users/annet/web2py/applications/init/controllers/cmssite.py"
> , line
> 239, in homePage
> form=crud.update(table=db.aboutText,hidden=dict(nodeID=id,aboutID=HOMEABOUTID),record=row,next=session.crud_next,deletable=True)
> File "/Users/annet/web2py/gluon/tools.py", line 3511, in update
> detect_record_change=self.settings.detect_record_change): File
> "/Users/annet/web2py/gluon/sqlhtml.py", line 1475, in accepts
> self.vars.id = self.table.insert(**fields) File
> "/Users/annet/web2py/gluon/dal.py", line 7806, in insert ret =
> self._db._adapter.insert(self,self._listify(fields)) File
> "/Users/annet/web2py/gluon/dal.py", line 1161, in insert raise e
> ProgrammingError: ('ERROR', '23502', 'null value in column "aboutid"
> violates not-null constraint')
> 
>  Error snapshot [image: help]  
> 
> (('ERROR',
> '23502', 'null value in column "aboutid" violates not-null
> constraint')) 
> 
> inspect attributes 
>  Frames 
>
>-  
>
>*File /Users/annet/web2py/gluon/restricted.py in restricted at
> line 212* code arguments variables 
> -  
>
>*File /Users/annet/web2py/applications/init/controllers/cmssite.py
> in  at line 417* code arguments variables 
> -  
>
>*File /Users/annet/web2py/gluon/globals.py in  at line
> 188* code arguments variables 
> -  
>
>*File /Users/annet/web2py/gluon/tools.py in f at line 2912* code 
>arguments variables 
> -  
>
>*File /Users/annet/web2py/applications/init/controllers/cmssite.py
> in homePage at line 239* code arguments variables 
> -  
>
>*File /Users/annet/web2py/gluon/tools.py in update at line 3511*
> code arguments variables 
> -  
>
>*File /Users/annet/web2py/gluon/sqlhtml.py in accepts at line
> 1475* code arguments variables 
> -  
>
>*File /Users/annet/web2py/gluon/dal.py in insert at line 7806*
> code arguments variables 
> -  
>
>*File /Users/annet/web2py/gluon/dal.py in insert at line 1161*
> code arguments variables 
> Function argument list 
>
>(self=, table=(id,nodeID,aboutID,text,createdOn,modifiedOn)>,
> fields=[(object>, 'Iedereen is welkom bij het USC!object>is overal 
>een horecavoorziening aanwezig.'), (, 
>datetime.datetime(2012, 11, 22, 16, 10, 8, 432055)),
> (object>, datetime.datetime(2012, 11, 22, 16, 10, 8, 432055)), 
>(, ''), (, '')])
> Code listing 
>
>1156.
>1157.
>1158.
>1159.
>1160.
>1161.
>
>1162.
>1163.
>1164.
>1165.
>
>try:
>self.execute(query)
>except Exception, e:
>if isinstance(e,self.integrity_error_class()):
>return None
>raise e
>
>if hasattr(table,'_primarykey'):
>return dict([(k[0].name, k[1]) for k in fields \
> if k[0].name in table._primarykey])
>id = self.lastrowid(table)
>
> Variables  e ProgrammingError('ERROR', '23502', 'null value in
> column "aboutid" violates not-null constraint')
>
> 
> Why are the hidden fields ignored in form=crud.update(..)?
> 
> Kind regards,
> 
> Annet.
> 

-- 





[web2py] hidden fields ignored in form=crud.update()?

2012-11-22 Thread Annet
In a function I have the following line of code:

form=crud.update(table=db.aboutText,hidden=dict(nodeID=id,aboutID=HOMEABOUTID),record=row,next=session.crud_next,deletable=True)

In the view the hidden fields are rendered correctly:




When I submit the form I get the following error:

Ticket ID 

127.0.0.1.2012-11-22.16-10-08.6c149a65-a3aa-43b5-b417-a44fe61ce122
 ('ERROR', '23502', 
'null value in column "aboutid" violates not-null constraint') Version  
web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')  
Python Python 2.7.1: 
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
  
Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.

Traceback (most recent call last):
  File "/Users/annet/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "/Users/annet/web2py/applications/init/controllers/cmssite.py" 
, line 417, in 

  File "/Users/annet/web2py/gluon/globals.py", line 188, in 
self._caller = lambda f: f()
  File "/Users/annet/web2py/gluon/tools.py", line 2912, in f
return action(*a, **b)
  File "/Users/annet/web2py/applications/init/controllers/cmssite.py" 
, line 239, in 
homePage

form=crud.update(table=db.aboutText,hidden=dict(nodeID=id,aboutID=HOMEABOUTID),record=row,next=session.crud_next,deletable=True)
  File "/Users/annet/web2py/gluon/tools.py", line 3511, in update
detect_record_change=self.settings.detect_record_change):
  File "/Users/annet/web2py/gluon/sqlhtml.py", line 1475, in accepts
self.vars.id = self.table.insert(**fields)
  File "/Users/annet/web2py/gluon/dal.py", line 7806, in insert
ret =  self._db._adapter.insert(self,self._listify(fields))
  File "/Users/annet/web2py/gluon/dal.py", line 1161, in insert
raise e
ProgrammingError: ('ERROR', '23502', 'null value in column "aboutid" violates 
not-null constraint')

 Error snapshot [image: help]  

(('ERROR', '23502', 
'null value in column "aboutid" violates not-null constraint')) 

inspect attributes 
 Frames 
   
   -  
   
   *File /Users/annet/web2py/gluon/restricted.py in restricted at line 212* 
   code arguments variables 
-  
   
   *File /Users/annet/web2py/applications/init/controllers/cmssite.py in 
at line 417* code arguments variables 
-  
   
   *File /Users/annet/web2py/gluon/globals.py in  at line 188* code 
   arguments variables 
-  
   
   *File /Users/annet/web2py/gluon/tools.py in f at line 2912* code 
   arguments variables 
-  
   
   *File /Users/annet/web2py/applications/init/controllers/cmssite.py in 
   homePage at line 239* code arguments variables 
-  
   
   *File /Users/annet/web2py/gluon/tools.py in update at line 3511* code 
   arguments variables 
-  
   
   *File /Users/annet/web2py/gluon/sqlhtml.py in accepts at line 1475* code 
   arguments variables 
-  
   
   *File /Users/annet/web2py/gluon/dal.py in insert at line 7806* code 
   arguments variables 
-  
   
   *File /Users/annet/web2py/gluon/dal.py in insert at line 1161* code 
   arguments variables 
Function argument list 
   
   (self=, table=, fields=[(, 'Iedereen is welkom bij het USC!'), (, 
   datetime.datetime(2012, 11, 22, 16, 10, 8, 432055)), (, datetime.datetime(2012, 11, 22, 16, 10, 8, 432055)), 
   (, ''), (, '')])
Code listing 
   
   1156.
   1157.
   1158.
   1159.
   1160.
   1161.
   
   1162.
   1163.
   1164.
   1165.
   
   try:
   self.execute(query)
   except Exception, e:
   if isinstance(e,self.integrity_error_class()):
   return None
   raise e
   
   if hasattr(table,'_primarykey'):
   return dict([(k[0].name, k[1]) for k in fields \
if k[0].name in table._primarykey])
   id = self.lastrowid(table)
   
Variables  e ProgrammingError('ERROR', '23502', 'null value in column 
   "aboutid" violates not-null constraint')
   

Why are the hidden fields ignored in form=crud.update(..)?

Kind regards,

Annet.

--