python - Posting a list to a web2py database -
i have simple web2py app implements restful api. in model, have like:
db.define_table('vehicles', field('flightid', type='string', default='00000', length=128, . . . field('route', 'reference path'), ) db.define_table('path', field('coordinates', type='list:integer', requires=is_not_empty())) i want vehicle able reference path, managed database entry. path, of course, given coordinate pairs in latitude/longitude list of tuples best. there more sensible way this? how post list of ints? use requests this?
the client needs able query vehicle lot, not send full path each time happens there many points along path. i'm totally out of element web stuff, appreciate help, tips or resources can provide in regard.
i don't see how store sequence of latitude/longitude pairs in list:integer field. instead, might consider following options:
- make
db.path.coordinatesjsonfield, , submit coordinates json object. when retrieving records table, web2py dal automatically convert json python object manipulation python. - use
stringortextfield , create own custom serialization of data string format, parsing data when doing inserts , selects. - implement option #2 using either
filter_in/filter_outor custom field type.
Comments
Post a Comment