Programatically create Row

57 views
Skip to first unread message

david...@gmail.com

unread,
Feb 12, 2021, 12:26:42 PM2/12/21
to web2py-users
I have a controller that displays confidential data from a table but want to be able to show the form publicly with some dummy data. The controller makes use of field representation and references so I basically need a Row.

I can create the object I need using the table.insert() methods and then db.rollback() to avoid committing the dummy data but is there a better method. I've had a look at the internals of Row and suspect that trying to create a Row object by hand would be pretty fraught, but is there a better way than just using insert() and rollback()? It feels like using a sledgehammer to crack a nut.

Cheers,
David

Jacinto Parga

unread,
Feb 13, 2021, 3:36:57 AM2/13/21
to web2py-users

David Orme

unread,
Feb 13, 2021, 11:45:09 AM2/13/21
to web...@googlegroups.com
Thanks for the suggestion. I don't need to create the form programmatically - the factory is great for that. I've already got code to create the form but want to create a dummy row on the server side to populate a display example form. 

Cheers, 
David

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/FSHPxYTxr24/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5ce7ca44-d5d7-4854-96c9-99b78b14fcdcn%40googlegroups.com.

Jacinto Parga

unread,
Feb 15, 2021, 10:53:12 AM2/15/21
to web2py-users
So, do you want to storage a dummy row to be proccessed in the same controler or to be passed to another controller or function?. I mean, if you want to use it in the same controller why not a local variable to storage it.. 

If you have used a SQLFORM. factory to get the values they are storaged in form.vars object.

What do you mean with a dummy row? Is it like a structure of a db row? 

Reply all
Reply to author
Forward
0 new messages