Hello everybody.
Please, anybory know a alternative or workaround to do this work?
And Sorry by my bad english.

On Oct 21, 5:17 pm, Savio Sabino <savi...@gmail.com> wrote:
> And reading the model of plugin_wiki I see that in def jqgrid the
> parameters and you doc are divergent in fields -> columns and
> col_widths -> ??? (I think):
>
> �...@staticmethod
>     def jqgrid(table,fieldname=None,fieldvalue=None,col_widths='',
>                _id=None,fields='',col_width=80,width=700,height=300):
>         """
>         ## Embed a jqGrid plugin
>         - ``table`` is the table name
>         - ``fieldname``, ``fieldvalue`` are an optional filter
> (fieldname==fieldvalue)
>         - ``_id`` is the "id" of the DIV that contains the jqGrid
>         - ``columns`` is a list of columns names to be displayed
>         - ``col_width`` is the width of each column (default)
>         - ``height`` is the height of the jqGrid
>         - ``width`` is the width of the jqGrid
>         """
>
> On Oct 21, 5:02 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Now I see the problem... need to think about this. It is not a but, it
> > just that virtual fields and not listed an must be retrieved
> > explicitly.
>
> > On Oct 21, 12:25 pm, Savio Sabino <savi...@gmail.com> wrote:
>
> > > The version is 1.87.3
> > > Ok, I found the problem.
> > > More this method shows the query in console ok?
> > > More this do not send virtual field to crud methods or appadmin. And I
> > > do not have idea in how to force it.
> > > Trying with jqgrid:
>
> > > {{=plugin_wiki.widget('jqgrid', db.produto,fields="id,nome",
> > > width=800,height=250)}}
>
> > > If I use fields parameters with the two fields above and in model I
> > > include the line:
>
> > > db.produto.virtualfields.append(VirtualFields())
>
> > > The data in jqgrid is not displayed.
>
> > > On Oct 21, 12:13 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > I made a new welcome app and this in a model:
>
> > > > db.define_table('produto',
> > > >                 Field('nome','string'),
> > > >                 Field('quant','integer',default=0),
> > > >                 Field('quant_min','integer',default=0)
> > > >                 )
> > > > class VirtualFields:
> > > >     def prodEnt(self):
> > > >         return self.produto.quant_min * 2
> > > > db.produto.virtualfields.append(VirtualFields())
> > > > db.produto.insert(nome='book',quant_min=5)
> > > > for row in db(db.produto).select():
> > > >     print row.nome, row.prodEnt
>
> > > > It works for me. What web2py version do you have? Can you reproduce
> > > > the problem in a smaller app?
>
> > > > On Oct 21, 9:57 am, Savio Sabino <savi...@gmail.com> wrote:
>
> > > > > I new app test, I have missed a line, the correct is:
>
> > > > > db.define_table('produto',
> > > > >                 Field('nome','string'),
> > > > >                 Field('quant','integer',default=0),
> > > > >                 Field('quant_min','integer',default=0)
> > > > >                 )
> > > > > class VirtualFields:
> > > > >     def prodEnt(self): return self.produto.quant_min * 2
> > > > > db.produto.virtualfields.append(VirtualFields())
> > > > > db.define_table('produto2',
> > > > >                 Field('nome','string'),
> > > > >                 Field('quant','integer',default=0),
> > > > >                 Field('quant_min','integer',default=0)
> > > > >                 )
>
> > > > > More, this do no have effect.
>
> > > > > On Oct 21, 11:37 am, Savio Sabino <savi...@gmail.com> wrote:
>
> > > > > > Ops, sorry. Desconsider this. I used google translate because I
> > > > > > develop in Portuguese.
> > > > > > The correct:
> > > > > > class VirtualFields:
>
> > > > > > The code in portuguese:
>
> > > > > > iAdm = db.Table(db, 'iAdm',
> > > > > >                 Field('nome',notnull=True),
> > > > > >                 Field('obs'),
> > > > > >                 Field('ativo','boolean',default=True),
> > > > > >                 Field('dt','datetime',default=request.now),
> > > > > >                 Field('user',db.auth_user,default=auth.user_id)
> > > > > >                 )
>
> > > > > > iAdm.dt.writable=False
> > > > > > iAdm.dt.readable=False
> > > > > > iAdm.user.writable=False
> > > > > > iAdm.user.readable=False
>
> > > > > > db.define_table('tp_produto', iAdm,
> > > > > >                 Field('pai','reference tp_produto'),
> > > > > >                 )
> > > > > > db.tp_produto.pai.requires = IS_EMPTY_OR(IS_IN_DB(db,
> > > > > > db.tp_produto.id, '%(nome)s'))
> > > > > > db.tp_produto.nome.requires = IS_NOT_IN_DB(db, db.tp_produto.nome)
>
> > > > > > db.define_table('fabricante', iAdm)
> > > > > > db.fabricante.nome.requires = IS_NOT_IN_DB(db, db.fabricante.nome)
>
> > > > > > db.define_table('fornecedor', iAdm,
> > > > > >                 Field('CNPJ'),
> > > > > >                 Field('contato'),
> > > > > >                 Field('email'),
> > > > > >                 Field('telefone')
> > > > > >                 )
> > > > > > db.fornecedor.nome.requires = IS_NOT_IN_DB(db, db.fornecedor.nome)
>
> > > > > > db.define_table('produto', iAdm,
> > > > > >                 Field('tipo',db.tp_produto),
> > > > > >                 Field('fabricante',db.fabricante),
> > > > > >                 Field('quant','integer',default=0),
> > > > > >                 Field('quant_min','integer',default=0)
> > > > > >                 )
> > > > > > class VirtualFields:
> > > > > >     def prodEnt(self): return self.produto.quant_min * 2
> > > > > > db.produto.virtualfields.append(VirtualFields())
> > > > > > db.produto.tipo.requires = IS_IN_DB(db, db.tp_produto.id, 
> > > > > > '%(nome)s')
> > > > > > db.produto.fabricante.requires = IS_IN_DB(db, db.fabricante.id, '%
> > > > > > (nome)s')
> > > > > > db.produto.nome.requires = IS_NOT_IN_DB(db, db.produto.nome)
>
> > > > > > db.produto.id.represent = lambda valor:
> > > > > > A(valor,_href=URL(r=request,c='default',f='editProduto',args=valor))
>
> > > > > > db.produto.nome.represent = lambda valor: A(valor,_href="#",
> > > > > > _onclick="jQuery('#mdlEntrada').fadeIn(); return false")
>
> > > > > > iOpr = db.Table(db, 'iOpr',
> > > > > >                 Field('produto',db.produto),
> > > > > >                 Field('fornecedor',db.fornecedor),
> > > > > >                 Field('quant','integer'),
> > > > > >                 Field('chamado'),
> > > > > >                 Field('obs'),
> > > > > >                 Field('ativo','boolean',default=True),
> > > > > >                 Field('dt','datetime',default=request.now),
> > > > > >                 Field('user',db.auth_user,default=auth.user_id)
> > > > > >                 )
> > > > > > iOpr.produto.requires = IS_IN_DB(db,db.produto.id,'%(nome)s')
> > > > > > iOpr.fornecedor.requires = IS_IN_DB(db,db.fornecedor.id,'%(nome)s')
>
> > > > > > iOpr.dt.writable=False
> > > > > > iOpr.dt.readable=False
> > > > > > iOpr.user.writable=False
> > > > > > iOpr.user.readable=False
>
> > > > > > db.define_table('estoque', iOpr)
>
> > > > > > db.define_table('entrada', iOpr,
> > > > > >                 Field('NF'),
> > > > > >                 Field('dt_garantia','date')
> > > > > >                 )
>
> > > > > > db.define_table('saida', iOpr)
>
> > > > > > The case to test virtual fields as made the most isolated as 
> > > > > > possible
> > > > > > to ensure the error orign: I have remove table inheritance for table
> > > > > > produto, and remove the represent.
>
> > > > > > Correcting myself. The error does not occur in Appadmin but in a
> > > > > > custom crud function:
>
> > > > > > @auth.requires_login()
> > > > > > def admin():
> > > > > >     args = request.args
> > > > > >     titulo = 'administração'
> > > > > >     if not args:
> > > > > >         link = UL(*[LI(A(tab,_href=URL(args=tab))) for tab in
> > > > > > db.tables])
> > > > > >         return dict(items=link,titulo=titulo)
>
> > > > > >     if not args(1):
> > > > > >         i = 0
> > > > > >     else:
> > > > > >         i =1
>
> > > > > >     for tab in db.tables:
> > > > > >         if tab==args(i):
> > > > > >             tb = db[tab]
>
> > > > > >     if args(0)=='editar':
> > > > > >         form = crud.update(tb,
> > > > > > args(2),next=URL(f='admin',args=args(1)))
> > > > > >         items = None
> > > > > >         titulo = 'Editar %s ' % args(i)
> > > > > >     else:
> > > > > >         form = crud.create(tb)
> > > > > >         rows = db().select(tb.ALL)
> > > > > >         items = SQLTABLE(rows,linkto='editar')
> > > > > >         titulo = 'Inserir %s ' % args(i)
>
> > > > > > And the error:
>
> > > > > > File "C:/web2py/applications/estoque/models/db.py", line 40, in
> > > > > > prodEnt
> > > > > >     def prodEnt(self): return self.produto.quant_min * 2
> > > > > >   File "C:\web2py\gluon\sql.py", line 733, in __getattr__
> > > > > >     return dict.__getitem__(self,key)
> > > > > > KeyError: 'quant_min'
>
> > > > > > Exception: <type 'exceptions.KeyError'>('quant_min')
>
> > > > > >  Function argument list: (self=<Row {'estoque': <gluon.sql.Set 
> > > > > > object
> > > > > > at 0x0531...'entrada': <gluon.sql.Set object at 0x0531B690>}>,
> > > > > > key='quant_min')
>
> > > > > > 728.
> > > > > > 729.
> > > > > > 730.
> > > > > > 731.
> > > > > > 732.
> > > > > > 733.
>
> > > > > > 734.
> > > > > > 735.
> > > > > > 736.
> > > > > > 737.
>
> > > > > >     def __setitem__(self, key, value):
> > > > > >         dict.__setitem__(self, str(key), value)
>
> > > > > >     def __getattr__(self, key):
> > > > > > return dict.__getitem__(self,key)
>
> > > > > >     def __setattr__(self, key, value):
> > > > > >         dict.__setitem__(self,key,value)
>
> > > > > >     * self: <Row {'estoque': <gluon.sql.Set object at
> > > > > > 0x0531...'entrada': <gluon.sql.Set object at 0x0531B690>}>
> > > > > >     * dict.__getitem__: <method '__getitem__' of 'dict' objects>
> > > > > >     * builtindict: <type 'dict'>
>
> ...
>
> read more »

Reply via email to