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:

<input type="hidden" value="11" name="nodeID">
<input type="hidden" value="1" name="aboutID">

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
<class 'gluon.contrib.pg8000.errors.ProgrammingError'> ('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" 
<http://127.0.0.1:8000/admin/edit/init/controllers/cmssite.py>, line 417, in 
<module>
  File "/Users/annet/web2py/gluon/globals.py", line 188, in <lambda>
    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" 
<http://127.0.0.1:8000/admin/edit/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]  

<class 'gluon.contrib.pg8000.errors.ProgrammingError'>(('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 
   <module> at line 417* code arguments variables 
    -  
   
   *File /Users/annet/web2py/gluon/globals.py in <lambda> 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=<gluon.dal.PostgreSQLAdapter object>, table=<Table aboutText 
   (id,nodeID,aboutID,text,createdOn,modifiedOn)>, fields=[(<gluon.dal.Field 
   object>, '<h4><em>Iedereen is welkom bij het USC!</em></h4...ard is overal 
   een horecavoorziening aanwezig.</p>'), (<gluon.dal.Field object>, 
   datetime.datetime(2012, 11, 22, 16, 10, 8, 432055)), (<gluon.dal.Field 
   object>, datetime.datetime(2012, 11, 22, 16, 10, 8, 432055)), 
   (<gluon.dal.Field object>, ''), (<gluon.dal.Field object>, '')])
    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.

-- 



Reply via email to