Virtual field strange behaviour

33 views
Skip to first unread message

António Ramos

unread,
Jul 24, 2017, 12:50:20 PM7/24/17
to web...@googlegroups.com
i have 2 tables

db.define_table('log',
Field('msg',"text"),
Field('created','datetime',default=datetime.datetime.utcnow()))

 
db.define_table(
"status",
Field.Virtual('blabla', lambda row: db.log.insert(msg="mmm")),
Format="%(title)s"
)


if i go to admin and select "log" database, every time i press "send" with db.log.id>0 as the query i get anoter row in table log with the record msg="mmm"

why is this???

regards

António

Leonel Câmara

unread,
Jul 24, 2017, 1:35:20 PM7/24/17
to web2py-users
What do you mean? Your virtual field is inserting 'mmm' into the log table. When you call "select" the virtual field is called for each row by the default processor which creates the Rows object.  

You can see the default processing rows from the DB get here:

ramstein74

unread,
Jul 24, 2017, 2:46:15 PM7/24/17
to web...@googlegroups.com
But the select is on table log and not on table status. Also i have many rows in table status and the select on table log fires the virtual field on table status and creates only one row in log.
Im confused by this




Enviado a partir do meu smartphone Samsung Galaxy.

-------- Mensagem original --------
De: Leonel Câmara <leonel...@gmail.com>
Data: 24/07/17 18:35 (GMT+00:00)
Para: web2py-users <web...@googlegroups.com>
Assunto: [web2py] Re: Virtual field strange behaviour

What do you mean? Your virtual field is inserting 'mmm' into the log table. When you call "select" the virtual field is called for each row by the default processor which creates the Rows object.  

You can see the default processing rows from the DB get here:

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Jul 24, 2017, 3:33:21 PM7/24/17
to web2py-users
Please attach a minimal app that reproduces the behavior.
Reply all
Reply to author
Forward
0 new messages