oh, we are over my parse_as_rest knowledge... i've only accessed the
args directly and did my own logic with it. :(
On 5/6/13 16:51 , Bernard wrote:
I don't think the form validators are used when using parse_as_rest().
When the URI is parsed, the date is simply extracted (as a string?) into a
DAL query.
Ex from my previous query:
http://localhost/manager/default/api/unit/123/timeseries/2013-05-01/2013-05-02
query=(unit.unit_id = '123')
query=(timeseries.utc_time >= '2013-05-01')
query=(timeseries.utc_time <= '2013-05-02')
Printed from dal.py->parse_as_rest()
The three above queries are and-ed together in the line
: "dbset=dbset(query)"
On Monday, May 6, 2013 3:39:13 PM UTC-7, Christian Foster Howes wrote:
there are a couple of characters that web2py is not nice about in the
URL parsing.....
for the format string, on the datetime fields use the
IS_DATETIME(format='...') validator with a custom format string. see
http://web2py.com/books/default/chapter/29/07#Validators
On 5/6/13 15:35 , Bernard wrote:
Thanks Christian,
I tried to escape it to %3A but that gave me an error invalid request. I
couldn't figure out where it's being blocked on the server (routes.py?).
Where can I get more info to change separator and parsing? Is that all
in
dal.py?
On Monday, May 6, 2013 3:28:03 PM UTC-7, Christian Foster Howes wrote:
can you url escape the : and have it work?
if not, maybe use a different separator and change the string to
timestamp
parsing to expect your format.
cfh
On Monday, May 6, 2013 1:42:40 PM UTC-7, Bernard wrote:
Hi Web2py users,
I am using the parse_as_rest feature for filtering by date range:
The pattern is as follows:
"/unit/{unit.unit_id}/timeseries[timeseries.unit]/{
timeseries.utc_time.ge}/{timeseries.utc_time.le}",
I couldn't find documentation that 'ge' and 'le' are valid for
datetime
fields, it seems to work well:
http://localhost/manager/default/api/unit/123/timeseries/2013-05-01/2013-05-02
However, I need to filter based on date and time.
Ideally, I would like to send a request with the time as part of the
date
specification:
http://localhost/manager/default/api/unit/123/timeseries/2013-05-0102:00/2013-05-0200:00
However, this is an invalid request due to the ':' in the URI.
I looked into using seconds since epoch for the datetime spec, but
that's
too slow on sqlite.
I'm wondering if anybody knows an easy way to work around this?
The not so pretty solution I'm considering right now is to add a time
as
part of the URI after the date:
http://localhost/manager/default/api/unit/123/timeseries/2013-05-01/02/00/2013-05-02/00/00
Then, in the controller, I would modify the args before passing to the
parse_as_rest() function by concating args 4 and 5 with the date in
arg 3,
to form the correct format ('YYYY-MM-YY hh:ss') that parse_as_rest()
can
use.
Any help much appreciated.
Regards,
Bernard
--
---
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.