Does it work if you make the following change in line 1808 of sqlhtml.py:
A(callable(rep) and rep(id) or id, _href=...
Anthony
On Saturday, December 10, 2011 11:29:41 AM UTC-5, Vincenzo Ampolo wrote:
>
> Hi,
>
> i've defined the following relations:
>
> db.define_table('users_dictionaries',
> Field('user_id', db.auth_user, requires =
> IS_IN_DB(db,'auth_user.id', db.auth_user._format)),
> Field('dictionary_id', db.dictionary,
> requires=IS_IN_DB(db,'dictionary.id',db.dictionary._format)),
> )
>
> db.define_table('users_categories',
> Field('user_id', db.auth_user, requires =
> IS_IN_DB(db,'auth_user.id', db.auth_user._format)),
> Field('category_id', db.category,
> requires=IS_IN_DB(db,'category.id',db.category._format)),
> )
>
> i then created a grid=SQLFORM.smartgrid(db.auth_user) and i can see the
> many-to-many relations i can navigate on them but when i try to add one i
> get:
>
> Traceback (most recent call last):
> File "/var/www/argomenti.in/web2py/gluon/restricted.py", line 194, in
> restricted
> exec ccode in environment
> File
> "/var/www/argomenti.in/web2py/applications/webkeywords2/controllers/admin.py"
> <http://localhost:8000/admin/default/edit/webkeywords2/controllers/admin.py>,
> line 13, in <module>
> File "/var/www/argomenti.in/web2py/gluon/globals.py", line 149, in <lambda>
> self._caller = lambda f: f()
> File "/var/www/argomenti.in/web2py/gluon/tools.py", line 2456, in f
> return action(*a, **b)
> File
> "/var/www/argomenti.in/web2py/applications/webkeywords2/controllers/admin.py"
> <http://localhost:8000/admin/default/edit/webkeywords2/controllers/admin.py>,
> line 6, in index
> grid = SQLFORM.smartgrid(db.auth_user)
> File "/var/www/argomenti.in/web2py/gluon/sqlhtml.py", line 1821, in
> smartgrid
> user_signature=user_signature,**kwargs)
> File "/var/www/argomenti.in/web2py/gluon/sqlhtml.py", line 1668, in grid
> value=field.represent(value,rrow)
> File "/var/www/argomenti.in/web2py/gluon/sqlhtml.py", line 1808, in <lambda>
> field.represent = lambda id,r=None,referee=referee,rep=field.represent:
> A(rep(id),_href=URL(args=request.args[:args]+['view',referee,id],
> user_signature=user_signature))TypeError: 'NoneType' object is not callable
>
> The problem is rep() being None but the documentation about
> field.represent says:
>
> represent can be None or can poin
> t to a function that takes a field value and returns an alternate
> representation for the field value.
>
> So it can be None or a function.... how can i fix it?
>
> --
> Vincenzo Ampolohttp://vincenzo-ampolo.nethttp://goshawknest.wordpress.com
>
>