Suppose I have a table like:
db.define_table('location',
Field(name, 'string'),
Field('point', 'geometry()')
)
I want to have the latitude and longitude as attributes also (whose value
can be derived from the point field). So I try this:
db.define_table('location',
Field(name, 'string'),
Field('point', 'geometry()'),
Field.Virtual('latitude', lambda row: row.location.point.st_x()),
Field.Virtual('longitude', lambda row: row.location.point.st_y()),
)
But it doesn't work and fails silently. The model just doesn't have
latitude or longitude fields. I also tried with Field.Method but this
complains that 'point' is of typer str.
I guess the complication is that st_x() translates into a database
function. I'm thinking about parsing the point string which is of the form
"POINT(x y)" as a workaround but I'd rather use st_x if someone can show me
how.
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.