Maybe you could use a virtual field and not a computed one:

db.rentals.urlid = Field.Virtual( 'urlid', lambda r: URL('rentals_manage', 
args=r.id) )

then after rows = db(db.rentals...).select(...)
the rows will contain an urlid field.

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Virtual-fields


On Sunday, April 3, 2016 at 8:17:25 PM UTC-4, Henk huisman wrote:
>
> Could anyone show me how to build a query with a computed field that 
> consists of a constant and a value of the ID of the records.
> The constant is an URL and the value is the ID of the row.
>
> I tried this (among several other attempts).
>
> rowsb=db.executesql("SELECT 'dikke bmw' as caption, startdate as start, 
>  '../rentals_manage/'+ %s  as url, FROM rentals;",as_dict = 
> True,placeholders=('id',))
>
> but that doesn't seem to be valid syntax...
>
> the output is needed by Timeline which is actually a very nice widget 
> http://www.simile-widgets.org/timeline/
>
> Danki
>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to