[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
I get the same error with the correct field name.

On Dec 27, 11:15 am, Anthony abasta...@gmail.com wrote:
 I think you want format='%(dog_name)s' -- there is no 'name' field in the
 'dog' table.

 Anthony







 On Tuesday, December 27, 2011 11:11:18 AM UTC-5, Cliff wrote:

  This is kind of a show stopper.  Smartgrid appears to stumble over
  table format definitions.

  Note the commented out format line in this model.
  db.define_table('dog',
                  Field('dog_name', length=32),
  ##                format='%(name)s',
                 )
  db.define_table('owner',
                  Field('name', length=32),
                  Field('phone', length=32),
                 )
  db.define_table('dog_owner',
                  Field('dog_id', db.dog),
                  Field('owner_id', db.owner)
                 )

  Uncomment the line and smartgrid 1.99.4 raises this exception when
  trying to
  add a record to the dog_owner table:
  type 'exceptions.TypeError' string indices must be integers, not str

  Here is the traceback:
  Traceback (most recent call last):
    File /home/cjk/w-99-4/web2py/gluon/restricted.py, line 204, in
  restricted
      exec ccode in environment
    File /home/cjk/w-99-4/web2py/applications/doggies/controllers/
  dog.py, line 5, in module
    File /home/cjk/w-99-4/web2py/gluon/globals.py, line 172, in
  lambda
      self._caller = lambda f: f()
    File /home/cjk/w-99-4/web2py/applications/doggies/controllers/
  dog.py, line 2, in index
      form = SQLFORM.smartgrid(db.dog)
    File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 1991, in
  smartgrid
      user_signature=user_signature,**kwargs)
    File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 1581, in grid
      _class='web2py_form').process(
    File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 862, in
  __init__
      inp = self.widgets.options.widget(field, default)
    File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 220, in widget
      return SELECT(*opts, **attr)
    File /home/cjk/w-99-4/web2py/gluon/html.py, line 587, in __init__
      self._postprocessing()
    File /home/cjk/w-99-4/web2py/gluon/html.py, line 1704, in
  _postprocessing
      if value and str(c['_value'])==str(value):
  TypeError: string indices must be integers, not str

  Here is the controller:
  def index():
      form = SQLFORM.smartgrid(
          db.owner,
          ui = 'jquery-ui',
          onvalidation = crud.archive,
      )
      return dict(form=form)

  To duplicate the problem:
  Add one owner and one dog.
  In your browser, open localhost:8000/dogapp/owner/index
  Edit the owner.
  Click the Dog Owner link
  Note the empty grid with add button.
  Click Add
  Observe web2py error message

  Similar exceptions occur if you use IS_IN_DB to define a format
  string.


[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Anthony
Can you open a ticket: http://code.google.com/p/web2py/issues/list



[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Anthony
I think you want format='%(dog_name)s' -- there is no 'name' field in the 
'dog' table.

Anthony

On Tuesday, December 27, 2011 11:11:18 AM UTC-5, Cliff wrote:

 This is kind of a show stopper.  Smartgrid appears to stumble over 
 table format definitions. 

 Note the commented out format line in this model. 
 db.define_table('dog', 
 Field('dog_name', length=32), 
 ##format='%(name)s', 
) 
 db.define_table('owner', 
 Field('name', length=32), 
 Field('phone', length=32), 
) 
 db.define_table('dog_owner', 
 Field('dog_id', db.dog), 
 Field('owner_id', db.owner) 
) 

 Uncomment the line and smartgrid 1.99.4 raises this exception when 
 trying to 
 add a record to the dog_owner table: 
 type 'exceptions.TypeError' string indices must be integers, not str 

 Here is the traceback: 
 Traceback (most recent call last): 
   File /home/cjk/w-99-4/web2py/gluon/restricted.py, line 204, in 
 restricted 
 exec ccode in environment 
   File /home/cjk/w-99-4/web2py/applications/doggies/controllers/ 
 dog.py, line 5, in module 
   File /home/cjk/w-99-4/web2py/gluon/globals.py, line 172, in 
 lambda 
 self._caller = lambda f: f() 
   File /home/cjk/w-99-4/web2py/applications/doggies/controllers/ 
 dog.py, line 2, in index 
 form = SQLFORM.smartgrid(db.dog) 
   File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 1991, in 
 smartgrid 
 user_signature=user_signature,**kwargs) 
   File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 1581, in grid 
 _class='web2py_form').process( 
   File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 862, in 
 __init__ 
 inp = self.widgets.options.widget(field, default) 
   File /home/cjk/w-99-4/web2py/gluon/sqlhtml.py, line 220, in widget 
 return SELECT(*opts, **attr) 
   File /home/cjk/w-99-4/web2py/gluon/html.py, line 587, in __init__ 
 self._postprocessing() 
   File /home/cjk/w-99-4/web2py/gluon/html.py, line 1704, in 
 _postprocessing 
 if value and str(c['_value'])==str(value): 
 TypeError: string indices must be integers, not str 

 Here is the controller: 
 def index(): 
 form = SQLFORM.smartgrid( 
 db.owner, 
 ui = 'jquery-ui', 
 onvalidation = crud.archive, 
 ) 
 return dict(form=form) 

 To duplicate the problem: 
 Add one owner and one dog. 
 In your browser, open localhost:8000/dogapp/owner/index 
 Edit the owner. 
 Click the Dog Owner link 
 Note the empty grid with add button. 
 Click Add 
 Observe web2py error message 

 Similar exceptions occur if you use IS_IN_DB to define a format 
 string. 



[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
Done.

Thanks.

On Dec 27, 11:36 am, Anthony abasta...@gmail.com wrote:
 Can you open a ticket:http://code.google.com/p/web2py/issues/list


[web2py] Re: smartgrid raises exception when adding record in many-to-many

2011-12-27 Thread Cliff
My bad.

The problem was self inflicted, caused by a diagnostic change I made
to html.py.

On Dec 27, 12:07 pm, Cliff cjk...@gmail.com wrote:
 Done.

 Thanks.

 On Dec 27, 11:36 am, Anthony abasta...@gmail.com wrote:







  Can you open a ticket:http://code.google.com/p/web2py/issues/list