Why change underline to hyphen in url patterns of parse_as_rest()?

71 views
Skip to first unread message

Ray (a.k.a. Iceberg)

unread,
Jul 1, 2013, 7:30:51 AM7/1/13
to web...@googlegroups.com
Hi folks,

I just noticed that, the auto patterns generated by dal.py's parse_as_rest() are using hyphen to replace underline. This way if I have:

    db.define_table("my_table",
        Field("my_field"),
        )

it will show up in auto patterns as a url like "http://.../my-table/my-field".

However this brings some inconvenience when I am writing other pieces of program to access this patterns.

So the question is, why dal.py's parse_as_rest() intentionally change all underlines into hyphens? I don't think SEO consideration matters in an api. So why?

Thanks in advance.

Regards,
Ray

Ray (a.k.a. Iceberg)

unread,
Jul 1, 2013, 10:47:16 AM7/1/13
to web...@googlegroups.com

Actually I am working on a generic rest api. I end up with several unnecessary lines of "...replace('-', '_')", in order to counteract the undesirable "underline to hyphen" behavior, came from dal.py's parse_as_rest() auto pattern. Yet I am still curious to know, why design a "underline to hyphen" behavior in parse_as_rest() auto pattern?

Regards,
Ray

Ray (a.k.a. Iceberg)

unread,
Sep 4, 2013, 1:30:39 AM9/4/13
to web...@googlegroups.com

I got bitten by the same problem, again. So, in short, my table looks like this:


   db.define_table("my_table",
        Field("my_field"),
        )

Why the auto patterns generated by parse_as_rest() ends up as something like this (notice the hyphen)?

    "/my-table/id/{my_table.id}",
    "/my-table/id/{my_table.id}/:field",

and I prefer this (notice the underline):

"/my_table/id/{my_table.id}", "/my_table/id/{my_table.id}/:field",

Any thoughts?
 
Reply all
Reply to author
Forward
0 new messages